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

[Workspace] Updated permission settings appearance #7652

Conversation

Kapian1234
Copy link
Contributor

@Kapian1234 Kapian1234 commented Aug 8, 2024

Description

Changed permission control selector style.
Merged user section and group section, and added type switching.

Issues Resolved

Screenshot

Screenshot 2024-08-08 at 11 43 18 Screenshot 2024-08-15 at 14 34 18

Testing the changes

Changelog

  • feat: Update permission settings appearance

Check List

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

Copy link

codecov bot commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 89.13043% with 5 lines in your changes missing coverage. Please review.

Project coverage is 63.80%. Comparing base (b4ae264) to head (668bf70).
Report is 175 commits behind head on main.

Files with missing lines Patch % Lines
...kspace_form/workspace_permission_setting_input.tsx 84.00% 1 Missing and 3 partials ⚠️
...kspace_form/workspace_permission_setting_panel.tsx 95.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7652   +/-   ##
=======================================
  Coverage   63.79%   63.80%           
=======================================
  Files        3656     3656           
  Lines       81190    81205   +15     
  Branches    12945    12950    +5     
=======================================
+ Hits        51794    51809   +15     
+ Misses      26217    26215    -2     
- Partials     3179     3181    +2     
Flag Coverage Δ
Linux_1 30.08% <89.13%> (+0.02%) ⬆️
Linux_2 55.87% <ø> (ø)
Linux_3 40.42% <ø> (-0.01%) ⬇️
Linux_4 31.28% <ø> (ø)
Windows_1 30.09% <89.13%> (+0.02%) ⬆️
Windows_2 55.82% <ø> (ø)
Windows_3 40.42% <ø> (ø)
Windows_4 31.28% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ruanyl
ruanyl previously approved these changes Aug 16, 2024
@Kapian1234 Kapian1234 requested a review from SuZhou-Joe August 16, 2024 09:06
Comment on lines +156 to +167
const handleTypeChange = useCallback(
(options: Array<EuiSelectableOption<any>>) => {
for (const option of options) {
if (option.checked === 'on') {
onTypeChange(option.value, index);
setIsTypeListOpen(false);
return;
}
}
},
[index, onTypeChange]
);
Copy link
Member

Choose a reason for hiding this comment

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

We need a unit test for this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's added here, but it doesn't seem to work src/plugins/workspace/public/components/workspace_form/workspace_permission_setting_input.test.tsx:117

Copy link
Contributor

Choose a reason for hiding this comment

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

The root cause should be missing await for waitFor. The waitFor return a promise. The test case will be completed if doesn't await the promise object.


