Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IA-3884: show groups version in dropdown #1939

Merged
merged 8 commits into from
Feb 5, 2025

Conversation

quang-le
Copy link
Member

@quang-le quang-le commented Jan 22, 2025

Follow up of #1933: use groups dropdown endpoint where indicated

Related JIRA tickets : IA-3880, IA-3884

Self proofreading checklist

  • Did I use eslint and black formatters
  • Is my code clear enough and well documented
  • Are my typescript files well typed
  • New translations have been added or updated if new strings have been introduced in the frontend
  • My migrations file are included
  • Are there enough tests
  • Documentation has been included (for new feature)

Doc

Comments in the code

Changes

  • Improve handling of anonymous users for /groups/dropdown endpoint
  • Modify CampaignScope, RoundScope and SubActivityScope naming to avoid react key errors in the front-end
  • Remove duplicate hooks for getting dropdowns
  • Remove (now) unnecessary mapping methods to convert groups to dropdown options

How to test

Test in the UI:

  • Filter in Completeness stats
  • Filter in Entities
  • Filter in Org Units
  • Select box in Org unit details, Info Tab
  • Filter in Org unit details children tab
  • Dropdowns in Org unit bulk update modal

Print screen / video

Screen.Recording.2025-01-22.at.18.07.55.mov
Screen.Recording.2025-01-22.at.18.03.42.mov
Screen.Recording.2025-01-22.at.18.07.55.mov

Notes

Includes hotfixes v1.251a and v1.251b

Follow the Conventional Commits specification

The merge message of a pull request must follow the Conventional Commits specification.

This convention helps to automatically generate release notes.

Use lowercase for consistency.

Example:

fix: empty instance pop up

Refs: IA-3665

Note that the Jira reference is preceded by a line break.

Both the line break and the Jira reference are entered in the Add an optional extended description… field.

bmonjoie and others added 8 commits January 20, 2025 13:38
When creating on-the-fly configuration to restrict OrgUnit Change Request creation,
the `created_at` and `updated_at` dates were not set. This resulted in the backend
sending `null` for those required field.

Those fields are now set to the current date and time to fix the issue in the mobile app.

IA-3878
- in change requests config
- in group sets table
- in most groups dropdowns
- this will prevent errors in the front end when using dropdowns
- Improve handling of anon users
- Keep only useGetGroupDropdown
- add default source version to its API call
- Remove unused useGetGroups
- Update useGetOrgUnitDetailData to use /groups/dropdown endpoint
- Update org unit forms to use dropdown API response
- remove unused utils
- remove unused TS type
- Correct error in SaveData TS type
Comment on lines -199 to -207
const groupsInputComponent = useMemo(() => {
return createGroupsInputComponent({
isFetchingGroups,
handleChange,
filters,
groups,
});
}, [filters, groups, handleChange, isFetchingGroups]);

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a hidden component. I took it out. It introduces some repetition, but is more legible I think, and avoids the unnecessary useMemo

Comment on lines -44 to -46
settings.row.original.groups.sort((a, b) =>
a.name > b.name ? 1 : b.name > a.name ? -1 : 0,
);
Copy link
Member Author

Choose a reason for hiding this comment

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

The linter was complaining about the nested ternary

Comment on lines +30 to +37
const groupsDataSourceQueryParams = originalOrgUnit?.source_id
? `?dataSource=${originalOrgUnit.source_id}`
: undefined;
const groupsQueryParams = isNewOrgunit
? '?defaultVersion=true'
: groupsDataSourceQueryParams;
const groupsApiUrl = '/api/groups/dropdown/';

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit of gymastic but:

  • strings don't need to be memoized
  • it allows me to pass just the params to the queryKey, so all group dropdown hooks have the same queryKey structure

@quang-le quang-le changed the title IA-3880: show groups version in dropdown IA-3884: show groups version in dropdown Jan 23, 2025
@quang-le quang-le added the release Should be released in production at next deploy label Feb 4, 2025
Copy link
Collaborator

@beygorghor beygorghor left a comment

Choose a reason for hiding this comment

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

Wow this is very cool ! even better, now we are sharing same cache across pages

@quang-le quang-le merged commit c77444d into main Feb 5, 2025
3 checks passed
@quang-le quang-le deleted the IA-3880_show_groups_version_in_dropdown branch February 5, 2025 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release Should be released in production at next deploy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants