Skip to content

feat(data export): add default and per type id scheme options - #2286

Merged
Chisomchima merged 11 commits into
masterfrom
feat/export-id-scheme-options
Sep 17, 2026
Merged

Chisomchima merged 11 commits into
masterfrom
feat/export-id-scheme-options

Conversation

@Chisomchima

@Chisomchima Chisomchima commented Sep 3, 2026 •

Copy link
Copy Markdown
Member
Screen.Recording.2026-09-15.at.16.24.33.mov

implements https://dhis2.atlassian.net/browse/DHIS2-20434

@dhis2-bot

Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-2286--dhis2-import-export.netlify.app

@dhis2-bot
dhis2-bot temporarily deployed to netlify September 3, 2026 06:15 Inactive
@Chisomchima Chisomchima changed the title feat(data export): add "(Default)" and per-type ID scheme options feat(data export): add default and per-type ID scheme options Sep 7, 2026
@Chisomchima Chisomchima changed the title feat(data export): add default and per-type ID scheme options feat(data export): add default and per-type id scheme options Sep 7, 2026
@Chisomchima
Chisomchima force-pushed the feat/export-id-scheme-options branch from 980634f to d861312 Compare September 7, 2026 22:36
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 7, 2026 22:48 Inactive
Add a "(Default)" option to the ID scheme dropdowns. Selecting it omits
the corresponding *IdScheme parameter from the request so the server
applies its own default for each object type, rather than forcing an
explicit idScheme=UID.

Add explicit dropdowns on the data export page for the remaining per-type
ID scheme parameters that previously had no UI control: categoryIdScheme,
categoryOptionIdScheme, categoryOptionComboIdScheme, dataSetIdScheme and
attributeOptionComboIdScheme. These default to "(Default)" (param omitted)
so existing exports are unchanged.

Consolidate the three near-identical ElementSchemes ID scheme components
into a single IdSchemeSelect. Guard every *IdScheme param across the
export and import form helpers so an empty value drops the param.
- Add src/utils/idSchemeParams.js as the single source of truth for which
  ID scheme params each endpoint accepts and for dropping schemes left at
  "(Default)". All six export/import form helpers now use it instead of
  repeating the "empty value => omit param" logic in three different
  shapes.
- Export valuesToParams from the Data/Event/TEI export helpers and add
  unit tests covering explicit, "(Default)", and unsupported-param cases,
  plus tests for idSchemeParams and IdSchemeSelect.
- IdSchemeSelect: drop the exhaustive-deps suppression via a stable
  attributeTypes default, add an unmount guard, and replace the implicit
  reduce with a named intersect helper.
- Offer attribute-based schemes for Category / Category option / Data set
  (these object types support custom unique attributes); note why the
  combo types do not.
- Map the five new inputs in the Cypress nameToDataTest helper, delete two
  empty EventIdScheme placeholder files, regenerate i18n/en.pot.
@Chisomchima
Chisomchima force-pushed the feat/export-id-scheme-options branch from 73f5495 to 380f19a Compare September 7, 2026 22:52
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 7, 2026 22:53 Inactive
Extract the org-unit, assigned-user, program-filter and last-updated
sections into small pure helpers that each return a params object, and
build the query string by merging them. Behaviour is unchanged; this
brings valuesToParams under the SonarQube cognitive-complexity limit.
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 7, 2026 23:01 Inactive

@Sharmyn28 Sharmyn28 left a comment

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.

Thanks Chisom! 😄

@tomzemp tomzemp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it might be good to check with Jan B and product team that they are happy with how the options are presented

From a code perspective: I don't see the real advantage of all the individual IdScheme components, like it seems like this increases the maintenance burden to have individually defined components that are more or less identical? If we just do something like

    <IdSchemeSelect
        name='categoryIdScheme'
        label='input-category-id-scheme'
        dataTest={ i18n.t('Category ID scheme')}
        attributeTypes={['categoryAttribute']}
    />

we'd achieve the same as what we do with CategoryIdScheme without creating a separate file?

The pattern of having multiple separate components seems useful to me in cases where we reasonably expect the inputs to diverge and hence want to already plan for that, but since we don't have that expectation, it seems like reusing one generic component is less cluttered.

