From f11d660503bf7c5ccd8eb1aa0416ace63d6c22cb Mon Sep 17 00:00:00 2001 From: Lin Wang Date: Tue, 19 Sep 2023 14:12:49 +0800 Subject: [PATCH] feat: remove permissionModes in savedobject client find method Signed-off-by: Lin Wang --- .../workspace_saved_objects_client_wrapper.ts | 3 +-- src/plugins/workspace/server/workspace_client.ts | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/workspace/server/saved_objects/workspace_saved_objects_client_wrapper.ts b/src/plugins/workspace/server/saved_objects/workspace_saved_objects_client_wrapper.ts index 5a8f59af9e37..d9c7bfd2bd47 100644 --- a/src/plugins/workspace/server/saved_objects/workspace_saved_objects_client_wrapper.ts +++ b/src/plugins/workspace/server/saved_objects/workspace_saved_objects_client_wrapper.ts @@ -30,7 +30,6 @@ import { SavedObjectsErrorHelpers, } from '../../../../core/server'; import { SavedObjectsPermissionControlContract } from '../permission_control/client'; -import { WorkspaceFindOptions } from '../types'; import { getPrincipalsFromRequest } from '../utils'; const ALL_WORKSPACE_INNER_DATA_PERMISSION_MODES: string[] = [ @@ -361,7 +360,7 @@ export class WorkspaceSavedObjectsClientWrapper { }; const findWithWorkspacePermissionControl = async ( - options: SavedObjectsFindOptions & Pick + options: SavedObjectsFindOptions ) => { const principals = getPrincipalsFromRequest(wrapperOptions.request); if (!options.ACLSearchParams) { diff --git a/src/plugins/workspace/server/workspace_client.ts b/src/plugins/workspace/server/workspace_client.ts index 56a8fd2d0d1e..b72b8089be68 100644 --- a/src/plugins/workspace/server/workspace_client.ts +++ b/src/plugins/workspace/server/workspace_client.ts @@ -228,11 +228,13 @@ export class WorkspaceClientWithSavedObject implements IWorkspaceDBImpl { options: WorkspaceFindOptions ): ReturnType { try { + const { permissionModes, ...restOptions } = options; const resultResp = await this.getSavedObjectClientsFromRequestDetail(requestDetail).find< WorkspaceAttribute >({ - ...options, + ...restOptions, type: WORKSPACE_TYPE, + ...(permissionModes ? { ACLSearchParams: { permissionModes } } : {}), }); const others = omit(resultResp, 'saved_objects'); let savedObjects = resultResp.saved_objects; @@ -284,8 +286,9 @@ export class WorkspaceClientWithSavedObject implements IWorkspaceDBImpl { const retryFindResp = await this.getSavedObjectClientsFromRequestDetail( requestDetail ).find({ - ...options, + ...restOptions, type: WORKSPACE_TYPE, + ...(permissionModes ? { ACLSearchParams: { permissionModes } } : {}), }); savedObjects = retryFindResp.saved_objects; }