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] Add privacy levels to the workspace #8907

Merged

Conversation

Kapian1234
Copy link
Contributor

@Kapian1234 Kapian1234 commented Nov 21, 2024

Description

Add workspace privacy settings to configure user permissions at workspace create, details and collaborators page;
Validate the collaborator input, a single '*' input is not allowed.

Issues Resolved

Screenshot

Workspace create
Screenshot 2024-11-25 at 11 58 44

Collaborators
Screenshot 2024-11-25 at 12 00 14
Screenshot 2024-11-25 at 12 00 55
Screenshot 2024-11-25 at 12 01 20
Screenshot 2024-11-25 at 12 02 03

Workspace details
Screenshot 2024-11-28 at 10 49 00
Screenshot 2024-11-28 at 10 49 24

Disallow '*' as an input
Screenshot 2024-12-02 at 10 38 52

Testing the changes

Changelog

  • feat: Add privacy levels to the workspace

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 Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.97%. Comparing base (40e61c7) to head (01f0c85).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8907      +/-   ##
==========================================
+ Coverage   60.93%   60.97%   +0.03%     
==========================================
  Files        3809     3812       +3     
  Lines       91267    91348      +81     
  Branches    14413    14433      +20     
==========================================
+ Hits        55616    55698      +82     
+ Misses      32097    32096       -1     
  Partials     3554     3554              
Flag Coverage Δ
Linux_1 29.05% <100.00%> (+0.08%) ⬆️
Linux_2 56.45% <ø> (ø)
Linux_3 37.97% <ø> (+<0.01%) ⬆️
Linux_4 29.03% <ø> (ø)
Windows_1 29.07% <100.00%> (+0.08%) ⬆️
Windows_2 56.40% <ø> (ø)
Windows_3 37.97% <ø> (ø)
Windows_4 29.03% <ø> (ø)

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.

@Kapian1234 Kapian1234 marked this pull request as ready for review December 2, 2024 03:42
@Kapian1234 Kapian1234 requested a review from ananzh as a code owner December 2, 2024 03:42
@SuZhou-Joe
Copy link
Member

@Kapian1234 Snapshot check failed in ci group 3, could you please fix that?

paddingSize="l"
initialIsOpen={true}
>
<EuiText className="workspace-privacy-flyout-description" size="s">
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 use style={{ whiteSpace: 'pre-line' }} here? Then we can remove the src/plugins/workspace/public/components/workspace_form/workspace_privacy_flyout.scss file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add some unit tests for this file?

Signed-off-by: Kapian1234 <[email protected]>
@@ -190,6 +200,12 @@ export const WorkspaceFormSummaryPanel = ({
)}
</FieldSummaryItem>
)}
{isPermissionEnabled && (
<FieldSummaryItem field={RightSidebarScrollField.PrivacyType}>
{privacyType && <EuiText size="xs">{privacyType2TextMap[privacyType].title}</EuiText>}
Copy link
Member

Choose a reason for hiding this comment

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

Should it actually check privacyType2TextMap[privacyType] here?

Suggested change
{privacyType && <EuiText size="xs">{privacyType2TextMap[privacyType].title}</EuiText>}
{privacyType2TextMap[privacyType] && <EuiText size="xs">{privacyType2TextMap[privacyType].title}</EuiText>}

Copy link
Contributor

@wanglam wanglam Jan 8, 2025

Choose a reason for hiding this comment

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

From a type-safe perspective, we don't need to perform any checks here. The privacyType was defined as the WorkspacePrivacyItemType type above. The privacyType2TextMap is using WorkspacePrivacyItemType as the map key. The privacyType2TextMap[privacyType] must exist. Do you think if we should check privacyType2TextMap[privacyType] exists here? It can be updated in the next collaborators' flyout PR.

@SuZhou-Joe SuZhou-Joe merged commit 8d98654 into opensearch-project:main Jan 8, 2025
69 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-8907-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 8d98654edee51417a640c2fcedf244dc267bddd4
# Push it to GitHub
git push --set-upstream origin backport/backport-8907-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-8907-to-2.x.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 9, 2025
* Add privacy selector UI at create page

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

* Add privacy settings UI at collaborstors page

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

* Changeset file for PR #8907 created/updated

* Add privacy settings panel at collaborstors page

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

* Fix the height of cards at workspace create page

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

* Refactor workspace creator form with privacyType and setPrivacyType

Signed-off-by: Lin Wang <[email protected]>

* Resolve some issues

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

* Add privacy settings control at details page

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

* Add single star user check for add collaborators modal

Signed-off-by: Lin Wang <[email protected]>

* Disable save button if the selected privay type remains unchanged at collaborators page

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

* Fix workspace creator UT

Signed-off-by: Lin Wang <[email protected]>

* Fix failed snapshots

Signed-off-by: Lin Wang <[email protected]>

* Add missing UT for workspace form utils

Signed-off-by: Lin Wang <[email protected]>

* Update UT for useWorkspaceForm

Signed-off-by: Lin Wang <[email protected]>

* Add unit tests for privacy settings at workspace create and details

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

* /

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

* Fix redirect to workspace landing page

Signed-off-by: Lin Wang <[email protected]>

* Remove changes to configuration files

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

* Remove changes to configuration files

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

* Add unit test for notification toasts

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

* Add test id for privacy setting selector

Signed-off-by: Lin Wang <[email protected]>

* Add unit test for Collaborators Link at workspace details

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

* Use constant for collaborators link

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

* Fix issues of spelling and importing path

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

* Remove the validation for the existence of an owner in permission settings

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

* Add test id for privacy setting button in collaborators page

Signed-off-by: Lin Wang <[email protected]>

* Fix the discard operation

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

* Add workspace privacy to summary card

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

* Add additional privacy description at workspace create page

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

* Remove unit tests related to missing owner in permission settings

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

* Add permissionEnabled check for summary card

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

* Disallow * input for user groups

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

* Rename the converter and move options outside the function

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

* Add learn more flyout at collaborators page

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

* Fix unit tests and update snapshots

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

* Remove the scss file for WorkspacePrivacyFlyout

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

* Address some issues

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

---------

Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Lin Wang <[email protected]>
Co-authored-by: SuZhou-Joe <[email protected]>
(cherry picked from commit 8d98654)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
SuZhou-Joe added a commit that referenced this pull request Jan 9, 2025
* Add privacy selector UI at create page



* Add privacy settings UI at collaborstors page



* Changeset file for PR #8907 created/updated

* Add privacy settings panel at collaborstors page



* Fix the height of cards at workspace create page



* Refactor workspace creator form with privacyType and setPrivacyType



* Resolve some issues



* Add privacy settings control at details page



* Add single star user check for add collaborators modal



* Disable save button if the selected privay type remains unchanged at collaborators page



* Fix workspace creator UT



* Fix failed snapshots



* Add missing UT for workspace form utils



* Update UT for useWorkspaceForm



* Add unit tests for privacy settings at workspace create and details



* /



* Fix redirect to workspace landing page



* Remove changes to configuration files



* Remove changes to configuration files



* Add unit test for notification toasts



* Add test id for privacy setting selector



* Add unit test for Collaborators Link at workspace details



* Use constant for collaborators link



* Fix issues of spelling and importing path



* Remove the validation for the existence of an owner in permission settings



* Add test id for privacy setting button in collaborators page



* Fix the discard operation



* Add workspace privacy to summary card



* Add additional privacy description at workspace create page



* Remove unit tests related to missing owner in permission settings



* Add permissionEnabled check for summary card



* Disallow * input for user groups



* Rename the converter and move options outside the function



* Add learn more flyout at collaborators page



* Fix unit tests and update snapshots



* Remove the scss file for WorkspacePrivacyFlyout



* Address some issues



---------






(cherry picked from commit 8d98654)

Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Lin Wang <[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>
Co-authored-by: Lin Wang <[email protected]>
Co-authored-by: SuZhou-Joe <[email protected]>
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