From cf8f9886c2b4bace4118a75e97a447e2f7ff6422 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 25 Apr 2024 02:12:24 +0000 Subject: [PATCH] [Workspace] Hide dashboard overview (#6625) * feat: hide dashboard overview Signed-off-by: yubonluo * Changeset file for PR #6625 created/updated * Changeset file for PR #6625 created/updated --------- Signed-off-by: yubonluo Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit 17ce31467586e419a0075239af5e39c75b3cdb1f) Signed-off-by: github-actions[bot] --- changelogs/fragments/6625.yml | 2 ++ src/plugins/workspace/public/utils.test.ts | 6 +++--- src/plugins/workspace/public/utils.ts | 25 ++++++++++++---------- 3 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/6625.yml diff --git a/changelogs/fragments/6625.yml b/changelogs/fragments/6625.yml new file mode 100644 index 000000000000..cd5e6e8ead0a --- /dev/null +++ b/changelogs/fragments/6625.yml @@ -0,0 +1,2 @@ +feat: +- [Workspace] Hide dashboard overview ([#6625](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6625)) \ No newline at end of file diff --git a/src/plugins/workspace/public/utils.test.ts b/src/plugins/workspace/public/utils.test.ts index 5471abace56d..c68dc844da2e 100644 --- a/src/plugins/workspace/public/utils.test.ts +++ b/src/plugins/workspace/public/utils.test.ts @@ -238,6 +238,7 @@ describe('workspace utils: filterWorkspaceConfigurableApps', () => { navLinkStatus: 1, order: -2000, status: 0, + workspaceAvailability: WorkspaceAvailability.outsideWorkspace, }, { appRoute: '/app/management', @@ -255,9 +256,8 @@ describe('workspace utils: filterWorkspaceConfigurableApps', () => { ] as PublicAppInfo[]; it('should filters out apps that are not accessible in the workspace', () => { const filteredApps = filterWorkspaceConfigurableApps(defaultApplications); - expect(filteredApps.length).toEqual(3); + expect(filteredApps.length).toEqual(2); expect(filteredApps[0].id).toEqual('dashboards'); - expect(filteredApps[1].id).toEqual('opensearchDashboardsOverview'); - expect(filteredApps[2].id).toEqual('management'); + expect(filteredApps[1].id).toEqual('management'); }); }); diff --git a/src/plugins/workspace/public/utils.ts b/src/plugins/workspace/public/utils.ts index c39c1e6d5958..ba9ab5399e21 100644 --- a/src/plugins/workspace/public/utils.ts +++ b/src/plugins/workspace/public/utils.ts @@ -118,18 +118,21 @@ export function isAppAccessibleInWorkspace(app: App, workspace: WorkspaceObject) // Get all apps that should be displayed in workspace when create/update a workspace. export const filterWorkspaceConfigurableApps = (applications: PublicAppInfo[]) => { - const visibleApplications = applications.filter(({ navLinkStatus, chromeless, category, id }) => { - const filterCondition = - navLinkStatus !== AppNavLinkStatus.hidden && - !chromeless && - !DEFAULT_SELECTED_FEATURES_IDS.includes(id); - // If the category is management, only retain Dashboards Management which contains saved objets and index patterns. - // Saved objets can show all saved objects in the current workspace and index patterns is at workspace level. - if (category?.id === DEFAULT_APP_CATEGORIES.management.id) { - return filterCondition && id === 'management'; + const visibleApplications = applications.filter( + ({ navLinkStatus, chromeless, category, id, workspaceAvailability }) => { + const filterCondition = + navLinkStatus !== AppNavLinkStatus.hidden && + !chromeless && + !DEFAULT_SELECTED_FEATURES_IDS.includes(id) && + workspaceAvailability !== WorkspaceAvailability.outsideWorkspace; + // If the category is management, only retain Dashboards Management which contains saved objets and index patterns. + // Saved objets can show all saved objects in the current workspace and index patterns is at workspace level. + if (category?.id === DEFAULT_APP_CATEGORIES.management.id) { + return filterCondition && id === 'management'; + } + return filterCondition; } - return filterCondition; - }); + ); return visibleApplications; };