-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Frontend user roles integration #2207
Conversation
} | ||
|
||
// ORGANIZATION-LEVEL | ||
export function useEditOrganizationAccess(id: number) { |
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.
Instead of defining these based on the action type, could they be defined based on the access level?
We shouldn't need many in that scenario:
export function isOrgManager(id: number) {
const authDetails = CoreModules.useAppSelector((state) => state.login.authDetails);
return (
authDetails?.role === user_roles.ADMIN || (authDetails?.orgs_managed && authDetails?.orgs_managed?.includes(id))
);
}
isProjectManager
isFieldManager
isAdmin
// PROJECT-LEVEL | ||
export function useCreateProjectAccess() { | ||
const authDetails = CoreModules.useAppSelector((state) => state.login.authDetails); | ||
return authDetails?.role === user_roles.ADMIN || !!authDetails?.orgs_managed; |
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.
This is good for orgs_managed: null
π
If for some reason the backend response changed to be orgs_managed: []
this would evaluate true, but the next check for the specific org id should still prevent access.
@spwoodcock please have a look! Updated according to your suggestion. |
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 good to me!
Useful reference: https://docs.google.com/spreadsheets/d/1crWztvXvuewE8Zv-qxbv0t_-eYHUqSlrJQgeto8kmf4
β¦ages an organization
β¦ is org admin of only one organization
β¦sociated with on organization list select
What type of PR is this? (check all applicable)
Related Issue
Describe this PR
Screenshots
N/A