Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
  • Loading branch information
SuZhou-Joe committed Aug 9, 2023
1 parent 83f1648 commit dc3029b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
13 changes: 6 additions & 7 deletions src/core/public/saved_objects/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,9 @@ export class SavedObjectsClient {
};
const currentWorkspaceId = this._getCurrentWorkspace();
let finalWorkspaces;
if (options.workspaces) {
if (options.hasOwnProperty('workspaces')) {
finalWorkspaces = options.workspaces;
} else if (typeof currentWorkspaceId === 'string') {
/**
* When the currentWorkspaceId is an empty string instead of undefined
* It means user is creating object in public workspace.
*/
finalWorkspaces = [currentWorkspaceId];
}

Expand Down Expand Up @@ -383,10 +379,13 @@ export class SavedObjectsClient {

const currentWorkspaceId = this._getCurrentWorkspace();
let finalWorkspaces;
if (options.workspaces) {
if (options.hasOwnProperty('workspaces')) {
finalWorkspaces = options.workspaces;
} else if (typeof currentWorkspaceId === 'string') {
finalWorkspaces = currentWorkspaceId ? [PUBLIC_WORKSPACE, currentWorkspaceId] : undefined;
finalWorkspaces =
currentWorkspaceId === PUBLIC_WORKSPACE
? undefined
: [PUBLIC_WORKSPACE, currentWorkspaceId];
}

const renamedQuery = renameKeys<SavedObjectsFindOptions, any>(renameMap, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,7 @@ export class WorkspaceSavedObjectsClientWrapper {
throw generateWorkspacePermissionError();
}
} else {
const queryDSL = ACL.genereateGetPermittedSavedObjectsQueryDSL(
[
PermissionMode.LibraryRead,
PermissionMode.LibraryWrite,
PermissionMode.Management,
PermissionMode.Read,
PermissionMode.Write,
],
principals,
options.type
);
options.workspaces = permittedWorkspaceIds;
options.queryDSL = queryDSL;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
}

private get workspaceIdQuery() {
return this.state.workspaceId
return this.state.workspaceId !== PUBLIC_WORKSPACE && this.state.workspaceId
? Array.from(new Set([PUBLIC_WORKSPACE, this.state.workspaceId]))
: undefined;
}
Expand Down

0 comments on commit dc3029b

Please sign in to comment.