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

[Backport 2.x] [Workspace]Register workspace settings under setup and settings #7258

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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
Loading