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] fix: Fix workspace page hanging with none collaborators for non dashboard admin #9004

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

raintygao
Copy link
Contributor

@raintygao raintygao commented Dec 4, 2024

Description

Fix workspace page hanging with none collaborators for non dashboard admin

Previously the permission field of a workspace with none collaborators is undefined, which will pass the workspace permission wrapper and cause page hanging. Actually this field could be an empty ACL object as workspace type object should always have this field.

Screenshot

image
Before

image
After

Testing the changes

  1. Use OSD admin to create a workspace then delete all collaborators.
  2. Use non OSD admin visit this workspace, then the page will not be hanging and throw error.

Changelog

  • fix: Fix workspace page hanging with none collaborators for non dashboard admin

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 Dec 4, 2024
@raintygao raintygao changed the title [Workspace] fix: Fix page hanging when none collaborators for non dashboard admin [Workspace] fix: Fix page hanging with none collaborators for non dashboard admin Dec 4, 2024
@raintygao raintygao changed the title [Workspace] fix: Fix page hanging with none collaborators for non dashboard admin [Workspace] fix: Fix workspace page hanging with none collaborators for non dashboard admin Dec 4, 2024
opensearch-changeset-bot bot added a commit to raintygao/OpenSearch-Dashboards that referenced this pull request Dec 4, 2024
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.86%. Comparing base (9f23442) to head (b9b7edd).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9004      +/-   ##
==========================================
- Coverage   60.87%   60.86%   -0.02%     
==========================================
  Files        3808     3808              
  Lines       91209    91210       +1     
  Branches    14410    14410              
==========================================
- Hits        55526    55517       -9     
- Misses      32142    32153      +11     
+ Partials     3541     3540       -1     
Flag Coverage Δ
Linux_1 29.02% <100.00%> (+<0.01%) ⬆️
Linux_2 56.38% <ø> (ø)
Linux_3 37.93% <ø> (+<0.01%) ⬆️
Linux_4 29.01% <ø> (ø)
Windows_1 29.03% <100.00%> (-0.02%) ⬇️
Windows_2 56.34% <ø> (ø)
Windows_3 37.93% <ø> (ø)
Windows_4 29.01% <ø> (ø)

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.

Comment on lines 40 to 46
export const EMPTY_PERMISSIONS = {
library_read: {},
library_write: {},
read: {},
write: {},
};

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 a WorkspacePermissionSetting object? If so can we add the typing so that typescript can better infer the return type of convertPermissionSettingsToPermissions?

We can also define this as readonly to ensure no consumer can modify this.

Ex.

export const EMPTY_PERMISSIONS: WorkspacePermissionSetting = {
  library_read: {},
  library_write: {},
  read: {},
  write: {},
} as const;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Its type is SavedObjectPermissions, have updated.

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

Comment on lines -107 to 116
return undefined;
// Workspace object should always have permissions, set it as an empty object here instead of undefined.
return EMPTY_PERMISSIONS;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

does it has any impact when permission control is turned off?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I supposed it may not as this is a specific object for workspace object.

Copy link
Collaborator

Choose a reason for hiding this comment

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

when permission control is off, permission field will not initialized and add to kibana index, i am not sure it will cause any issue when try to save a object with empty permission, we can have a test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This means the value of permission field will not be consistent between permission is on/off, right? So it seems updating client wrapper will be a better solution?

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