Skip to content

Commit

Permalink
[Workspace] Make dashboards management available (#6575)
Browse files Browse the repository at this point in the history
* [Workspace] Make dashboards management available

Signed-off-by: yubonluo <yubonluo@amazon.com>

* [Workspace] optimize the code

Signed-off-by: yubonluo <yubonluo@amazon.com>

* [Workspace] optimize the code

Signed-off-by: yubonluo <yubonluo@amazon.com>

* [Workspace] modify requiredPlugins

Signed-off-by: yubonluo <yubonluo@amazon.com>

* Changeset file for PR #6575 created/updated

* [Workspace] add more comments

Signed-off-by: yubonluo <yubonluo@amazon.com>

* [Workspace] delete useless code

Signed-off-by: yubonluo <yubonluo@amazon.com>

* [Workspace] delete useless code

Signed-off-by: yubonluo <yubonluo@amazon.com>

---------

Signed-off-by: yubonluo <yubonluo@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 8db9688)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 7d6d7d0 commit 4e35fdd
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 4e35fdd

Please sign in to comment.