-
Notifications
You must be signed in to change notification settings - Fork 367
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
upcoming: [M3-7613] - Grants and Permissions for Placement Groups #10257
Conversation
Coverage Report: ✅ |
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.
Nice job with pointing out the drawer can be reached by URL in the testing instructions.
Left some feedback in comments, and I also wanted to mention how I tested at least the read only linodes part with a couple updates to the mocks that allow us to mock add_linodes
as false
.
rest.get('*/profile', (req, res, ctx) => {
const profile = profileFactory.build({
restricted: true, // This is important! The grants endpoint is only called for restricted users!
user_type: 'default',
});
return res(ctx.json(profile));
}),
rest.get('*/profile/grants', (req, res, ctx) => {
return res(
ctx.json(grantsFactory.build({ global: { add_linodes: false }},))
);
}),
packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/components/LandingHeader/LandingHeaderProps.tsx
Outdated
Show resolved
Hide resolved
...cementGroups/PlacementGroupsDetail/PlacementGroupsLinodes/PlacementGroupsLinodesTableRow.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/PlacementGroups/PlacementGroupsUnassignModal.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx
Show resolved
Hide resolved
@jaalah-akamai would love to have your eyes on this initial permission PR to confirm the overall direction before I dive into a review. thx! |
packages/manager/src/features/PlacementGroups/PlacementGroupsLanding/PlacementGroupsLanding.tsx
Show resolved
Hide resolved
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.
Addressed feedback looks good. Couple more things:
As far as URLs, it looks like a user with read only access could still potentially navigate to the edit drawer and delete modal via URL with the placement group id, so these UIs would need disabled state too.
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.
@carrillo-erik please rebase at your earliest convenience so we can rely on serverHandler to test the PR, thx.
@@ -19,6 +19,7 @@ export interface LandingHeaderProps { | |||
buttonDataAttrs?: { [key: string]: boolean | string }; | |||
createButtonText?: string; | |||
disabledCreateButton?: boolean; | |||
disableEditButton?: boolean; |
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 should read disabledBreadcrumbEditButton
for clarity since Landing header has other CTAs
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.
Good call. The recent code push reflects this change.
@@ -146,7 +159,7 @@ export const PlacementGroupsCreateDrawer = ( | |||
autoFocus: true, | |||
}} | |||
aria-label="Label for the Placement Group" | |||
disabled={false} | |||
disabled={disabledCreateButton || false} |
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.
same here - the naming convention could lead to confusion.disabledCreateButton
implies only the button and disabling the form using this variable isn't optimal. The button can also be disabled for other reasons limits) so we could run into logic problems down the line.
How about renaming disabledCreateButton
with disablePlacementGroupCreation
(or similar) where it applies?
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.
Same as the other comment.
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.
Description 📝
This PR sets up the Grants and Permissions for users to be able to create, delete, and update Placement Groups. More specifically, write access to create a Placement Group will be dictated by the
add_linodes
grant. Access to assign/unassign an individual Linode to a Placement Group will be based on havingread_write
access to the specific Linode.Changes 🔄
useRestrictedGlobalGrantCheck
hook. Once it's determined if the user has theadd_linodes
grant, certain components will be hidden from the user or disabled to the user; and in other cases, we display components to convey a message to the user.useIsResourceRestricted
hook. This time, we are interested to know if a user hasread_write
access for specific Linodes in order to assign (add) them to a Placement Group.Preview 📷
How to test 🧪
Prerequisites
(How to setup test environment)
serverHandlers.ts
file on line 559 and line 574.Reproduction steps
How to test
section above. Kudos to @mjac0bs for this solution!isLinodeReadOnly
value in the files touched by this PR.useIsResourceRestricted
hook in the current state proved to be difficult since it would require having a testing account which we can set the grants and permissions, then log into that account while using the MSW. After the API hits thealpha
environment, this will be more thoroughly tested.isLinodeReadOnly
value on the Placement Groups landing page and then visitinghttp://localhost:3000/placement-groups/create
orhttp://localhost:3000/placement-groups/1/linodes
As an Author I have considered 🤔
Check all that apply