From 98d60a442de8c8ca5e4bbbed761b6b088457af2b Mon Sep 17 00:00:00 2001 From: yubonluo <15242088755@163.com> Date: Tue, 5 Mar 2024 14:32:07 +0800 Subject: [PATCH 1/3] remove management workspace --- src/core/public/index.ts | 1 - src/core/public/utils/index.ts | 1 - src/core/server/index.ts | 1 - src/core/utils/constants.ts | 2 - src/core/utils/index.ts | 1 - .../workspace_creator/workspace_form.tsx | 24 ++++------- .../workspace_menu/workspace_menu.tsx | 24 +---------- .../server/integration_tests/routes.test.ts | 4 +- .../workspace/server/workspace_client.ts | 40 ------------------- 9 files changed, 11 insertions(+), 87 deletions(-) diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 1c55911d0ab3..a41fdd71a4f6 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -357,7 +357,6 @@ export { WorkspacesStart, WorkspacesSetup, WorkspacesService } from './workspace export { WorkspacePermissionMode, PUBLIC_WORKSPACE_ID, - MANAGEMENT_WORKSPACE_ID, WORKSPACE_TYPE, cleanWorkspaceId, } from '../utils'; diff --git a/src/core/public/utils/index.ts b/src/core/public/utils/index.ts index 6786739cd1d6..de82b561e4e7 100644 --- a/src/core/public/utils/index.ts +++ b/src/core/public/utils/index.ts @@ -37,5 +37,4 @@ export { formatUrlWithWorkspaceId, getWorkspaceIdFromUrl, PUBLIC_WORKSPACE_ID, - MANAGEMENT_WORKSPACE_ID, } from '../../utils'; diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 63c9904ccb1e..1527a600660f 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -364,7 +364,6 @@ export { DEFAULT_APP_CATEGORIES, WorkspacePermissionMode, PUBLIC_WORKSPACE_ID, - MANAGEMENT_WORKSPACE_ID, WORKSPACE_TYPE, } from '../utils'; diff --git a/src/core/utils/constants.ts b/src/core/utils/constants.ts index f4c5d9948a25..069114825090 100644 --- a/src/core/utils/constants.ts +++ b/src/core/utils/constants.ts @@ -15,5 +15,3 @@ export enum WorkspacePermissionMode { } export const PUBLIC_WORKSPACE_ID = 'public'; - -export const MANAGEMENT_WORKSPACE_ID = 'management'; diff --git a/src/core/utils/index.ts b/src/core/utils/index.ts index da3bfba02f1f..1f31bcc5862c 100644 --- a/src/core/utils/index.ts +++ b/src/core/utils/index.ts @@ -41,7 +41,6 @@ export { WORKSPACE_PATH_PREFIX, WorkspacePermissionMode, PUBLIC_WORKSPACE_ID, - MANAGEMENT_WORKSPACE_ID, WORKSPACE_TYPE, } from './constants'; export { getWorkspaceIdFromUrl, formatUrlWithWorkspaceId, cleanWorkspaceId } from './workspace'; diff --git a/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx b/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx index b2ff40855a9d..4907470fa330 100644 --- a/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx +++ b/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx @@ -34,7 +34,6 @@ import { AppNavLinkStatus, ApplicationStart, DEFAULT_APP_CATEGORIES, - MANAGEMENT_WORKSPACE_ID, } from '../../../../../core/public'; import { useApplications } from '../../hooks'; import { DEFAULT_CHECKED_FEATURES_IDS } from '../../../common/constants'; @@ -172,17 +171,10 @@ export const WorkspaceForm = ({ const [color, setColor] = useState(defaultValues?.color); const [icon, setIcon] = useState(defaultValues?.icon); const [defaultVISTheme, setDefaultVISTheme] = useState(defaultValues?.defaultVISTheme); - const isEditingManagementWorkspace = defaultValues?.id === MANAGEMENT_WORKSPACE_ID; // feature visibility section will be hidden in management workspace // permission section will be hidden when permission is not enabled - const [selectedTab, setSelectedTab] = useState( - !isEditingManagementWorkspace - ? WorkspaceFormTabs.FeatureVisibility - : permissionEnabled - ? WorkspaceFormTabs.UsersAndPermissions - : WorkspaceFormTabs.NotSelected - ); + const [selectedTab, setSelectedTab] = useState(WorkspaceFormTabs.FeatureVisibility); const [numberOfErrors, setNumberOfErrors] = useState(0); // The matched feature id list based on original feature config, // the feature category will be expanded to list of feature ids @@ -602,14 +594,12 @@ export const WorkspaceForm = ({ - {!isEditingManagementWorkspace && ( - - {featureVisibilityTitle} - - )} + + {featureVisibilityTitle} + {permissionEnabled && ( - workspace.id !== MANAGEMENT_WORKSPACE_ID && workspace.id !== currentWorkspace?.id - ), + ...workspaceList.filter((workspace) => workspace.id !== currentWorkspace?.id), ].slice(0, 5); } @@ -64,12 +60,7 @@ export const WorkspaceMenu = ({ basePath, getUrlForApp, workspaces, navigateToUr defaultMessage: 'OpenSearch Dashboards', } ); - const managementWorkspaceName = i18n.translate( - 'core.ui.primaryNav.workspacePickerMenu.managementWorkspaceName', - { - defaultMessage: 'Management', - } - ); + const filteredWorkspaceList = getFilteredWorkspaceList(workspaceList, currentWorkspace); const currentWorkspaceName = currentWorkspace?.name ?? defaultHeaderName; @@ -199,17 +190,6 @@ export const WorkspaceMenu = ({ basePath, getUrlForApp, workspaces, navigateToUr icon: 'folderClosed', panel: 1, }, - { - name: managementWorkspaceName, - icon: 'managementApp', - href: formatUrlWithWorkspaceId( - getUrlForApp(WORKSPACE_OVERVIEW_APP_ID, { - absolute: false, - }), - MANAGEMENT_WORKSPACE_ID, - basePath - ), - }, ], }, { diff --git a/src/plugins/workspace/server/integration_tests/routes.test.ts b/src/plugins/workspace/server/integration_tests/routes.test.ts index 101ca824f9f8..d2cebf22b823 100644 --- a/src/plugins/workspace/server/integration_tests/routes.test.ts +++ b/src/plugins/workspace/server/integration_tests/routes.test.ts @@ -233,7 +233,7 @@ describe('workspace service', () => { }) .expect(200); // Global and Management workspace will be created by default after workspace list API called. - expect(listResult.body.result.total).toEqual(4); + expect(listResult.body.result.total).toEqual(3); }); it('unable to perform operations on workspace by calling saved objects APIs', async () => { const result = await osdTestServer.request @@ -296,7 +296,7 @@ describe('workspace service', () => { .expect(200); expect(findResult.body.total).toEqual(0); // Global and Management workspace will be created by default after workspace list API called. - expect(listResult.body.result.total).toEqual(3); + expect(listResult.body.result.total).toEqual(2); }); }); }); diff --git a/src/plugins/workspace/server/workspace_client.ts b/src/plugins/workspace/server/workspace_client.ts index 5d4365854e61..85638eb0c960 100644 --- a/src/plugins/workspace/server/workspace_client.ts +++ b/src/plugins/workspace/server/workspace_client.ts @@ -16,7 +16,6 @@ import type { import { ACL, DEFAULT_APP_CATEGORIES, - MANAGEMENT_WORKSPACE_ID, PUBLIC_WORKSPACE_ID, WORKSPACE_TYPE, WorkspacePermissionMode, @@ -223,35 +222,6 @@ export class WorkspaceClientWithSavedObject implements IWorkspaceClientImpl { publicWorkspaceACL.getPermissions() ); } - private async setupManagementWorkspace(savedObjectClient?: SavedObjectsClientContract) { - const managementWorkspaceACL = new ACL().addPermission( - [WorkspacePermissionMode.LibraryWrite, WorkspacePermissionMode.Write], - { - users: ['*'], - } - ); - const DSM_APP_ID = 'dataSources'; - const DEV_TOOLS_APP_ID = 'dev_tools'; - - return this.checkAndCreateWorkspace( - savedObjectClient, - MANAGEMENT_WORKSPACE_ID, - { - name: i18n.translate('workspaces.management.workspace.default.name', { - defaultMessage: 'Management', - }), - features: [ - `@${DEFAULT_APP_CATEGORIES.management.id}`, - WORKSPACE_OVERVIEW_APP_ID, - WORKSPACE_UPDATE_APP_ID, - DSM_APP_ID, - DEV_TOOLS_APP_ID, - ], - reserved: true, - }, - managementWorkspaceACL.getPermissions() - ); - } public async setup(core: CoreSetup): Promise> { this.setupDep.savedObjects.registerType(workspace); @@ -335,16 +305,6 @@ export class WorkspaceClientWithSavedObject implements IWorkspaceClientImpl { tasks.push(this.setupPublicWorkspace(scopedClientWithoutPermissionCheck)); } - /** - * Setup management workspace if management workspace can not be found - */ - const hasManagementWorkspace = savedObjects.some( - (item) => item.id === MANAGEMENT_WORKSPACE_ID - ); - if (!hasManagementWorkspace) { - tasks.push(this.setupManagementWorkspace(scopedClientWithoutPermissionCheck)); - } - try { await Promise.all(tasks); if (tasks.length) { From c1a4b1e237438dd8668276df93ff709cf13dd3ef Mon Sep 17 00:00:00 2001 From: yubonluo <15242088755@163.com> Date: Tue, 5 Mar 2024 15:52:42 +0800 Subject: [PATCH 2/3] delete unnecessary code comments --- .../public/components/workspace_creator/workspace_form.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx b/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx index 4907470fa330..5aa005fb5cfd 100644 --- a/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx +++ b/src/plugins/workspace/public/components/workspace_creator/workspace_form.tsx @@ -172,8 +172,6 @@ export const WorkspaceForm = ({ const [icon, setIcon] = useState(defaultValues?.icon); const [defaultVISTheme, setDefaultVISTheme] = useState(defaultValues?.defaultVISTheme); - // feature visibility section will be hidden in management workspace - // permission section will be hidden when permission is not enabled const [selectedTab, setSelectedTab] = useState(WorkspaceFormTabs.FeatureVisibility); const [numberOfErrors, setNumberOfErrors] = useState(0); // The matched feature id list based on original feature config, From 9430f40b94dec0cb5425aaec1a1da6fc3ac46dbf Mon Sep 17 00:00:00 2001 From: yubonluo <15242088755@163.com> Date: Wed, 6 Mar 2024 09:52:33 +0800 Subject: [PATCH 3/3] delete comments --- src/plugins/workspace/server/integration_tests/routes.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/workspace/server/integration_tests/routes.test.ts b/src/plugins/workspace/server/integration_tests/routes.test.ts index d2cebf22b823..3a16e1e7d7e5 100644 --- a/src/plugins/workspace/server/integration_tests/routes.test.ts +++ b/src/plugins/workspace/server/integration_tests/routes.test.ts @@ -232,7 +232,7 @@ describe('workspace service', () => { page: 1, }) .expect(200); - // Global and Management workspace will be created by default after workspace list API called. + // Global workspace will be created by default after workspace list API called. expect(listResult.body.result.total).toEqual(3); }); it('unable to perform operations on workspace by calling saved objects APIs', async () => { @@ -295,7 +295,7 @@ describe('workspace service', () => { }) .expect(200); expect(findResult.body.total).toEqual(0); - // Global and Management workspace will be created by default after workspace list API called. + // Global workspace will be created by default after workspace list API called. expect(listResult.body.result.total).toEqual(2); }); });