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

Feat disable duplicate user or group permission #242

Conversation

wanglam
Copy link
Collaborator

@wanglam wanglam commented Oct 25, 2023

Description

  1. Move permissions out of attributes parameter
  2. Disable duplicate permission for specific user or group

Issues Resolved

Screenshot

Testing the changes

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@wanglam wanglam marked this pull request as ready for review October 25, 2023 02:33
@wanglam wanglam force-pushed the feat-disable-duplicate-user-or-group-permission branch from d203dd4 to ab9465e Compare October 25, 2023 02:39
@codecov-commenter
Copy link

codecov-commenter commented Oct 25, 2023

Codecov Report

Merging #242 (ab9465e) into workspace (1ac7ec4) will increase coverage by 0.00%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           workspace     #242   +/-   ##
==========================================
  Coverage      66.21%   66.21%           
==========================================
  Files           3438     3438           
  Lines          66262    66269    +7     
  Branches       10691    10693    +2     
==========================================
+ Hits           43878    43883    +5     
- Misses         19703    19705    +2     
  Partials        2681     2681           
Flag Coverage Δ
Linux_1 30.84% <50.00%> (+<0.01%) ⬆️
Linux_2 55.41% <ø> (ø)
Linux_3 42.78% <ø> (+<0.01%) ⬆️
Linux_4 34.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...components/workspace_creator/workspace_creator.tsx 77.77% <100.00%> (+1.30%) ⬆️
src/plugins/workspace/public/workspace_client.ts 71.42% <ø> (ø)
...ic/components/workspace_creator/workspace_form.tsx 70.21% <33.33%> (-1.22%) ⬇️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

permissions: WorkspaceRoutePermissionItem[];
}
attributes: Omit<WorkspaceAttribute, 'id'>,
permissions: WorkspaceRoutePermissionItem[]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not in the scope, but should permissions be optional? Because user may not have permission control turned on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, the permissions could be optional.

combination.length === permissionModes.length &&
combination.every((mode) => permissionModes.includes(mode))
);
const isValidatePermissions = (permissions: Permissions) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we move convertToACL to workspace_client, and passing the raw permissions(type is WorkspaceRoutePermissionItem[]) to create/update, perhaps we don't need to convert the data here? It would be much easier to validate a flatten array of WorkspaceRoutePermissionItem[].

Not only make it easier to validate the permission mode combinations, but also make it easier to validate the user/group duplications here as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. The WorkspaceRoutePermissionItem[] in route level was only used in the front end page. I kept the ACL parameter in case of passing ACL to workspace client directly. From current implementation, the create or update method only be used in workspace routes. I think we can change to parameter type to WorkspaceRoutePermissionItem[].

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also can rename WorkspaceRoutePermissionItem to not include word Route so that it's more generic,

Signed-off-by: Lin Wang <wonglam@amazon.com>
@wanglam wanglam merged commit 1d679f8 into ruanyl:workspace Oct 26, 2023
20 of 21 checks passed
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.

3 participants