fix: hide remove role button for users without permissions#142
Conversation
|
Thanks for the pull request, @jacobo-dominguez-wgu! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
f5ad084 to
383e62c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #142 +/- ##
==========================================
+ Coverage 97.34% 97.36% +0.02%
==========================================
Files 89 89
Lines 2106 2129 +23
Branches 457 501 +44
==========================================
+ Hits 2050 2073 +23
Misses 53 53
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
383e62c to
3b8d2d4
Compare
3b8d2d4 to
0cb0cac
Compare
| action, | ||
| scope, | ||
| }; | ||
| const { data: hasPermission, isLoading } = useValidateUserPermissions([permission]); |
There was a problem hiding this comment.
This works, but doing it item-by-item is not very efficient.
Do you see anyway we could do it in bulk? like using useValidateUserPermissions on a parent component that has knowledge of all the items currently displayed on the table? useValidateUserPermissions supports querying permissions in bulk, this results in a single request instead of one per item.
There was a problem hiding this comment.
Sure, moved to a parent component to create a bulk request.
0cb0cac to
1334afd
Compare
| const deletePermissions = useMemo(() => { | ||
| const uniqueScopes = [...new Set(userAssignments.map(assignment => assignment.scope))]; | ||
| const permissions = uniqueScopes.map(scope => { | ||
| const action = scope.startsWith('lib') ? CONTENT_LIBRARY_PERMISSIONS.MANAGE_LIBRARY_TEAM : CONTENT_COURSE_PERMISSIONS.MANAGE_COURSE_TEAM; |
There was a problem hiding this comment.
Let's extract this into a dedicated function, so we can easily extend it when more scopes are added.
rodmgwgu
left a comment
There was a problem hiding this comment.
Tested and works great!, just added a nit comment, thanks!
1334afd to
df73f14
Compare
Added the missing tooltip and fixed the issue on wrong delete button disabled when removing filters, returning to previous table page or after getting back from role assignation wizard. @rodmgwgu Could you check again? |
bea844b to
a256525
Compare
rodmgwgu
left a comment
There was a problem hiding this comment.
Tested and everything is working great now, thanks!
Description
Adding permission check for team management
manage_library_teamormanage_course_teamto disable or enable delete role button.Also added query invalidation for user with all the query settings when a role is removed.
UPDATE:
It closes #141
How to test it
Test 1
Test 2