From 64b364545164ac3da2e43189ec060ad72f4a559b Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Fri, 8 Mar 2024 09:06:51 +0800 Subject: [PATCH] feat: add feature flag check Signed-off-by: SuZhou-Joe --- src/core/public/http/http_service.ts | 11 ++++++++--- src/plugins/workspace/opensearch_dashboards.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/public/http/http_service.ts b/src/core/public/http/http_service.ts index c2caf18be880..0c9758b6525f 100644 --- a/src/core/public/http/http_service.ts +++ b/src/core/public/http/http_service.ts @@ -53,9 +53,14 @@ export class HttpService implements CoreService { public setup({ injectedMetadata, fatalErrors }: HttpDeps): HttpSetup { const opensearchDashboardsVersion = injectedMetadata.getOpenSearchDashboardsVersion(); let workspaceBasePath = ''; - const workspaceId = getWorkspaceIdFromUrl(window.location.href); - if (workspaceId) { - workspaceBasePath = `${WORKSPACE_PATH_PREFIX}/${workspaceId}`; + const plugins = injectedMetadata.getPlugins(); + const findWorkspaceConfig = plugins.find((plugin) => plugin.id === 'workspace'); + // Only try to get workspace id from url when workspace feature is enabled + if (findWorkspaceConfig) { + const workspaceId = getWorkspaceIdFromUrl(window.location.href); + if (workspaceId) { + workspaceBasePath = `${WORKSPACE_PATH_PREFIX}/${workspaceId}`; + } } const basePath = new BasePath( injectedMetadata.getBasePath(), diff --git a/src/plugins/workspace/opensearch_dashboards.json b/src/plugins/workspace/opensearch_dashboards.json index 6a01faa2f76d..4443b7e99834 100644 --- a/src/plugins/workspace/opensearch_dashboards.json +++ b/src/plugins/workspace/opensearch_dashboards.json @@ -2,7 +2,7 @@ "id": "workspace", "version": "opensearchDashboards", "server": true, - "ui": false, + "ui": true, "requiredPlugins": [ "savedObjects" ],