Skip to content

Commit

Permalink
fix: only show close button for editors
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesvedder committed Jun 11, 2024
1 parent 1cb7740 commit b6dad92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions designer_v2/lib/features/study/study_controller_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class StudyControllerState extends StudyControllerBaseState implements IStudyApp
@override
bool get isPublishVisible => studyWithMetadata?.model.status == StudyStatus.draft;

@override
bool get isClosedVisible => studyWithMetadata?.model.status == StudyStatus.running && studyWithMetadata!.model.canEdit(super.currentUser);

@override
StudyStatus? get studyStatus => study.value?.status;

Expand Down
3 changes: 2 additions & 1 deletion designer_v2/lib/features/study/study_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ abstract class IStudyAppBarViewModel implements IStudyStatusBadgeViewModel, IStu
bool get isSyncIndicatorVisible;
bool get isStatusBadgeVisible;
bool get isPublishVisible;
bool get isClosedVisible;
}

/// Custom scaffold shared between all pages for an individual [Study]
Expand Down Expand Up @@ -237,7 +238,7 @@ class _StudyScaffoldState extends ConsumerState<StudyScaffold> {
actionButtons.add(const SizedBox(width: 12.0)); // padding
}

if (state.isPublished) {
if (state.isClosedVisible) {
final formViewModel = ref.watch(studyPublishValidatorProvider(widget.studyId));
final closeButton = ReactiveForm(
formGroup: formViewModel.form,
Expand Down

0 comments on commit b6dad92

Please sign in to comment.