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]feat: add collaborator table to workspace detail page #8501

Merged
merged 8 commits into from
Oct 9, 2024

Conversation

raintygao
Copy link
Contributor

@raintygao raintygao commented Oct 5, 2024

Description

add collaborator table to workspace detail page

Screenshot

image
image
image
image
image

Testing the changes

Go to workspace detail page, then test the related changes.

Changelog

  • feat: add collaborator table to workspace detail page

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

opensearch-changeset-bot bot added a commit to raintygao/OpenSearch-Dashboards that referenced this pull request Oct 5, 2024
@raintygao raintygao changed the title [Workspace]feat: add collaborator table to workspace list page [Workspace]feat: add collaborator table to workspace detail page Oct 5, 2024
opensearch-changeset-bot bot added a commit to raintygao/OpenSearch-Dashboards that referenced this pull request Oct 5, 2024
Copy link

codecov bot commented Oct 6, 2024

Codecov Report

Attention: Patch coverage is 69.09091% with 34 lines in your changes missing coverage. Please review.

Project coverage is 60.93%. Comparing base (61eedf7) to head (fd17483).
Report is 93 commits behind head on main.

Files with missing lines Patch % Lines
...ts/workspace_form/workspace_collaborator_table.tsx 62.33% 24 Missing and 5 partials ⚠️
...ic/components/workspace_form/use_workspace_form.ts 50.00% 3 Missing ⚠️
...ponents/workspace_form/add_collaborator_button.tsx 88.88% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8501      +/-   ##
==========================================
- Coverage   60.93%   60.93%   -0.01%     
==========================================
  Files        3767     3769       +2     
  Lines       89406    89498      +92     
  Branches    13994    14008      +14     
==========================================
+ Hits        54478    54534      +56     
- Misses      31526    31556      +30     
- Partials     3402     3408       +6     
Flag Coverage Δ
Linux_1 29.00% <69.09%> (+0.04%) ⬆️
Linux_2 56.25% <ø> (ø)
Linux_3 37.75% <ø> (+<0.01%) ⬆️
Linux_4 29.91% <ø> (ø)
Windows_1 29.02% <69.09%> (+0.04%) ⬆️
Windows_2 56.20% <ø> (ø)
Windows_3 37.75% <ø> (ø)
Windows_4 29.91% <ø> (ø)

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.

group: collaboratorId,
}),
}));
const newPermissionSettings = [...permissionSettings, ...addedSettings];
Copy link
Member

Choose a reason for hiding this comment

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

Shall we check duplicate records here?

Copy link
Contributor Author

@raintygao raintygao Oct 7, 2024

Choose a reason for hiding this comment

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

Yes, we change to use modal and the check interaction is to be confirmed with at least one owner, we could ignore this for now.

Comment on lines 54 to 52
onChange(newPermissionSettings);
handleSubmitPermissionSettings(newPermissionSettings as WorkspacePermissionSetting[]);
Copy link
Member

Choose a reason for hiding this comment

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

It seems we are telling parent component we are changing the permission settings through 2 callbacks. May I know the reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original reason is that we will split change and submit into two steps for now, one is changing data flow, one is submitting and refreshing. For now we won't refresh after submitting, let me combine them.

Comment on lines 426 to 443
// const userPermissionExists = finalPermissionSettings.find(
// (setting) => setting.type === WorkspacePermissionItemType.User
// );
// const groupPermissionExists = finalPermissionSettings.find(
// (setting) => setting.type === WorkspacePermissionItemType.Group
// );
// if (!userPermissionExists) {
// finalPermissionSettings.push({
// ...emptyUserPermission,
// id: generateNextPermissionSettingsId(finalPermissionSettings),
// } as typeof finalPermissionSettings[0]);
// }
// if (!groupPermissionExists) {
// finalPermissionSettings.push({
// ...emptyUserGroupPermission,
// id: generateNextPermissionSettingsId(finalPermissionSettings),
// } as typeof finalPermissionSettings[0]);
// }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// const userPermissionExists = finalPermissionSettings.find(
// (setting) => setting.type === WorkspacePermissionItemType.User
// );
// const groupPermissionExists = finalPermissionSettings.find(
// (setting) => setting.type === WorkspacePermissionItemType.Group
// );
// if (!userPermissionExists) {
// finalPermissionSettings.push({
// ...emptyUserPermission,
// id: generateNextPermissionSettingsId(finalPermissionSettings),
// } as typeof finalPermissionSettings[0]);
// }
// if (!groupPermissionExists) {
// finalPermissionSettings.push({
// ...emptyUserGroupPermission,
// id: generateNextPermissionSettingsId(finalPermissionSettings),
// } as typeof finalPermissionSettings[0]);
// }