const handleDelete = useCallback(
(index: number) => {
onChange?.(permissionSettings.filter((_item, itemIndex) => itemIndex !== index));
handlePermissionSettingsChange?.(
permissionSettings.filter((_item, itemIndex) => itemIndex !== index)
Copy link
Member

Choose a reason for hiding this comment

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

All the event are missing test coverage, can we add those?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -124,12 +132,20 @@ describe('WorkspacePermissionSettingInput', () => {
});
});
it('should call onChange with new group type', () => {
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we move these offset mocks to the beforeEach / afterEach? I think we should clear it after test case complete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -112,3 +113,20 @@ describe('WorkspacePermissionSettingInput', () => {
expect(onDeleteMock).toHaveBeenCalledWith(0);
});
});

it('should call onTypeChange with types after types changed', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this test case inside describe section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry I didn't notice that

Signed-off-by: Kapian1234 <[email protected]>
…apian1234/OpenSearch-Dashboards into workspace_permission_setting_panel_dev

it('should call onTypeChange with types after types changed', () => {
const { renderResult, onTypeChangeMock } = setup({});
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should reset offset value after test case completed.

Copy link
Contributor Author

@Kapian1234 Kapian1234 Aug 20, 2024

Choose a reason for hiding this comment

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

Shall we use beforeEach and afterEach here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need put them in before / after if there only one test case use it.

Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Kapian1234 <[email protected]>
const permissionToggleListButton = renderResult
.getAllByTestId('comboBoxToggleListButton')
.filter((button) => button.closest('[data-test-subj="workspace-permissionModeOptions"]'))[0];
fireEvent.click(permissionToggleListButton);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we refactor to below code?

import {  within } from '@testing-library/react';



    const permissionToggleListButton = within(
      renderResult.getAllByTestId('workspace-permissionModeOptions')[1]
    ).getByTestId('comboBoxToggleListButton');
    fireEvent.click(permissionToggleListButton);

That look more clarify to me.

'offsetHeight'
);
const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth');
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we delete this Object.defineProperty?

Copy link
Contributor

@wanglam wanglam left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@SuZhou-Joe SuZhou-Joe left a comment

Choose a reason for hiding this comment

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

LGTM, good job!

@SuZhou-Joe SuZhou-Joe merged commit aed03fa into opensearch-project:main Aug 21, 2024
66 of 67 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 21, 2024
* Changed permission control style

Signed-off-by: Kapian1234 <[email protected]>

* Merged the group section and user section, and added type switching.

Signed-off-by: Kapian1234 <[email protected]>

* Added isDisabled for permission control

Signed-off-by: Kapian1234 <[email protected]>

* Modified styles and added descriptions for permission control

Signed-off-by: Kapian1234 <[email protected]>

* /

Signed-off-by: Kapian1234 <[email protected]>

* Modified tests

Signed-off-by: Kapian1234 <[email protected]>

* Changeset file for PR #7652 created/updated

* Modified tests

Signed-off-by: Kapian1234 <[email protected]>

* Modified tests

Signed-off-by: Kapian1234 <[email protected]>

* /

Signed-off-by: Kapian1234 <[email protected]>

* Modified tests

Signed-off-by: Kapian1234 <[email protected]>

* Remove the doc updates

Signed-off-by: Kapian1234 <[email protected]>

* Remove the doc updates

Signed-off-by: Kapian1234 <[email protected]>

* Resolve some issues

Signed-off-by: Kapian1234 <[email protected]>

* resolve some issues

Signed-off-by: Kapian1234 <[email protected]>

* Change type switch to popover style

Signed-off-by: Kapian1234 <[email protected]>

* Change type switch to popover style

Signed-off-by: Kapian1234 <[email protected]>

* Change type switch to popover style

Signed-off-by: Kapian1234 <[email protected]>

* Change type switch to popover style

Signed-off-by: Kapian1234 <[email protected]>

* Modify tests

Signed-off-by: Kapian1234 <[email protected]>

* Resolve some issues

Signed-off-by: Kapian1234 <[email protected]>

* Modify tests

Signed-off-by: Kapian1234 <[email protected]>

* Modify tests to increase coverage

Signed-off-by: Kapian1234 <[email protected]>

* Modify tests

Signed-off-by: Kapian1234 <[email protected]>

* Modify tests

Signed-off-by: Kapian1234 <[email protected]>

* Modify tests

Signed-off-by: Kapian1234 <[email protected]>

* Modify tests

Signed-off-by: Kapian1234 <[email protected]>

---------

Signed-off-by: Kapian1234 <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit aed03fa)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AMoo-Miki pushed a commit that referenced this pull request Aug 22, 2024
* Changed permission control style



* Merged the group section and user section, and added type switching.



* Added isDisabled for permission control



* Modified styles and added descriptions for permission control



* /



* Modified tests



* Changeset file for PR #7652 created/updated

* Modified tests



* Modified tests



* /



* Modified tests



* Remove the doc updates



* Remove the doc updates



* Resolve some issues



* resolve some issues



* Change type switch to popover style



* Change type switch to popover style



* Change type switch to popover style



* Change type switch to popover style



* Modify tests



* Resolve some issues



* Modify tests



* Modify tests to increase coverage



* Modify tests



* Modify tests



* Modify tests



* Modify tests



---------



(cherry picked from commit aed03fa)

Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
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.

5 participants