Skip to content

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

Merged
henrikmv merged 71 commits into
masterfrom
hv/chore/DHIS2-21394_view-single-event-read-only
Jun 2, 2026
Merged

feat: [DHIS2-21394] Implement read-only mode for event program view event#4566
henrikmv merged 71 commits into
masterfrom
hv/chore/DHIS2-21394_view-single-event-read-only

Conversation

@henrikmv

@henrikmv henrikmv commented May 15, 2026

Copy link
Copy Markdown
Contributor

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 and others added 30 commits April 17, 2026 12:54
…ProgramAccess' into hv/chore/DHIS2-21371_EnrollmentDashboardReadOnly
@github-actions

github-actions Bot commented May 20, 2026

Copy link
Copy Markdown

@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.

@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!

@henrikmv henrikmv added testing and removed testing labels Jun 2, 2026
Base automatically changed from hv/chore/DHIS2-21371_EnrollmentDashboardReadOnly to master June 2, 2026 14:28
@sonarqubecloud

sonarqubecloud Bot commented Jun 2, 2026

Copy link
Copy Markdown

@henrikmv henrikmv added testing and removed testing labels Jun 2, 2026
@henrikmv
henrikmv merged commit a90e6a7 into master Jun 2, 2026
87 of 93 checks passed
@henrikmv
henrikmv deleted the hv/chore/DHIS2-21394_view-single-event-read-only branch June 2, 2026 15:30
dhis2-bot added a commit that referenced this pull request Jun 2, 2026
# [106.4.0](v106.3.0...v106.4.0) (2026-06-02)

### Features

* [DHIS2-21394] Implement read-only mode for event program view event ([#4566](#4566)) ([a90e6a7](a90e6a7))
@dhis2-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 106.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

simonadomnisoru pushed a commit that referenced this pull request Jun 18, 2026
# [106.4.0](v106.3.0...v106.4.0) (2026-06-02)

### Features

* [DHIS2-21394] Implement read-only mode for event program view event ([#4566](#4566)) ([a90e6a7](a90e6a7))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants