From f0b347403423261a12fe48dc08c0bdecdc072d24 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 21:42:20 +0800 Subject: [PATCH] [Workspace]Register workspace settings under setup and settings (#7242) (#7258) * Move workspace list under setup and settings nav group * Changeset file for PR #7242 created/updated * Add comment for page refresh --------- (cherry picked from commit dcd4cf6a5593d78e1247a984d766ada64c135be9) Signed-off-by: Lin Wang Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> --- changelogs/fragments/7242.yml | 2 ++ src/plugins/workspace/public/plugin.test.ts | 24 +++++++++++++++++++++ src/plugins/workspace/public/plugin.ts | 19 +++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/7242.yml diff --git a/changelogs/fragments/7242.yml b/changelogs/fragments/7242.yml new file mode 100644 index 000000000000..f857043d811d --- /dev/null +++ b/changelogs/fragments/7242.yml @@ -0,0 +1,2 @@ +feat: +- [Workspace] Register workspace settings under setup and settings ([#7242](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7242)) \ No newline at end of file diff --git a/src/plugins/workspace/public/plugin.test.ts b/src/plugins/workspace/public/plugin.test.ts index eb1d8178ff70..32cb8b492258 100644 --- a/src/plugins/workspace/public/plugin.test.ts +++ b/src/plugins/workspace/public/plugin.test.ts @@ -8,6 +8,7 @@ import { waitFor } from '@testing-library/dom'; import { ChromeBreadcrumb } from 'opensearch-dashboards/public'; import { workspaceClientMock, WorkspaceClientMock } from './workspace_client.mock'; import { applicationServiceMock, chromeServiceMock, coreMock } from '../../../core/public/mocks'; +import { DEFAULT_NAV_GROUPS, AppNavLinkStatus } from '../../../core/public'; import { WorkspacePlugin } from './plugin'; import { WORKSPACE_FATAL_ERROR_APP_ID, WORKSPACE_OVERVIEW_APP_ID } from '../common/constants'; import { savedObjectsManagementPluginMock } from '../../saved_objects_management/public/mocks'; @@ -149,6 +150,29 @@ describe('Workspace plugin', () => { expect(setupMock.chrome.registerCollapsibleNavHeader).toBeCalledTimes(1); }); + it('#setup should register workspace list with a visible application and register to settingsAndSetup nav group', async () => { + const setupMock = coreMock.createSetup(); + setupMock.chrome.navGroup.getNavGroupEnabled.mockReturnValue(true); + const workspacePlugin = new WorkspacePlugin(); + await workspacePlugin.setup(setupMock, {}); + + expect(setupMock.application.register).toHaveBeenCalledWith( + expect.objectContaining({ + id: 'workspace_list', + navLinkStatus: AppNavLinkStatus.visible, + }) + ); + expect(setupMock.chrome.navGroup.addNavLinksToGroup).toHaveBeenCalledWith( + DEFAULT_NAV_GROUPS.settingsAndSetup, + expect.arrayContaining([ + { + id: 'workspace_list', + title: 'workspace settings', + }, + ]) + ); + }); + it('#start add workspace overview page to breadcrumbs when start', async () => { const startMock = coreMock.createStart(); const workspaceObject = { diff --git a/src/plugins/workspace/public/plugin.ts b/src/plugins/workspace/public/plugin.ts index 2fdb385b37c2..0b69b0083718 100644 --- a/src/plugins/workspace/public/plugin.ts +++ b/src/plugins/workspace/public/plugin.ts @@ -20,6 +20,7 @@ import { WorkspaceAvailability, ChromeNavGroupUpdater, NavGroupStatus, + DEFAULT_NAV_GROUPS, } from '../../../core/public'; import { WORKSPACE_FATAL_ERROR_APP_ID, @@ -318,7 +319,14 @@ export class WorkspacePlugin implements Plugin<{}, {}, WorkspacePluginSetupDeps> core.application.register({ id: WORKSPACE_LIST_APP_ID, title: '', - navLinkStatus: AppNavLinkStatus.hidden, + /** + * Nav link status should be visible when nav group enabled. + * The page should be refreshed and all applications need to register again + * after nav group enabled changed. + */ + navLinkStatus: core.chrome.navGroup.getNavGroupEnabled() + ? AppNavLinkStatus.visible + : AppNavLinkStatus.hidden, async mount(params: AppMountParameters) { const { renderListApp } = await import('./application'); return mountWorkspaceApp(params, renderListApp); @@ -326,6 +334,15 @@ export class WorkspacePlugin implements Plugin<{}, {}, WorkspacePluginSetupDeps> workspaceAvailability: WorkspaceAvailability.outsideWorkspace, }); + core.chrome.navGroup.addNavLinksToGroup(DEFAULT_NAV_GROUPS.settingsAndSetup, [ + { + id: WORKSPACE_LIST_APP_ID, + title: i18n.translate('workspace.settingsAndSetup.workspaceSettings', { + defaultMessage: 'workspace settings', + }), + }, + ]); + /** * register workspace column into saved objects table */