Better to remove the code instead of comment out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry, I missed this change. 😂

Comment on lines 142 to 146
cancelButtonText="Cancel"
confirmButtonText="Confirm"
>
<EuiText>
<p>Delete collaborator? The collaborators will not have access to the workspace.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Nit: i18n

const basicSettings = {
...setting,
// This is used for table display and search match.
displayedType:
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8486/files#diff-974bcd16c33ef28e4be36bfb140026ab9cb437f8b85bdd717ba7ecf58d38bd0eR17

Should we use this method to get the displayedType? I do not think it is collaborator_table's duty to generate the displayedType.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but this method not been implemented. It only provides a virtual type. cc @wanglam

Copy link
Contributor

@wanglam wanglam Oct 8, 2024

Choose a reason for hiding this comment

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

I think we should call all displayedCollaboratorTypes.getDisplayedType and use the first not undefined result and display a &mdash; if it's undefined. Forget to register default getDisplayedType in my previous PR. We can call getDisplayedType here first.

@@ -138,7 +138,7 @@ export const permissionModeOptions = [
inputDisplay: i18n.translate(
'workspace.form.permissionSettingPanel.permissionModeOptions.readAndWrite',
{
defaultMessage: 'Read & Write',
defaultMessage: 'Read and write',
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: can we use WORKSPACE_ACCESS_LEVEL_NAMES in src/plugins/workspace/public/constants.ts instead?

@@ -16,7 +16,7 @@ import { WorkspaceFormProvider, WorkspaceOperationType } from '../workspace_form
import { DataSourceConnectionType } from '../../../common/types';
import * as utilsExports from '../../utils';
import { IntlProvider } from 'react-intl';

import { of } from 'rxjs';
Copy link
Member

Choose a reason for hiding this comment

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

Nit: let's keep the empty line

Suggested change
import { of } from 'rxjs';
import { of } from 'rxjs';

<EuiConfirmModal
title="Change access level"
onCancel={() => modal.close()}
onConfirm={async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Is this async necessary?

if (selection) {
const modal = overlays.openModal(
<EuiConfirmModal
title="Change access level"
Copy link
Member

Choose a reason for hiding this comment

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

i18n?

const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const { overlays } = useOpenSearchDashboards();

const accessLevelOptions = Object.keys(WORKSPACE_ACCESS_LEVEL_NAMES).map((level) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: We can use Object.keys(WORKSPACE_ACCESS_LEVEL_NAMES) as WorkspaceCollaboratorAccessLevel[]
, then we don't need too many as WorkspaceCollaboratorAccessLevel below.

confirmButtonText="Confirm"
>
<EuiText>
<p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing i18n here.

@Hailong-am Hailong-am merged commit 98df4dd into opensearch-project:main Oct 9, 2024
68 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 9, 2024
* feat: add collaborator table

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

* Changeset file for PR #8501 created/updated

* Changeset file for PR #8501 created/updated

* remove extra comment and add test for button

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

* combine onChange

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

* update table

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

* test: add tests for table

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

* address comments

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

---------

Signed-off-by: tygao <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 98df4dd)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Hailong-am pushed a commit that referenced this pull request Oct 9, 2024
…) (#8528)

* feat: add collaborator table



* Changeset file for PR #8501 created/updated

* Changeset file for PR #8501 created/updated

* remove extra comment and add test for button



* combine onChange



* update table



* test: add tests for table



* address comments



---------



(cherry picked from commit 98df4dd)

Signed-off-by: tygao <[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>
@ananzh ananzh added the v2.18.0 label Oct 30, 2024
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.

6 participants