Skip to content

Commit

Permalink
Optimize the code
Browse files Browse the repository at this point in the history
Signed-off-by: yubonluo <yubonluo@amazon.com>
  • Loading branch information
yubonluo committed Jun 3, 2024
1 parent 8a5721e commit 35b04bd
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@ export class WorkspaceSavedObjectsClientWrapper {
// Objects with id in overwrite mode will be regarded as update
const objectsToCreate = options.overwrite ? objects.filter((obj) => !obj.id) : objects;
// Only OSD admin can bulkCreate workspace.
if (objectsToCreate.some((obj) => obj.type === WORKSPACE_TYPE))
if (objectsToCreate.some((obj) => obj.type === WORKSPACE_TYPE)) {
throw generateOSDAdminPermissionError();
}

const hasTargetWorkspaces = options?.workspaces && options.workspaces.length > 0;

Expand Down Expand Up @@ -348,7 +349,9 @@ export class WorkspaceSavedObjectsClientWrapper {
// If options contains id and overwrite, it is an update action.
const isUpdateMode = options?.id && options?.overwrite;
// Only OSD admin can create workspace.
if (type === WORKSPACE_TYPE && !isUpdateMode) throw generateOSDAdminPermissionError();
if (type === WORKSPACE_TYPE && !isUpdateMode) {
throw generateOSDAdminPermissionError();
}

const hasTargetWorkspaces = options?.workspaces && options.workspaces.length > 0;

Expand Down

0 comments on commit 35b04bd

Please sign in to comment.