Skip to content
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

service scoping on the client #9185

Merged
merged 4 commits into from Nov 2, 2023
Merged

Conversation

aditya-mitra
Copy link
Collaborator

@aditya-mitra aditya-mitra commented Oct 31, 2023

Summary

🤖 Generated by Copilot at 73ca242

Refactored the codebase to use the userHasAccess function and the useUserHasAccessHook hook for checking user permissions based on scopes. This improved the code consistency, flexibility, and readability across various components and files, such as ProjectTable.tsx, UserPermissionDrawer.tsx, ProfileMenu.tsx, ProjectsPage.tsx, and SettingMenu.tsx. Removed unused or redundant code, such as userIsAdmin and hasProjectWriteAccess.

References

refs #9161

Explanation

🤖 Generated by Copilot at 73ca242

  • Refactored the code to use useUserHasAccessHook and userHasAccess functions to check user permissions based on scopes instead of hard-coded admin roles (link, link, link, link)
  • Replaced the variable isAdmin with hasProjectWritePermission in ProjectTable.tsx, using the scope projects:write for project-related actions such as update, push, invalidate, view, and delete (link, link, link, link, link, link, link, link)
  • Changed the variable selfUserPermission to use userHasAccess with the scope projects:write instead of admin:admin in UserPermissionDrawer.tsx (link)
  • Removed unused imports and variables from MediaIconsBox/index.tsx (link, link)
  • Changed the variable hasAdminAccess to use useUserHasAccessHook with the scope admin:admin in ProfileMenu.tsx (link)
  • Changed the variables hasAdminAccess and hasEditorAccess to use userHasAccess with the scopes admin:admin and editor:write in SettingMenu.tsx (link)
  • Changed the functions useUserHasAccessHook and userHasAccess to return only the result of checking for the given scope, without checking for admin:admin as well, in userHasAccess.ts (link, link)
  • Removed the unused function userIsAdmin from userHasAccess.ts (link)
  • Replaced the variable isAdmin with hasWriteAccess in ProjectsPage.tsx, using the scope editor:write for editor-related actions such as download, link, unlink, pull, and delete projects (link, link, link, link, link, link)

🤖 Generated by Copilot at 73ca242

userHasAccess
checks scopes for permissions
refactoring code

QA Steps

List any additional steps required to QA the changes of this PR, as well as any supplemental images or videos.

Checklist

  • If this PR is still a WIP, convert to a draft
  • When this PR is ready, mark it as "Ready for review"
  • ensure all checks pass
  • Changes have been manually QA'd
  • Changes reviewed by at least 2 approved reviewers

aditya-mitra and others added 3 commits November 2, 2023 14:03
Reverted studio project page hasWriteAccess to require admin:admin.
We want admins to have full control of projects, but not people with just
editor:write; editor:write just means you can use the editor at all.
@barankyle barankyle force-pushed the refactor/client/service-scoping branch from 1064057 to 74c607d Compare November 2, 2023 21:03
@barankyle barankyle added this pull request to the merge queue Nov 2, 2023
Merged via the queue into dev with commit 922a2de Nov 2, 2023
8 checks passed
@barankyle barankyle deleted the refactor/client/service-scoping branch November 2, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants