Skip to content

Commit

Permalink
feat: address TODO
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Mar 22, 2024
1 parent 876487d commit 9e74d17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 37 deletions.
14 changes: 6 additions & 8 deletions src/plugins/workspace/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
this.workspaceConflictControl.wrapperFactory
);

core.savedObjects.addClientWrapper(
-2,
WORKSPACE_ID_CONSUMER_WRAPPER_ID,
new WorkspaceIdConsumerWrapper().wrapperFactory
);

this.logger.info('Workspace permission control enabled:' + isPermissionControlEnabled);
if (isPermissionControlEnabled) {
this.permissionControl = new SavedObjectsPermissionControl(this.logger);
Expand All @@ -100,14 +106,6 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
);
}

// TODO: TOO many client wrapper inside a single workspace plugin
// Try to combine conflict wrapper and this consumer wrapper.
core.savedObjects.addClientWrapper(
-2,
WORKSPACE_ID_CONSUMER_WRAPPER_ID,
new WorkspaceIdConsumerWrapper().wrapperFactory
);

registerRoutes({
http: core.http,
logger: this.logger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import {
SavedObjectsCheckConflictsObject,
OpenSearchDashboardsRequest,
SavedObjectsFindOptions,
SavedObjectsUpdateOptions,
SavedObjectsBulkUpdateOptions,
SavedObjectsBulkUpdateObject,
WORKSPACE_TYPE,
} from '../../../../core/server';

Expand Down Expand Up @@ -89,26 +86,8 @@ export class WorkspaceIdConsumerWrapper {
),
bulkGet: wrapperOptions.client.bulkGet,
get: wrapperOptions.client.get,
update: <T = unknown>(
type: string,
id: string,
attributes: Partial<T>,
options: SavedObjectsUpdateOptions = {}
) =>
wrapperOptions.client.update(
type,
id,
attributes,
this.formatWorkspaceIdParams(wrapperOptions.request, options)
),
bulkUpdate: <T = unknown>(
objects: Array<SavedObjectsBulkUpdateObject<T>>,
options?: SavedObjectsBulkUpdateOptions
) =>
wrapperOptions.client.bulkUpdate(
objects,
this.formatWorkspaceIdParams(wrapperOptions.request, options)
),
update: wrapperOptions.client.update,
bulkUpdate: wrapperOptions.client.bulkUpdate,
addToNamespaces: wrapperOptions.client.addToNamespaces,
deleteFromNamespaces: wrapperOptions.client.deleteFromNamespaces,
};
Expand Down
7 changes: 1 addition & 6 deletions src/plugins/workspace/server/workspace_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ import {
import { IWorkspaceClientImpl, WorkspaceFindOptions, IResponse, IRequestDetail } from './types';
import { workspace } from './saved_objects';
import { generateRandomId } from './utils';
import {
WORKSPACE_ID_CONSUMER_WRAPPER_ID,
WORKSPACE_OVERVIEW_APP_ID,
WORKSPACE_SAVED_OBJECTS_CLIENT_WRAPPER_ID,
WORKSPACE_UPDATE_APP_ID,
} from '../common/constants';
import { WORKSPACE_SAVED_OBJECTS_CLIENT_WRAPPER_ID } from '../common/constants';

const WORKSPACE_ID_SIZE = 6;

Expand Down

0 comments on commit 9e74d17

Please sign in to comment.