Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
Signed-off-by: yubonluo <yubonluo@amazon.com>
  • Loading branch information
yubonluo committed Apr 15, 2024
1 parent d176011 commit 991971e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/plugins/opensearch_dashboards_overview/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ export class OpenSearchDashboardsOverviewPlugin
return {
status: AppStatus.inaccessible,
navLinkStatus: AppNavLinkStatus.hidden,
workspaceless: true,
workspaceAccessibility: WorkspaceAccessibility.NO,
};
} else {
return {
status: AppStatus.accessible,
navLinkStatus: AppNavLinkStatus.default,
workspaceless: true,
workspaceAccessibility: WorkspaceAccessibility.NO,
};
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/workspace/public/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('workspace utils: getSelectedFeatureQuantities', () => {
navLinkStatus: 1,
order: -2000,
status: 0,
workspaceless: true,
workspaceAccessibility: WorkspaceAccessibility.NO,
},
] as PublicAppInfo[];
it('should support * rules and exclude management category', () => {
Expand Down
20 changes: 12 additions & 8 deletions src/plugins/workspace/public/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,19 @@ export const featureMatchesConfig = (featureConfigs: string[]) => ({

// Get all apps excluding management category
export const getAllExcludingManagementApps = (applications: PublicAppInfo[]): PublicAppInfo[] => {
return applications.filter(({ navLinkStatus, chromeless, category, workspaceless, id }) => {
const filterCondition =
navLinkStatus !== AppNavLinkStatus.hidden && !chromeless && !workspaceless;
if (category?.id === DEFAULT_APP_CATEGORIES.management.id) {
return filterCondition && id === 'management';
} else {
return filterCondition;
return applications.filter(
({ navLinkStatus, chromeless, category, workspaceAccessibility, id }) => {
const filterCondition =
navLinkStatus !== AppNavLinkStatus.hidden &&
!chromeless &&
workspaceAccessibility !== WorkspaceAccessibility.NO;
if (category?.id === DEFAULT_APP_CATEGORIES.management.id) {
return filterCondition && id === 'management';
} else {
return filterCondition;
}
}
});
);
};

export const getSelectedFeatureQuantities = (
Expand Down

0 comments on commit 991971e

Please sign in to comment.