-
Notifications
You must be signed in to change notification settings - Fork 916
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
Merged
SuZhou-Joe
merged 36 commits into
opensearch-project:main
from
Kapian1234:workspace_permission_setting_panel_dev
Aug 21, 2024
Merged
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
14af74b
Changed permission control style
Kapian1234 e28f4a9
Merged the group section and user section, and added type switching.
Kapian1234 3d860e2
Added isDisabled for permission control
Kapian1234 4b7a368
Modified styles and added descriptions for permission control
Kapian1234 2bf47e1
/
Kapian1234 272b57f
Modified tests
Kapian1234 afb5a25
Changeset file for PR #7652 created/updated
opensearch-changeset-bot[bot] 97505a9
Modified tests
Kapian1234 3b94759
Merge branch 'workspace_permission_setting_panel_dev' of github.com:K…
Kapian1234 3fe0e7b
Modified tests
Kapian1234 6b98eeb
Merge branch 'main' into workspace_permission_setting_panel_dev
Kapian1234 7c19205
Merge branch 'main' into workspace_permission_setting_panel_dev
Kapian1234 31a87ee
/
Kapian1234 55d8213
Modified tests
Kapian1234 ac75a01
Remove the doc updates
Kapian1234 c136b48
Remove the doc updates
Kapian1234 7d33f1b
Resolve some issues
Kapian1234 b0b1b85
resolve some issues
Kapian1234 17ec17f
Change type switch to popover style
Kapian1234 432c5cd
Change type switch to popover style
Kapian1234 b9906d5
Merge branch 'workspace_permission_setting_panel_dev' of github.com:K…
Kapian1234 da3996d
Change type switch to popover style
Kapian1234 ed7c13a
Change type switch to popover style
Kapian1234 040b5e1
Modify tests
Kapian1234 55e9f02
Resolve some issues
Kapian1234 6dbcbea
Resolve some conflicts
Kapian1234 a0b4243
Modify tests
Kapian1234 3f6247c
Merge branch 'main' of https://github.com/opensearch-project/OpenSear…
Kapian1234 7a535e3
Modify tests to increase coverage
Kapian1234 9292fe7
Merge branch 'main' into workspace_permission_setting_panel_dev
Kapian1234 4651d44
Modify tests
Kapian1234 a0c8f94
Merge branch 'workspace_permission_setting_panel_dev' of github.com:K…
Kapian1234 d58a9ca
Modify tests
Kapian1234 d266ca8
Modify tests
Kapian1234 ed8bff2
Modify tests
Kapian1234 668bf70
Merge branch 'main' into workspace_permission_setting_panel_dev
Kapian1234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- Update permission settings appearance ([#7652](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7652)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ const setup = (options?: Partial<WorkspacePermissionSettingInputProps>) => { | |
const onGroupOrUserIdChangeMock = jest.fn(); | ||
const onPermissionModesChangeMock = jest.fn(); | ||
const onDeleteMock = jest.fn(); | ||
const onTypeChangeMock = jest.fn(); | ||
const renderResult = render( | ||
<WorkspacePermissionSettingInput | ||
index={0} | ||
|
@@ -24,6 +25,7 @@ const setup = (options?: Partial<WorkspacePermissionSettingInputProps>) => { | |
onGroupOrUserIdChange={onGroupOrUserIdChangeMock} | ||
onPermissionModesChange={onPermissionModesChangeMock} | ||
onDelete={onDeleteMock} | ||
onTypeChange={onTypeChangeMock} | ||
{...options} | ||
/> | ||
); | ||
|
@@ -32,10 +34,45 @@ const setup = (options?: Partial<WorkspacePermissionSettingInputProps>) => { | |
onGroupOrUserIdChangeMock, | ||
onPermissionModesChangeMock, | ||
onDeleteMock, | ||
onTypeChangeMock, | ||
}; | ||
}; | ||
|
||
describe('WorkspacePermissionSettingInput', () => { | ||
const originalOffsetHeight = Object.getOwnPropertyDescriptor( | ||
HTMLElement.prototype, | ||
'offsetHeight' | ||
); | ||
const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth'); | ||
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { | ||
configurable: true, | ||
value: 600, | ||
}); | ||
|
||
beforeEach(() => { | ||
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { | ||
configurable: true, | ||
value: 600, | ||
}); | ||
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', { | ||
configurable: true, | ||
value: 600, | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
Object.defineProperty( | ||
HTMLElement.prototype, | ||
'offsetHeight', | ||
originalOffsetHeight as PropertyDescriptor | ||
); | ||
Object.defineProperty( | ||
HTMLElement.prototype, | ||
'offsetWidth', | ||
originalOffsetWidth as PropertyDescriptor | ||
); | ||
}); | ||
|
||
it('should render consistent user id and permission modes', () => { | ||
const { renderResult } = setup({ | ||
userId: 'foo', | ||
|
@@ -44,9 +81,6 @@ describe('WorkspacePermissionSettingInput', () => { | |
|
||
expect(renderResult.getByText('foo')).toBeInTheDocument(); | ||
expect(renderResult.getByText('Read')).toBeInTheDocument(); | ||
expect( | ||
renderResult.getByText('Read').closest('.euiButtonGroupButton-isSelected') | ||
).toBeInTheDocument(); | ||
}); | ||
it('should render consistent group id and permission modes', () => { | ||
const { renderResult } = setup({ | ||
|
@@ -57,19 +91,16 @@ describe('WorkspacePermissionSettingInput', () => { | |
|
||
expect(renderResult.getByText('bar')).toBeInTheDocument(); | ||
expect(renderResult.getByText('Read & Write')).toBeInTheDocument(); | ||
expect( | ||
renderResult.getByText('Read & Write').closest('.euiButtonGroupButton-isSelected') | ||
).toBeInTheDocument(); | ||
}); | ||
it('should call onGroupOrUserIdChange with user id', () => { | ||
const { renderResult, onGroupOrUserIdChangeMock } = setup(); | ||
|
||
expect(onGroupOrUserIdChangeMock).not.toHaveBeenCalled(); | ||
fireEvent.click(renderResult.getByText('Select a user')); | ||
fireEvent.input(renderResult.getByTestId('comboBoxSearchInput'), { | ||
fireEvent.input(renderResult.getAllByTestId('comboBoxSearchInput')[0], { | ||
target: { value: 'user1' }, | ||
}); | ||
fireEvent.blur(renderResult.getByTestId('comboBoxSearchInput')); | ||
fireEvent.blur(renderResult.getAllByTestId('comboBoxSearchInput')[0]); | ||
expect(onGroupOrUserIdChangeMock).toHaveBeenCalledWith({ type: 'user', userId: 'user1' }, 0); | ||
}); | ||
it('should call onGroupOrUserIdChange with group', () => { | ||
|
@@ -79,10 +110,10 @@ describe('WorkspacePermissionSettingInput', () => { | |
|
||
expect(onGroupOrUserIdChangeMock).not.toHaveBeenCalled(); | ||
fireEvent.click(renderResult.getByText('Select a user group')); | ||
fireEvent.input(renderResult.getByTestId('comboBoxSearchInput'), { | ||
fireEvent.input(renderResult.getAllByTestId('comboBoxSearchInput')[0], { | ||
target: { value: 'group' }, | ||
}); | ||
fireEvent.blur(renderResult.getByTestId('comboBoxSearchInput')); | ||
fireEvent.blur(renderResult.getAllByTestId('comboBoxSearchInput')[0]); | ||
expect(onGroupOrUserIdChangeMock).toHaveBeenCalledWith({ type: 'group', group: 'group' }, 0); | ||
}); | ||
|
||
|
@@ -100,6 +131,10 @@ describe('WorkspacePermissionSettingInput', () => { | |
const { renderResult, onPermissionModesChangeMock } = setup({}); | ||
|
||
expect(onPermissionModesChangeMock).not.toHaveBeenCalled(); | ||
const permissionToggleListButton = renderResult | ||
.getAllByTestId('comboBoxToggleListButton') | ||
.filter((button) => button.closest('[data-test-subj="workspace-permissionModeOptions"]'))[0]; | ||
fireEvent.click(permissionToggleListButton); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
fireEvent.click(renderResult.getByText('Owner')); | ||
expect(onPermissionModesChangeMock).toHaveBeenCalledWith(['library_write', 'write'], 0); | ||
}); | ||
|
@@ -111,4 +146,13 @@ describe('WorkspacePermissionSettingInput', () => { | |
fireEvent.click(renderResult.getByLabelText('Delete permission setting')); | ||
expect(onDeleteMock).toHaveBeenCalledWith(0); | ||
}); | ||
|
||
it('should call onTypeChange with types after types changed', () => { | ||
const { renderResult, onTypeChangeMock } = setup({}); | ||
expect(onTypeChangeMock).not.toHaveBeenCalled(); | ||
|
||
fireEvent.click(renderResult.getByTestId('workspace-typeOptions')); | ||
fireEvent.click(renderResult.getByText('Group')); | ||
expect(onTypeChangeMock).toHaveBeenCalledWith('group', 0); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shall we delete this
Object.defineProperty
?