Skip to content

Feature/changes user role user groups tabs#343

Merged
adrianq merged 6 commits intodevelopmentfrom
feature/changes_user_role_user_groups_tabs
Apr 27, 2026
Merged

Feature/changes user role user groups tabs#343
adrianq merged 6 commits intodevelopmentfrom
feature/changes_user_role_user_groups_tabs

Conversation

@xurxodev
Copy link
Copy Markdown
Contributor

📌 References

📝 Implementation

This branch consolidates several changes to the User Groups, User Roles and Dashboards tabs, both in behaviour and in App Settings.

1. Hide "Filter by Users" column in DHIS2 2.42 (3ba477e)

DHIS2 2.42 moved several user properties out of userCredentials. The "Filter by Users" column and related filter is now hidden on 2.42 instances where the filtering contract is incompatible,
avoiding broken queries.

2. Add Hide not applicable user roles filter (d57f97b)

User Roles tab now mirrors User Groups behaviour: after filtering users by the current org unit scope, roles with no remaining users are hidden in memory when "Hide not applicable user roles" is
enabled. Previously this only worked via API for User Groups.

3. Shared implementation between User Roles and User Groups (c2890be)

Refactor to remove duplicated filtering / org-unit scoping logic between the two tabs, so they now share the same code paths.

4. Load all users when org-unit scope is disabled in users filter (cb4c056)

When the "Show only users assigned to my organization unit and below" toggle is off, the "Filter by Users" dropdown now fetches all users via a new GetAllUsersSimpleUseCase, so the admin
can filter by users outside the current scope.

5. Configurable default value for boolean filters in App Settings (fef5a3d)

App Settings → Filter Permissions can now configure, per tab (User Groups / User Roles / Dashboards), not only Visible but also Default for the boolean filters:

  • filterUsersInOrgUnit (all three tabs)
  • filterHideNotApplicableUserGroups / filterHideNotApplicableUserRoles

The Show/Hide Filters section is renamed to Filters and uses a two-column Visible | Default layout. Visible and Default are independent — the admin can pre-configure the default state
even when the filter is hidden from non-admin users. Defaults apply to admin and non-admin alike.

On the data layer, appSettingsHelpers.mergeAndAddRuntimeProps was refactored into a single generic migrateRecord helper that back-fills missing keys and missing fields from defaults. This
replaces the previous migrateNewerActions and merge logic, and covers forward-compatible migration for both class-based (actionsAccess) and plain-object records (uiXxxActionsAccess). Unit
tests added in src/data/repositories/common/__tests__/appSettingsHelpers.spec.ts.

📹 Screenshots/Screen capture

App settings Before
Screenshot 2026-04-15 at 10 19 41

App settings After
Screenshot 2026-04-15 at 10 18 22

🔥 Testing

  1. Open the app as admin and go to Settings → Filter Permissions.
  2. Expand each accordion (User Groups, User Roles, Dashboards) and verify:
    • The section is titled Filters and shows two columns Visible | Default.
    • Boolean filters (Show only users assigned..., Hide not applicable...) have both switches.
    • Non-boolean rows (Filter by Users, Filter by Owners, exports) show only Visible, with under Default.
  3. Toggle Show only users assigned to my org unit and below Default = OFF in User Groups and save.
  4. Go to the User Groups tab and verify the filter opens already unchecked and the full user-group list (beyond the admin's org units) is displayed.
  5. Repeat step 3–4 for User Roles and Dashboards.
  6. Set filterUsersInOrgUnit.visible = false but defaultValue = false and save. Log in as a non-admin user and verify:
    • The toggle is not visible in the User Groups / User Roles / Dashboards tab.
    • The list loads without the org-unit scope applied (hidden default is honoured).
  7. With Default = ON, open the User Roles tab on a DHIS2 2.42 instance and verify:
    • Roles with no users from the current org unit scope are hidden when "Hide not applicable user roles" is active.
    • Disabling the org-unit toggle loads the full user list in the "Filter by Users" dropdown.
  8. Run yarn test — the new appSettingsHelpers.spec.ts suite (6 cases) must pass.
  9. Verify backward compatibility: on an instance with App Settings already stored without defaultValue, reload the app and confirm nothing breaks (missing defaultValue is back-filled to
    true by migrateRecord).

xurxodev added 4 commits April 9, 2026 11:42
To support hiding roles with empty users after excluding users outside org units,
load all roles once (like user groups) and apply filtering/sorting/pagination in-memory.
Add UI permission for the new filter and repository support to fetch all roles.
- Extract duplicate functions
- Refactor to use generic parameter
…tings

  Admins can now set the initial state of boolean filters (org unit scope,
  hide not applicable) for User Groups, User Roles and Dashboards tabs.
  The "Show/Hide Filters" section is renamed to "Filters" and uses a
  Visible/Default two-column layout. Visible and Default are independent,
  so the admin can pre-set the default even when the filter is hidden.

  Unifies the settings migration helpers into a single generic migrateRecord
  used both for actionsAccess and the three uiXxxActionsAccess records,
  preserving stored values while back-filling new fields/keys from defaults.

  Adds tests for mergeAndAddRuntimeProps covering legacy storage, full
  records and missing-key migration.
@xurxodev xurxodev marked this pull request as ready for review April 15, 2026 11:11
@adrianq adrianq changed the base branch from feature/support_2.42 to development April 17, 2026 08:19
@bundlemon
Copy link
Copy Markdown

bundlemon Bot commented Apr 17, 2026

BundleMon

No change in files bundle size

Groups updated (1)
Status Path Size Limits
Build Folder
./**/*
1.41MB (+948B +0.06%) +20%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@adrianq adrianq self-requested a review April 26, 2026 08:50
@adrianq
Copy link
Copy Markdown
Member

adrianq commented Apr 26, 2026

@xurxodev all good - just a minor fix I have implemented here 64627bd if you confirm it is OK with you I will merge the PR

@xurxodev
Copy link
Copy Markdown
Contributor Author

@adrianq Nice catch, I missed this one. The fix looks good to me.

@adrianq adrianq merged commit dc6541e into development Apr 27, 2026
6 checks passed
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