-
Notifications
You must be signed in to change notification settings - Fork 0
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 remove management permission mode in acl permission #195
Feat remove management permission mode in acl permission #195
Conversation
…on mode usage Signed-off-by: Lin Wang <wonglam@amazon.com>
Codecov Report
@@ Coverage Diff @@
## workspace #195 +/- ##
=============================================
+ Coverage 66.09% 66.12% +0.02%
=============================================
Files 3420 3420
Lines 65752 65753 +1
Branches 10589 10590 +1
=============================================
+ Hits 43461 43480 +19
+ Misses 19650 19633 -17
+ Partials 2641 2640 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -28,42 +28,55 @@ export type WorkspacePermissionSetting = ( | |||
modes: Array< | |||
| WorkspacePermissionMode.LibraryRead | |||
| WorkspacePermissionMode.LibraryWrite | |||
| WorkspacePermissionMode.Management |
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.
Should WorkspacePermissionSetting
just be
export type WorkspacePermissionSetting =
| { type: 'user'; userId: string; modes: Array<WorkspacePermissionMode> }
| { type: 'group'; group: string; modes: Array<WorkspacePermissionMode> };
@@ -227,63 +239,89 @@ export const WorkspacePermissionSettingPanel = ({ | |||
onChange, | |||
firstRowDeletable, | |||
}: WorkspacePermissionSettingPanelProps) => { | |||
const valueRef = useRef(value); | |||
valueRef.current = value; | |||
const transferredValue = useMemo(() => { |
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.
You mean transformed
?
for (let i = 0; i < value.length; i++) { | ||
const valueItem = value[i]; | ||
if ( | ||
!valueItem.modes || | ||
!valueItem.type || | ||
(valueItem.type === 'user' && !valueItem.userId) || | ||
(valueItem.type === 'group' && !valueItem.group) | ||
) { | ||
result.push(valueItem); | ||
continue; | ||
} | ||
for (const key in optionIdToWorkspacePermissionModesMap) { | ||
if (!Object.prototype.hasOwnProperty.call(optionIdToWorkspacePermissionModesMap, key)) { | ||
continue; | ||
} | ||
const modesForCertainPermissionId = optionIdToWorkspacePermissionModesMap[key]; | ||
if (modesForCertainPermissionId.every((mode) => valueItem.modes?.includes(mode))) { | ||
result.push({ ...valueItem, modes: modesForCertainPermissionId }); | ||
} | ||
} | ||
} |
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.
Could you help me to understand this piece of code? from L247-L267
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.
The passed permission records were based user & group level. One user or group will contains multi permission modes. Since each permission mode in the UI was single select, we can't display multi permission option in one row. So we need to separate these permission modes into multi rows. Will add some annotation to clarify the logic.
@@ -33,7 +33,8 @@ type WorkspaceRoutePermissionItem = { | |||
modes: Array< | |||
| WorkspacePermissionMode.LibraryRead | |||
| WorkspacePermissionMode.LibraryWrite | |||
| WorkspacePermissionMode.Management | |||
| WorkspacePermissionMode.Read |
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.
Should it be like this?
modes: WorkspacePermissionMode[]
@@ -286,8 +280,8 @@ export class WorkspaceSavedObjectsClientWrapper { | |||
!(await this.validateWorkspacesAndSavedObjectsPermissions( | |||
await wrapperOptions.client.get(type, options.id), |
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 have a question on this line, it's not related to this PR. What if options.id
doesn't exist?
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 think it will throw an error about document doesn't exists.
@@ -383,7 +357,12 @@ export class WorkspaceSavedObjectsClientWrapper { | |||
perPage: 999, | |||
ACLSearchParams: { | |||
principals, | |||
permissionModes: workspaceInnerPermissionModes, | |||
permissionModes: options.ACLSearchParams.permissionModes | |||
? intersection(options.ACLSearchParams.permissionModes, [ |
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.
Would be nice to leave a comment on why intersection
is needed
Signed-off-by: Lin Wang <wonglam@amazon.com>
* feat: remove management permission mode and clearify library permission mode usage Signed-off-by: Lin Wang <wonglam@amazon.com> * address PR comments and add annotations Signed-off-by: Lin Wang <wonglam@amazon.com> --------- Signed-off-by: Lin Wang <wonglam@amazon.com> (cherry picked from commit 29ccc20) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
1.Remove management permission mode
2.Update workspaces permission check use LibraryRead / LibraryWrite
3.Update ACL permission check use Read / Write
4.Change workspace permission form use below options
- Read: LibraryRead + Read
- Read+Write: LibraryWrite + Write
- Admin: LibraryWrite + Write
Issues Resolved
Screenshot
Testing the changes
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr