Skip to content

feat: [DHIS2-21394] Implement read-only mode for event program view event#4566

Open
henrikmv wants to merge 7 commits into
hv/chore/DHIS2-21371_EnrollmentDashboardReadOnlyfrom
hv/chore/DHIS2-21394_view-single-event-read-only
Open

feat: [DHIS2-21394] Implement read-only mode for event program view event#4566
henrikmv wants to merge 7 commits into
hv/chore/DHIS2-21371_EnrollmentDashboardReadOnlyfrom
hv/chore/DHIS2-21394_view-single-event-read-only

Conversation

@henrikmv
Copy link
Copy Markdown
Contributor

@henrikmv henrikmv commented May 15, 2026

DHIS2-21394

Event program — view event page

Action / Element Missing event write access Expired ¹ Event completed + stage blocks entry
Edit event (button on event details) button hidden, read-only badge button hidden, read-only badge button hidden, read-only badge
View changelog (overflow menu) shown shown shown
Modify event notes (NotesSection) widget read-only widget read-only widget read-only
Modify Relationships (RelationshipsSection) add/remove actions hidden add/remove actions hidden add/remove actions hidden
Modify Assignee (AssigneeSection) DisplayMode read-only DisplayMode read-only DisplayMode read-only
Event data form (edit mode) unreachable — edit button hidden unreachable unreachable
Top-right page badge shown — “view access to program” shown — “outside the valid period” shown — “has been completed”

Authorities (user-role flags)

¹ Expired events can be modified with F_EDIT_EXPIRED.
completeEventsExpiryDays is not respected and will be added in #4583

@henrikmv henrikmv changed the base branch from master to hv/chore/DHIS2-21371_EnrollmentDashboardReadOnly May 15, 2026 11:33
@henrikmv henrikmv marked this pull request as ready for review May 16, 2026 12:21
@henrikmv henrikmv requested a review from a team as a code owner May 16, 2026 12:21
devin-ai-integration[bot]

This comment was marked as resolved.

@henrikmv henrikmv marked this pull request as draft May 18, 2026 10:08
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

@henrikmv henrikmv added testing and removed testing labels May 20, 2026
@henrikmv henrikmv marked this pull request as ready for review May 20, 2026 15:11
devin-ai-integration[bot]

This comment was marked as resolved.

@sonarqubecloud
Copy link
Copy Markdown

@simonadomnisoru simonadomnisoru changed the title chore: [DHIS2-21394] Implement read-only mode for event program view event feat: [DHIS2-21394] Implement read-only mode for event program view event May 25, 2026
Comment on lines +96 to +108
const expiryPeriod = useProgramExpiryForUser(programId);
const occurredAt = useSelector((state: any) => state.viewEventPage.loadedValues?.dataEntryValues?.occurredAt);
const eventStatus = useSelector((state: any) => state.viewEventPage.loadedValues?.eventContainer?.event?.status);
const { hasAuthority: canUncompleteEvent } = useAuthorities({ authorities: ['F_UNCOMPLETE_EVENT'] });
const occurredAtClient = convertFormToClient(occurredAt, dataElementTypes.DATE) as string;
const { isWithinValidPeriod: isEventWithinValidPeriod } = isValidPeriod(occurredAtClient, expiryPeriod ?? null);
const canEditCompletedEvent = !(
programStage?.blockEntryForm
&& !canUncompleteEvent
&& eventStatus === eventStatuses.COMPLETED
);
const readOnly = !eventAccess.write || !isEventWithinValidPeriod || !canEditCompletedEvent;
const showEditButton = !isEditEventPage && !readOnly;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep the code cleaner, perhaps these lines could be moved from ViewEvent.component.tsx to ViewEvent.container.tsx? Ideally, the *.component.tsx files shouldn't handle much computation logic. Extracting this into an external function/custom hook is another good alternative.
Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, @simonadomnisoru .

There is already a significant amount of permission-checking logic, and more will soon be added. This is further complicated by the same logic being implemented in both Tracker and Event programs, even though they share the same permission behaviour.

Since #4583 adds another permission check, I used that opportunity to create a shared hook for both program types. I will leave this requested change to that PR.

Let me know what you think. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants