-
Notifications
You must be signed in to change notification settings - Fork 43
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
🐛 Update archetype rbac scopes #1624
Conversation
Signed-off-by: ibolton336 <[email protected]>
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.
The approach looks good, just a comment about the style when building the items
array.
...(archetypeWriteAccess | ||
? [ | ||
{ | ||
title: t("actions.duplicate"), | ||
onClick: () => | ||
setArchetypeToDuplicate(archetype), | ||
}, | ||
] | ||
: []), |
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.
The alternate form would be to drop undefieneds and then .filter(Boolean)
at the end...
[
archetypeWriteAccess && {
title: ...
...
},
assessmentWriteAccess && { ... },
...
].filter(Boolean)
const token = keycloak.tokenParsed; | ||
const userScopes: string[] = token?.scope.split(" ") || [], | ||
archetypeWriteAccess = checkAccess(userScopes, archetypesWriteScopes), | ||
assessmentWriteAccess = checkAccess(userScopes, assessmentWriteScopes), | ||
reviewsWriteAccess = checkAccess(userScopes, reviewsWriteScopes); |
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 know this is what we have to work with right now, but it pains me just a bit.
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.
Approving because it works.
But the scope checking code is ugly and deserves to be refactored in the near future.
https://issues.redhat.com/browse/MTA-1893