Skip to content

Commit

Permalink
[Workspace]Register workspace settings under setup and settings (#7242)
Browse files Browse the repository at this point in the history
* Move workspace list under setup and settings nav group

Signed-off-by: Lin Wang <[email protected]>

* Changeset file for PR #7242 created/updated

* Add comment for page refresh

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit dcd4cf6)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 6e5ee91 commit b272445
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/7242.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [Workspace] Register workspace settings under setup and settings ([#7242](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7242))
24 changes: 24 additions & 0 deletions src/plugins/workspace/public/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 = {
Expand Down
19 changes: 18 additions & 1 deletion src/plugins/workspace/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
WorkspaceAvailability,
ChromeNavGroupUpdater,
NavGroupStatus,
DEFAULT_NAV_GROUPS,
} from '../../../core/public';
import {
WORKSPACE_FATAL_ERROR_APP_ID,
Expand Down Expand Up @@ -318,14 +319,30 @@ 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);
},
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
*/
Expand Down

0 comments on commit b272445

Please sign in to comment.