The recorded Cypress network-shim fixtures match requests by exact
path string, so the id-scheme params must stay ahead of paging/
totalPages to match; the complexity-refactor had moved them after,
breaking CI. Also guard idSchemeEntries against an unknown endpoint
and add coverage for it.

Also strip explanatory comments from the source/test files this
branch touched, per request.
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 15, 2026 07:00 Inactive
The previous commit stripped comments from every file this branch
touched, but only the comments this PR itself introduced were meant
to go - restore the comments that already existed in these files on
master (PAGE INFO markers, xhr/URL-generation notes, the TEI
org-unit/program-status explanations, etc). Comments on code that's
new to this PR (idSchemeParams.js, IdSchemeSelect.jsx, the `compact`
helper) stay removed.
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 15, 2026 07:06 Inactive
@Chisomchima Chisomchima changed the title feat(data export): add default and per-type id scheme options feat(data export): add default and per type id scheme options Sep 15, 2026
Category, category option, category option combo, data set, and
attribute option combo ID scheme fields were each a near-identical
wrapper component used in exactly one place (Data Export). Replace
them with direct IdSchemeSelect usage and centralise their shared
attribute-type arrays, removing duplicated boilerplate without
touching the fields (idScheme, dataElementIdScheme, orgUnitIdScheme)
that are genuinely reused across multiple pages.
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 15, 2026 15:22 Inactive
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 15, 2026 15:38 Inactive

@tomzemp tomzemp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

Maybe we should default to the default rather than UID now for data element/org unit/id scheme? (e.g. change to use '' here:

dataElementIdScheme: defaultDataElementIdSchemeOption,
orgUnitIdScheme: defaultOrgUnitIdSchemeOption,
idScheme: defaultIdSchemeOption,
)

Image

I also think you might have deleted some comments unrelated to your work? (Like in src/utils/helper.js?)

Chisomchima and others added 2 commits September 17, 2026 12:39
Jan wanted the empty option worded differently depending on what it means:
"(Default)" only on the fallback idScheme dropdown (defers to the server's
default), "(Undefined)" on the per-object-type ones (defers to the fallback
dropdown instead). He also asked for Data import to offer the same per-type
dropdowns as Data export. Following that up, Tom/Jan agreed the per-type and
fallback dropdowns should default to unset rather than an explicit UID, so
that deferring is the default behavior rather than something users have to
opt into.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Jan wanted the empty option worded differently depending on what it means:
"(Default)" only on the fallback idScheme dropdown (defers to the server's
default), "(Undefined)" on the per-object-type ones (defers to the fallback
dropdown instead). He also asked for Data import to offer the same per-type
dropdowns as Data export. Following that up, Tom/Jan agreed the per-type and
fallback dropdowns should default to unset rather than an explicit UID, so
that deferring is the default behavior rather than something users have to
opt into.
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 17, 2026 11:40 Inactive
…rt-export-app into feat/export-id-scheme-options
@sonarqubecloud

Copy link
Copy Markdown

@dhis2-bot
dhis2-bot temporarily deployed to netlify September 17, 2026 11:42 Inactive
@Chisomchima

Copy link
Copy Markdown
Member Author

Looks good!

Maybe we should default to the default rather than UID now for data element/org unit/id scheme? (e.g. change to use '' here:

dataElementIdScheme: defaultDataElementIdSchemeOption,
orgUnitIdScheme: defaultOrgUnitIdSchemeOption,
idScheme: defaultIdSchemeOption,

)
Image
I also think you might have deleted some comments unrelated to your work? (Like in src/utils/helper.js?)

Thanks for the suggestion! Checked with Jan and he agreed — data element/org unit/idScheme now default to "(Undefined)"/"(Default)" instead of explicit UID, matching the other 5 dropdowns. Pushed.

FYI, only the Id scheme has "Default" on the list now, the rest is "Undefined".

@Chisomchima
Chisomchima merged commit 206825e into master Sep 17, 2026
10 checks passed
@Chisomchima
Chisomchima deleted the feat/export-id-scheme-options branch September 17, 2026 14:02

This branch was previously deployed

1 inactive deployment
netlify — c87f33b5 Deployed Sep 17, 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.

4 participants