Skip to content

feat: [DHIS2-21941] Self contained changelog widget - #4690

Open
henrikmv wants to merge 6 commits into
hv/feat/DHIS2-21655_uncomplete-event-view-modefrom
hv/chore/DHIS2-21941_SingleSourceChangelogValues
Open

feat: [DHIS2-21941] Self contained changelog widget#4690
henrikmv wants to merge 6 commits into
hv/feat/DHIS2-21655_uncomplete-event-view-modefrom
hv/chore/DHIS2-21941_SingleSourceChangelogValues

Conversation

@henrikmv

@henrikmv henrikmv commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

DHIS2-21941

Reason behind this initiative: The fourth implementation of the Changelog, introduced in #4657, highlighted the need to make it easier to reuse.

This PR makes changelog widgets self-contained by removing the entityData / eventData / trackedEntityData props that were passed down from parent components. Instead, the changelog now fetches current entity values directly from the tracker API via a new useCurrentEntityValues hook.

Key changes

  • New useCurrentEntityValues hook — fetches current values from tracker/events/{id} or tracker/trackedEntities/{id}, replacing the prop-based approach.

  • Improved isLatestValue detection — previously compared change.currentValue against a prop-provided snapshot. Now validates against both the newest changelog entry per field and fresh API data.

  • Centralized removeChangelogQueries — extracts duplicated cache invalidation into a shared utility, and adds invalidation for two new mutation sites: CompletionMenuItem and SkipAction.

  • Opening the changelog now fires one extra tiny tracker/{events|trackedEntities}/{id}?fields=…[…,value] fetch, but it runs in parallel with the (slower) changelog list request, is cached with staleTime: Infinity so reopens are free, and is skipped entirely for changelogs without FILE_RESOURCE/IMAGE fields. In return, the widget becomes fully self-contained — no more entityData prop drilled from three different-shaped parent sources, and no more fragile ?.value hack that silently broke on stale parent caches.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

devin-ai-integration[bot]

This comment was marked as resolved.

@henrikmv henrikmv added testing and removed testing labels Aug 5, 2026
@henrikmv
henrikmv marked this pull request as ready for review August 5, 2026 14:57
@henrikmv
henrikmv requested a review from a team as a code owner August 5, 2026 14:57
@henrikmv henrikmv added testing and removed testing labels Aug 5, 2026
@henrikmv
henrikmv marked this pull request as draft August 6, 2026 06:45
@henrikmv
henrikmv marked this pull request as ready for review August 6, 2026 06:48
@henrikmv henrikmv added testing and removed testing labels Aug 6, 2026
@henrikmv henrikmv changed the title feat: [DHIS2-21941] Single source for changelog values feat: [DHIS2-21941] Self contained changelog widget Aug 6, 2026
…vent-view-mode' into hv/chore/DHIS2-21941_SingleSourceChangelogValues
@henrikmv
henrikmv marked this pull request as draft August 12, 2026 10:46
@henrikmv
henrikmv marked this pull request as ready for review August 12, 2026 10:48
entityId: string,
) => queryClient.removeQueries([ReactQueryAppNamespace, 'changelog', entityType, entityId]);

export const removeEventChangelogQueries = (queryClient: QueryClient, eventId: string) =>

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.

Overall, this refactor initiative looks ok to me. But I was thinking about invalidating the cache when an event's status changes, and I think the following use cases are not covered at the moment:

  1. The Scenario: User can complete the enrollment and the active events feature
Image
  1. Completing events from the working lists
Image

Should we address these in preparation for DHIS2-21919, or leave them for later? 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.

Nice catch! I’ll do all the preparation for DHIS2-21919 now, which means including invalidating all the necessary caches.

Thanks!

@sonarqubecloud

Copy link
Copy Markdown

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