Skip to content

refactor: reorganise visualization module - #367

Draft
HendrikThePendric wants to merge 8 commits into
masterfrom
refactor/reorganise-visualization-module
Draft

HendrikThePendric wants to merge 8 commits into
masterfrom
refactor/reorganise-visualization-module

Conversation

@HendrikThePendric

@HendrikThePendric HendrikThePendric commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Implements N/A

Description

This does not need a thorough review since all this PR does is move some stuff around.

The main issue was that state.ts held six unrelated concerns in 684 lines. Each now lives in a file with a more specific name. I tried to stick to the general guideline that says "a file should be named for what it produces", but this didn't always work completely, so we now ended up withguards, normalize-legacy, ui-config, save, and current-vis (which now also has buildCurrentVisFromVisUiConfig from the store, since that produces a CurrentVisualization). state.ts keeps the comparison.

removeDimensionPropertiesBeforeSaving was moved to the dimension domain: it produces a DimensionArray and has callers in two concerns.


Quality checklist

  • Cypress and/or Jest tests added/updated N/A
  • Docs added
  • d2-ci dependency replaced N/A

ToDo


@dhis2-bot

Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-367.event-visualizer.netlify.dhis2.org

@dhis2-bot
dhis2-bot temporarily deployed to netlify September 3, 2026 10:42 Inactive
edoardo
edoardo previously approved these changes Sep 4, 2026
@HendrikThePendric
HendrikThePendric force-pushed the feat/unapplied-changes-DHIS2-22011 branch from 52c0035 to 92a36c5 Compare September 22, 2026 09:45
HendrikThePendric and others added 7 commits September 22, 2026 15:00
…2-22011]

Deciding whether there are unapplied changes needs to know which output types
the current config can produce, which until now only the action button hook
could work out. Pure move: the existing tests cover it unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…[DHIS2-22011]

Validity only asked whether the layout held more than one tracked entity type.
A layout holding none — only context-free dimensions such as Last updated on —
passed every check, so the button stayed enabled and clicking it threw.

Found while reusing this validity check for the unapplied changes indicator,
which has to know whether an output type can be produced at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…n [DHIS2-22011]

A legacy Event Report persists its value column as a dy/latitude/longitude
dimension. The app expresses that with the custom value fields instead and
holds no layout position for them, so they survived a load without ever being
rebuildable from visUiConfig — enough on its own to make a freshly loaded
visualization look edited.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
areVisualizationsEquivalent only had to answer "does the saved visualization
differ from the current one". Comparing the current visualization against the
one visUiConfig would produce needs the same notion of equivalence, so export
it and fold the per-field rules into one helper.

Fields the API returns richer than visUiConfig can rebuild now compare by id:
option sets and legend sets carry a name, a repetition carries the context the
backend derives from its dimension, and the custom value carries both a name
and an aggregation type.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…22011]

Editing the layout or the options changes visUiConfig, which does not reach
the visualization on screen until the user applies it. Nothing said so, which
left the canvas silently disagreeing with the panel next to it.

The indicator only appears when the user can act on it: it stays hidden when
no output type can be produced from the config at all, since every button that
would apply the change is disabled in that case.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The section described sibling DHIS2 apps' helpers, none of which exist in this
repo, so it pointed readers at symbols they could not find.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@HendrikThePendric
HendrikThePendric force-pushed the feat/unapplied-changes-DHIS2-22011 branch from 92a36c5 to 5f3f681 Compare September 22, 2026 13:07
@HendrikThePendric
HendrikThePendric force-pushed the refactor/reorganise-visualization-module branch from 5540ae7 to 60d66f3 Compare September 22, 2026 14:00
Some files had grown a bit out of control
@HendrikThePendric
HendrikThePendric force-pushed the refactor/reorganise-visualization-module branch from 60d66f3 to afe4bd7 Compare September 22, 2026 14:16
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 22, 2026 14:17 Inactive
@sonarqubecloud

Copy link
Copy Markdown

@HendrikThePendric
HendrikThePendric force-pushed the feat/unapplied-changes-DHIS2-22011 branch from 5f3f681 to 5d728ed Compare September 23, 2026 15:23
Base automatically changed from feat/unapplied-changes-DHIS2-22011 to master September 24, 2026 15:13
@HendrikThePendric
HendrikThePendric dismissed edoardo’s stale review September 24, 2026 15:13

The base branch was changed.

This branch was previously deployed

1 inactive deployment
netlify — afe4bd75 Deployed Sep 22, 2026 by dhis2-bot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants