Skip to content

Commit

Permalink
chore: update name and assertion
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <tygao@amazon.com>
  • Loading branch information
raintygao committed Sep 25, 2023
1 parent c9f5142 commit 6050914
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ export class WorkspaceSavedObjectsClientWrapper {
objects: Array<SavedObjectsBulkCreateObject<T>>,
options: SavedObjectsCreateOptions = {}
): Promise<SavedObjectsBulkResponse<T>> => {
const isPassedWorkspaces = options?.workspaces && options.workspaces.length > 0;
const hasTargetWorkspaces = options?.workspaces && options.workspaces.length > 0;

if (
isPassedWorkspaces &&
hasTargetWorkspaces &&
!(await this.validateMultiWorkspacesPermissions(
options.workspaces!,
options.workspaces ?? [],
wrapperOptions.request,
[WorkspacePermissionMode.LibraryWrite, WorkspacePermissionMode.Management]
))
Expand All @@ -272,7 +272,7 @@ export class WorkspaceSavedObjectsClientWrapper {
!(await this.validateWorkspacesAndSavedObjectsPermissions(
await wrapperOptions.client.get(type, id),
wrapperOptions.request,
!isPassedWorkspaces
!hasTargetWorkspaces
? // If no workspaces are passed, we need to check the workspace permission of object when overwrite.
[WorkspacePermissionMode.LibraryWrite, WorkspacePermissionMode.Management]
: [],
Expand All @@ -293,12 +293,12 @@ export class WorkspaceSavedObjectsClientWrapper {
attributes: T,
options?: SavedObjectsCreateOptions
) => {
const isPassedWorkspaces = options?.workspaces && options.workspaces.length > 0;
const hasTargetWorkspaces = options?.workspaces && options.workspaces.length > 0;

if (
isPassedWorkspaces &&
hasTargetWorkspaces &&
!(await this.validateMultiWorkspacesPermissions(
options.workspaces!,
options.workspaces ?? [],
wrapperOptions.request,
[WorkspacePermissionMode.LibraryWrite, WorkspacePermissionMode.Management]
))
Expand All @@ -312,7 +312,7 @@ export class WorkspaceSavedObjectsClientWrapper {
!(await this.validateWorkspacesAndSavedObjectsPermissions(
await wrapperOptions.client.get(type, options.id),
wrapperOptions.request,
!isPassedWorkspaces
!hasTargetWorkspaces
? // If no workspaces are passed, we need to check the workspace permission of object when overwrite.
[WorkspacePermissionMode.LibraryWrite, WorkspacePermissionMode.Management]
: [],
Expand Down

0 comments on commit 6050914

Please sign in to comment.