-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat: setup reserved workspaces when calling list workspaces API #178
Feat: setup reserved workspaces when calling list workspaces API #178
Conversation
Codecov Report
@@ Coverage Diff @@
## workspace #178 +/- ##
=============================================
+ Coverage 61.39% 61.87% +0.48%
=============================================
Files 2982 2117 -865
Lines 57792 40889 -16903
Branches 9360 7470 -1890
=============================================
- Hits 35481 25300 -10181
+ Misses 20224 13897 -6327
+ Partials 2087 1692 -395
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 937 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
b2e16b5
to
2d913a2
Compare
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
@@ -125,6 +227,52 @@ export class WorkspaceClientWithSavedObject implements IWorkspaceDBImpl { | |||
type: WORKSPACE_TYPE, | |||
} | |||
); | |||
const scopedClientWithoutPermissionCheck = this.getScopeClientWithoutPermisson(requestDetail); |
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.
There has been a PR fixing typos, please change the function name to getScopedClientWithoutPermission
.
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.
Fixed and thanks
const managementWorkspaceACL = new ACL().addPermission([WorkspacePermissionMode.Management], { | ||
users: ['*'], | ||
}); |
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.
For management workspace, are we going to grant WorkspacePermissionMode.Management
to all users?
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.
Yes, the conclusion is that we will make public and management workspace manageable by anyone, and the first one can change the permission if they want to limit the permission.
const publicWorkspaceACL = new ACL().addPermission([WorkspacePermissionMode.Management], { | ||
users: ['*'], | ||
}); |
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.
For public workspace, are we going to grant WorkspacePermissionMode.Management
to all users?
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.
Yes, the conclusion is that we will make public and management workspace manageable by anyone, and the first one can change the permission if they want to limit the permission.
I found that reserved workspaces were not automatically created from the left menu header. When workspace feature is enabled, the header obtain the workspace list like the following:
Instead of simply get |
There should be a place to call the workspace _list or the workspaceList$ will always be empty. |
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
} | ||
|
||
public getPrincipalsFromRequest(request: OpenSearchDashboardsRequest): Principals { | ||
static getPrincipalsFromRequest(request: OpenSearchDashboardsRequest): Principals { |
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.
Nit: I might just move this out of the class and make it a pure util function
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.
Agree, changed that.
PUBLIC_WORKSPACE_ID, | ||
{ | ||
name: i18n.translate('workspaces.public.workspace.default.name', { | ||
defaultMessage: 'public', |
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.
Would be nice to tweak a bit
defaultMessage: 'public', | |
defaultMessage: 'Public', |
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.
Thanks for this catch. According to mockup, it should be named "Global workspace", changed to that.
/** | ||
* Setup public workspace if public workspace can not be found | ||
*/ | ||
const hasPublicWorkspace = savedObjects.find((item) => item.id === PUBLIC_WORKSPACE_ID); |
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.
The name hasPublicWorkspace
indicates a boolean values, can we change find
-> some
?
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.
Sure, changed that.
*/ | ||
if (principals.users) { | ||
const hasPersonalWorkspace = savedObjects.find((item) => | ||
principals.users?.includes(item.id) |
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.
Can you leave a comment and say something like: user id will be personal workspace id
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.
Sure, done.
@@ -125,6 +227,52 @@ export class WorkspaceClientWithSavedObject implements IWorkspaceDBImpl { | |||
type: WORKSPACE_TYPE, | |||
} | |||
); | |||
const scopedClientWithoutPermissionCheck = this.getScopedClientWithoutPermission(requestDetail); |
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.
Please fix lint
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Will permission related changes in this PR be conflicted with this task? https://github.com/orgs/opensearch-project/projects/127/views/5?sortedBy%5Bdirection%5D=asc&sortedBy%5BcolumnId%5D=Assignees&pane=issue&itemId=38846476 |
Let me change the setup permission to comply with the new permission model. |
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
* feat: setup reserved workspaces when calling list workspaces API Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: fix test flow Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: fix lint Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: fix typos Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * fix: setup personal workspace using correct id Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * refractor: move function getPrincipalsFromRequest to a util function Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: change code according to comment Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: modify reserved workspace permission Signed-off-by: SuZhou-Joe <suzhou@amazon.com> --------- Signed-off-by: SuZhou-Joe <suzhou@amazon.com> (cherry picked from commit 4bccdea) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
… (#183) * feat: setup reserved workspaces when calling list workspaces API * feat: fix test flow * feat: fix lint * feat: fix typos * fix: setup personal workspace using correct id * refractor: move function getPrincipalsFromRequest to a util function * feat: change code according to comment * feat: modify reserved workspace permission --------- (cherry picked from commit 4bccdea) Signed-off-by: SuZhou-Joe <suzhou@amazon.com> 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>
Description
Issues Resolved
Screenshot
Testing the changes
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr