From 9e0e9798c80dc24468b06354f2fbcd234c685ef7 Mon Sep 17 00:00:00 2001 From: "opensearch-workspace-development[bot]" <144193788+opensearch-workspace-development[bot]@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:34:33 +0800 Subject: [PATCH] fix: workspace permission entire update (#132) (#141) * fix: workspace permission entire update * refactor: rename to convertToFullWorkspacePermissions and remove read and write permission * Revert "refactor: rename to convertToFullWorkspacePermissions and remove read and write permission" This reverts commit a4b7ba79d425ce7268918469446a738d6f525975. * Revert "fix: workspace permission entire update" This reverts commit d972e132820c80968b101015786c2d15c480dd92. * fix: update to client.create to override entire object * feat: add workspace version limit for object update --------- (cherry picked from commit 0bd03dfe91b963b75124016d927ac3df8a1b3914) Signed-off-by: Lin Wang Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- src/plugins/workspace/server/workspace_client.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/workspace/server/workspace_client.ts b/src/plugins/workspace/server/workspace_client.ts index f72952f72378..437522b2f26b 100644 --- a/src/plugins/workspace/server/workspace_client.ts +++ b/src/plugins/workspace/server/workspace_client.ts @@ -166,9 +166,14 @@ export class WorkspaceClientWithSavedObject implements IWorkspaceDBImpl { throw new Error(DUPLICATE_WORKSPACE_NAME_ERROR); } } - await client.update>(WORKSPACE_TYPE, id, attributes, { + + await client.create>(WORKSPACE_TYPE, attributes, { + id, permissions, + overwrite: true, + version: workspaceInDB.version, }); + return { success: true, result: true,