Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workspace]Register workspace settings under setup and settings #7242

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -150,6 +151,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
15 changes: 14 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,26 @@ export class WorkspacePlugin implements Plugin<{}, {}, WorkspacePluginSetupDeps>
core.application.register({
id: WORKSPACE_LIST_APP_ID,
title: '',
navLinkStatus: AppNavLinkStatus.hidden,
// nav link should be visible when nav group enabled
navLinkStatus: core.chrome.navGroup.getNavGroupEnabled()
? AppNavLinkStatus.visible
: AppNavLinkStatus.hidden,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment of when core.chrome.navGroup.getNavGroupEnabled() changed, the page will refresh and application setup will execute it again?

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
Loading