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 146b95582482..98e832bb9b5d 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 */