-
Notifications
You must be signed in to change notification settings - Fork 21
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
Dashboard permissions #2131
Dashboard permissions #2131
Conversation
Deployed to https://pr-2131.aam-digital.net/ |
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.
Seems to work well already 👍
Shall we also add the option similar to views, to assign "permittedUserRoles": ["custom_role"]
to any dashboard widget?
...shboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.ts
Outdated
Show resolved
Hide resolved
...shboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.ts
Outdated
Show resolved
Hide resolved
@@ -53,6 +53,7 @@ export class EntityPermissionGuard implements CanActivate { | |||
path = path.replace(/^\//, ""); | |||
|
|||
function isPathMatch(genericPath: string, path: string) { | |||
// TODO this does not seem to work with children routes (admin module) |
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.
yes, I was a bit lazy implementing this ... 😅
I think the logic could actually be shared between all guards, so we can make the code from UserRoleGuard reusable:
private getRouteConfig(path: string): ViewConfig { |
(side note: router.config already contains all the data from config, so parsing the config there is actually unnecessary)
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 am not sure what you mean here. What is the shared logic? And also regarding the router.config
I am not fully following. Do you want to extend it here if you have a improvement in mind?
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.
generalized the code. Please review my commit :-)
# Conflicts: # src/app/core/permissions/permission-guard/entity-permission.guard.ts # src/app/core/ui/navigation/navigation/navigation.component.spec.ts # src/app/core/ui/navigation/navigation/navigation.component.ts
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.
Really nice generalizations and great cleanup of the interfaces! 😃
@TheSlimvReal , please review my refactoring of the guards that is part of this PR as well, before merging this.
} | ||
|
||
/** | ||
* Extract the relevant route from Router, to get a merged route that contains the full trail of `permittedRoles` |
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.
what do you mean by "full trail of permittedRoles
"?
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 includes the "permittedRoles" from parent routes of nested routing. Not perfect merge of route data, however - for more complex use cases this might potentially break, I think.
🎉 This PR is included in version 3.28.0-master.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 3.28.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
closes: #2122, closes #1552