Skip to content

Conversation

@janhenrikoverland
Copy link
Collaborator

@janhenrikoverland janhenrikoverland commented Jan 27, 2026

Architecture

I decided to modify the existing components in @dhis2/analytics to communicate with the server and toggle on server version. Apps like Data Visualizer can still use PeriodDimension and release with min version 2.40 without problems.

For <=42 nothing has changed.

In 43+ the enabled PTs are fetched from the server. These are used to populate the fixed period types. For relative periods it's a bit more complicated. The following considerations have been made:

  • The "Financial year relative period start month" setting points to a FY period type. This PT must be enabled, otherwise hide FY period type. Settings app or the server might improve their handling and ensure valid combinations later.
  • For the above, extra mapping was needed as the server (unfortunately) stores e.g. "FINANCIAL_YEAR_OCTOBER" instead of matching its own period type "FinancialOct".
  • The corresponding settings for weekly and six-monthly are not implemented yet. So for now: if any weekly type is enable, show Weeks. If any six-monthly type is enabled, show Six-months.
  • The remaining relative PTs have respective fixed PTs, so show based on their enabled status.
  • The old "Hide*periods" settings are no longer regarded in the 43+ implementation
  • The setting "Default relative period for analysis" (e.g. "LAST_12_MONTHS") but could be of any PT, so we need to parse and extract the PT and ensure that it's enabled. Otherwise pick a period from the closest enabled PT.

Claude Code suggested a few improvements:

Data fetching fix

The original code used useDataQuery({ skip: true }) to conditionally skip queries on pre-v43 servers. This doesn't work — useDataQuery has no skip mechanism on the query
object, and useStaticInput freezes the first query reference. Replaced with a single combined query using { lazy: true } + useEffect, which is the established pattern in
this codebase (see OpenFileDialog, AboutAOUnit, etc.). This also reduces three network requests to one.

Period options filtering consolidated in PeriodTransfer

FixedPeriodFilter and RelativePeriodFilter were computing their own filtered period lists internally, duplicating logic already in PeriodTransfer. Now PeriodTransfer
always passes pre-filtered availableOptions to both filter components, making them pure presentation components. FixedPeriodSelect (the only other consumer of
FixedPeriodFilter) now computes availableOptions from its allowedPeriodTypes prop before passing them down.

Tab toggle bug fix

onIsRelativeClick was using the raw getRelativePeriodsOptionsById/getFixedPeriodsOptionsById helpers, bypassing the filtered options. On v43+ servers with restricted
period types, switching between relative/fixed tabs could show periods from disabled types.

Screenshots v42

No changes:

Screenshot from 2026-01-27 12-24-15 Screenshot from 2026-01-27 12-24-25

Screenshots v43

Respects the enabled types:

Screenshot from 2026-01-27 12-25-27 Screenshot from 2026-01-27 12-25-02 Screenshot from 2026-01-27 12-25-10

janhenrikoverland and others added 7 commits January 27, 2026 01:10
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
The test was failing because the useConfig mock was missing the serverVersion property that the component now requires for version detection.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Expand the period type mappings to include all 52 period types supported
by @dhis2/multi-calendar-dates library, including all 12 financial year
variants (FYJAN-FYDEC), weekly variants, quarterly variants, and
six-monthly variants. This ensures that when a period type like
FinancialSep is enabled on the server, it correctly appears in the
fixed periods dropdown.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 New issues
1 New Critical Issues (required ≤ 0)
2 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

2 participants