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: update workspace settings page UI #237

Closed
wants to merge 22 commits into from
Closed

feat: update workspace settings page UI #237

wants to merge 22 commits into from

Conversation

yuye-aws
Copy link
Collaborator

@yuye-aws yuye-aws commented Oct 19, 2023

Description

Update the UI for workspace update page.

Issues Resolved

Screenshot

image

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

@yuye-aws yuye-aws marked this pull request as draft October 19, 2023 07:21
@yuye-aws yuye-aws marked this pull request as ready for review October 19, 2023 07:22
@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2023

Codecov Report

Merging #237 (00502b9) into workspace (dc240eb) will decrease coverage by 5.85%.
The diff coverage is n/a.

@@              Coverage Diff              @@
##           workspace     #237      +/-   ##
=============================================
- Coverage      66.24%   60.40%   -5.85%     
=============================================
  Files           3438     2162    -1276     
  Lines          66264    42118   -24146     
  Branches       10694     7731    -2963     
=============================================
- Hits           43899    25440   -18459     
+ Misses         19757    14988    -4769     
+ Partials        2608     1690     -918     
Flag Coverage Δ
Linux_1 ?
Linux_2 55.42% <ø> (ø)
Linux_3 42.78% <ø> (+<0.01%) ⬆️
Linux_4 ?

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

see 1579 files with indirect coverage changes

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

@yuye-aws yuye-aws changed the title feat: update create workspace page UI and implement unit tests feat: update workspace settings page UI Oct 19, 2023
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
}
>;

export type UserOrGroupPermissionEditingData = Array<
Copy link
Owner

Choose a reason for hiding this comment

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

I'd rename it to PermissionFieldData, that becomes

export type PermissionFieldData = {
  id?: string; 
  modes?: WorkspacePermissionMode[]
}

And in getUserAndGroupPermissions function, I will do

  const userPermissions: PermissionFieldData[] = [];
  const groupPermissions: PermissionFieldData[] = [];

Copy link
Collaborator Author

@yuye-aws yuye-aws Oct 27, 2023

Choose a reason for hiding this comment

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

How about declaring both variables in PermissionFieldData and create a new type for editing permission data:
type PermissionEditingData = Array<Partial<PermissionFieldData>>;

return [userPermissions, groupPermissions];
};

const getUnsavedUserOrGroupPermissionChangesCount = (
Copy link
Owner

Choose a reason for hiding this comment

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

I'd rename getUnsavedPermissionsCount

Copy link
Owner

Choose a reason for hiding this comment

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

I will simplify it in this way:

Convert the original form data: initialFormData.permissions which type is UserPermissionSetting to a data structure:

Map<string, string>

The key is ${type}/${userId} or ${type}/${groupName}, for example:

user key: "user/u123"
group key: "group/g123"

The value is a merge of modes: modes.join('/'), for example read/library_read

Then I can simply iterate currentFormData.groupPermissions and currentFormData.userPermissions to find those changed/added/deleted

Copy link
Collaborator Author

@yuye-aws yuye-aws Oct 27, 2023

Choose a reason for hiding this comment

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

Thanks, I will implement your idea. I just have two thoughts:

  1. Since I treat user permissions and group permissions separately, the key for the map only needs the id.
  2. Given that read/library_read and library_read/read should be considered equal, I will use getPermissionModeId as the value for the map.

Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
@yuye-aws yuye-aws requested review from wanglam and ruanyl October 30, 2023 03:49
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
@yuye-aws yuye-aws closed this Jan 3, 2024
@yuye-aws yuye-aws deleted the update-settings branch January 3, 2024 09:25
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.

4 participants