-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix(current-user): allow custom fields in getUserGroups (DHIS2-10625) #280
Conversation
This allows to override fields=:all to reduce the response size. One example is the Interpretations component, where only the group ids are actually needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing things this way doesn't introduce breaking changes, so that's a good thing. However, this does obviously mean that everywhere in our code base we will have to start adding a fields arg to the call to getCurrentUser
, because we should assume that getting all the users for a number of userGroups is going to cause a performance issue.
Perhaps we should include !users
in the default fields filter?
(I'm just leaving a neutral review, because I'm not sure what would be best here)
I don't understand why the support for optional params means we have to start to add the fields arg to the It looks like everything will work the same as it does today if |
Object.assign({ paging: false }, listOptions, { | ||
filter: [`id:in:[${userGroupIds.join(',')}]`], | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the intention is to allow overwriting the filter
property, then the listOptions
should be the last argument in the assign
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I used the same approach already in place for getOrganisationUnits
.
I don't think the filter
should be overridden, these methods are called like d2.currentUser.getUserGroups()
which implies the groups returned are the ones where the current user belongs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you make a good point, but we probably need a slightly more nuanced solution:
{
paging: false,
...listOptions,
filter: [
...listOptions.filter,
`id:in:[${userGroupIds.join(',')}]`,
]
}
My point: the part where we filter the userGroups on the user's userGroups should not be overwritten.
Note: when I wrote the above, Edoardo's comment was not visible yet.
My approach here is to not introduce any breaking changes, as I don't know where and how these methods on
That would be a breaking change. |
BTW, I just came to realise that for the specific problem of the interpretations panel, the group ids required are already in
I will update the Interpretation component and replace |
Yeah, this was also why I didn't approve or request changes, I'm simply not sure what is best here.... Obviously not introducing breaking changes is a good thing. But in this case that actually means that everywhere we use this method without any |
Current user group ids are already available from the /me response. Add a method for accessing them directly without making any api request. In some cases the ids are all is needed (ie. Interpretations component). Related to DHIS2-10625.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good solution for now
## [31.9.1](v31.9.0...v31.9.1) (2021-03-09) ### Bug Fixes * **current-user:** add getUserGroupIds, allow custom fields in getUserGroups (DHIS2-10625) ([#280](#280)) ([d3e84a6](d3e84a6))
🎉 This PR is included in version 31.9.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Improvement proposal for fixing DHIS2-10625.
This allows to override
fields=:all
to reduce the response size.One example is the Interpretations component, where only the group ids
are actually needed.
See dhis2/d2-ui#685.