Skip to content

Commit

Permalink
Merge branch 'main' into feature/data-selector-enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
mengweieric authored Apr 22, 2024
2 parents 94b451a + 8db9688 commit 535f64d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 6 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/6575.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [Workspace] Make dashboards management available ([#6575](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6575))
73 changes: 71 additions & 2 deletions src/plugins/workspace/public/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { AppNavLinkStatus } from '../../../core/public';
import { featureMatchesConfig, isAppAccessibleInWorkspace } from './utils';
import { AppNavLinkStatus, PublicAppInfo } from '../../../core/public';
import {
featureMatchesConfig,
filterWorkspaceConfigurableApps,
isAppAccessibleInWorkspace,
} from './utils';

describe('workspace utils: featureMatchesConfig', () => {
it('feature configured with `*` should match any features', () => {
Expand Down Expand Up @@ -149,3 +153,68 @@ describe('workspace utils: isAppAccessibleInWorkspace', () => {
).toBe(true);
});
});

describe('workspace utils: filterWorkspaceConfigurableApps', () => {
const defaultApplications = [
{
appRoute: '/app/dashboards',
id: 'dashboards',
title: 'Dashboards',
category: {
id: 'opensearchDashboards',
label: 'OpenSearch Dashboards',
euiIconType: 'inputOutput',
order: 1000,
},
status: 0,
navLinkStatus: 1,
},
{
appRoute: '/app/dev_tools',
id: 'dev_tools',
title: 'Dev Tools',
category: {
id: 'management',
label: 'Management',
order: 5000,
euiIconType: 'managementApp',
},
status: 0,
navLinkStatus: 1,
},
{
appRoute: '/app/opensearch_dashboards_overview',
id: 'opensearchDashboardsOverview',
title: 'Overview',
category: {
id: 'opensearchDashboards',
label: 'Library',
euiIconType: 'inputOutput',
order: 1000,
},
navLinkStatus: 1,
order: -2000,
status: 0,
},
{
appRoute: '/app/management',
id: 'management',
title: 'Dashboards Management',
category: {
id: 'management',
label: 'Management',
order: 5000,
euiIconType: 'managementApp',
},
status: 0,
navLinkStatus: 1,
},
] as PublicAppInfo[];
it('should filters out apps that are not accessible in the workspace', () => {
const filteredApps = filterWorkspaceConfigurableApps(defaultApplications);
expect(filteredApps.length).toEqual(3);
expect(filteredApps[0].id).toEqual('dashboards');
expect(filteredApps[1].id).toEqual('opensearchDashboardsOverview');
expect(filteredApps[2].id).toEqual('management');
});
});
13 changes: 9 additions & 4 deletions src/plugins/workspace/public/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,19 @@ export function isAppAccessibleInWorkspace(app: App, workspace: WorkspaceObject)
return false;
}

// Get all apps that should be displayed in workspace when create/update a workspace.
export const filterWorkspaceConfigurableApps = (applications: PublicAppInfo[]) => {
const visibleApplications = applications.filter(({ navLinkStatus, chromeless, category, id }) => {
return (
const filterCondition =
navLinkStatus !== AppNavLinkStatus.hidden &&
!chromeless &&
!DEFAULT_SELECTED_FEATURES_IDS.includes(id) &&
category?.id !== DEFAULT_APP_CATEGORIES.management.id
);
!DEFAULT_SELECTED_FEATURES_IDS.includes(id);
// If the category is management, only retain Dashboards Management which contains saved objets and index patterns.
// Saved objets can show all saved objects in the current workspace and index patterns is at workspace level.
if (category?.id === DEFAULT_APP_CATEGORIES.management.id) {
return filterCondition && id === 'management';
}
return filterCondition;
});

return visibleApplications;
Expand Down

0 comments on commit 535f64d

Please sign in to comment.