Skip to content

Commit

Permalink
side nav changes for SA (#1084)
Browse files Browse the repository at this point in the history
* side nac changes for SA

Signed-off-by: Riya Saxena <[email protected]>

* changed category from configure to detect

Signed-off-by: Riya Saxena <[email protected]>

* side nav changes for SA

Signed-off-by: Riya Saxena <[email protected]>

* side nav changes for SA

Signed-off-by: Riya Saxena <[email protected]>

* Update public/plugin.ts

Co-authored-by: SuZhou-Joe <[email protected]>
Signed-off-by: Riya <[email protected]>

* Update public/plugin.ts

Co-authored-by: SuZhou-Joe <[email protected]>
Signed-off-by: Riya <[email protected]>

* Update public/plugin.ts

Co-authored-by: SuZhou-Joe <[email protected]>
Signed-off-by: Riya <[email protected]>

* Update public/plugin.ts

Co-authored-by: SuZhou-Joe <[email protected]>
Signed-off-by: Riya <[email protected]>

* Update public/plugin.ts

Co-authored-by: SuZhou-Joe <[email protected]>
Signed-off-by: Riya <[email protected]>

* Update public/utils/constants.ts

Co-authored-by: SuZhou-Joe <[email protected]>
Signed-off-by: Riya <[email protected]>

* side nav changes for SA

Signed-off-by: Riya Saxena <[email protected]>

---------

Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya <[email protected]>
Co-authored-by: SuZhou-Joe <[email protected]>
  • Loading branch information
riysaxen-amzn and SuZhou-Joe authored Jul 22, 2024
1 parent f34835a commit 4e3a06b
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 1 deletion.
1 change: 1 addition & 0 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ export default class Main extends Component<MainProps, MainState> {
<EuiPage restrictWidth={'100%'}>
{/* Hide side navigation bar when on any HIDDEN_NAV_ROUTES pages. */}
{!HIDDEN_NAV_ROUTES.some((route) => pathname.match(route)) && (
!core.chrome.navGroup.getNavGroupEnabled() &&
<EuiPageSideBar style={{ minWidth: 200 }}>
<EuiSideNav style={{ width: 200 }} items={sideNav} />
</EuiPageSideBar>
Expand Down
128 changes: 127 additions & 1 deletion public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import {
AppMountParameters,
CoreSetup,
CoreStart,
DEFAULT_APP_CATEGORIES,
DEFAULT_NAV_GROUPS,
Plugin,
PluginInitializerContext,
WorkspaceAvailability,
} from '../../../src/core/public';
import { PLUGIN_NAME, ROUTES, setDarkMode } from './utils/constants';
import { CORRELATIONS_NAV_ID, CORRELATIONS_RULE_NAV_ID, DETECTORS_NAV_ID, DETECTORS_RULE_NAV_ID, FINDINGS_NAV_ID, LOG_TYPES_NAV_ID, PLUGIN_NAME, ROUTES, THREAT_ALERTS_NAV_ID, THREAT_INTEL_NAV_ID, setDarkMode } from './utils/constants';
import { SecurityAnalyticsPluginSetup, SecurityAnalyticsPluginStart } from './index';
import { DataPublicPluginStart, DataPublicPluginSetup } from '../../../src/plugins/data/public';
import { SecurityAnalyticsPluginConfigType } from '../config';
Expand Down Expand Up @@ -43,6 +46,13 @@ export class SecurityAnalyticsPlugin
core: CoreSetup<SecurityAnalyticsPluginStartDeps>,
{ dataSourceManagement }: SecurityAnalyticsPluginSetupDeps
): SecurityAnalyticsPluginSetup {

const mountWrapper = async (params: AppMountParameters, redirect: string) => {
const { renderApp } = await import("./security_analytics_app");
const [coreStart, depsStart] = await core.getStartServices();
return renderApp(coreStart, params, redirect, depsStart, dataSourceManagement);
};

core.application.register({
id: PLUGIN_NAME,
title: 'Security Analytics',
Expand All @@ -52,12 +62,128 @@ export class SecurityAnalyticsPlugin
label: 'OpenSearch Plugins',
order: 2000,
},
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
const { renderApp } = await import('./security_analytics_app');
const [coreStart, depsStart] = await core.getStartServices();
return renderApp(coreStart, params, ROUTES.LANDING_PAGE, depsStart, dataSourceManagement);
},
});

if (core.chrome.navGroup.getNavGroupEnabled()) {

// register investigate and configure routes
core.application.register({
id: THREAT_ALERTS_NAV_ID,
title: 'Threat alerts',
order: 9070,
category: DEFAULT_APP_CATEGORIES.investigate,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.ALERTS);
},
});

core.application.register({
id: FINDINGS_NAV_ID,
title: 'Findings',
order: 9080,
category: DEFAULT_APP_CATEGORIES.investigate,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.FINDINGS);
},
});

core.application.register({
id: CORRELATIONS_NAV_ID,
title: 'Correlations',
order: 9080,
category: DEFAULT_APP_CATEGORIES.investigate,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.CORRELATIONS);
},
});

core.application.register({
id: DETECTORS_NAV_ID,
title: 'Threat detectors',
order: 9080,
category: DEFAULT_APP_CATEGORIES.configure,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.DETECTORS);
},
});

core.application.register({
id: DETECTORS_RULE_NAV_ID,
title: 'Detection rules',
order: 9080,
category: DEFAULT_APP_CATEGORIES.configure,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.RULES);
},
});

core.application.register({
id: CORRELATIONS_RULE_NAV_ID,
title: 'Correlation rules',
order: 9080,
category: DEFAULT_APP_CATEGORIES.detect,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.CORRELATION_RULES);
},
});

core.application.register({
id: THREAT_INTEL_NAV_ID,
title: 'Threat intelligence',
order: 9080,
category: DEFAULT_APP_CATEGORIES.configure,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.THREAT_INTEL_OVERVIEW);
},
});

core.application.register({
id: LOG_TYPES_NAV_ID,
title: 'Log types',
order: 9080,
category: DEFAULT_APP_CATEGORIES.configure,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.LOG_TYPES);
},
});

const navlinks = [
{ id: THREAT_ALERTS_NAV_ID, showInAllNavGroup: true },
{ id: FINDINGS_NAV_ID, showInAllNavGroup: true },
{ id: CORRELATIONS_NAV_ID },
{ id: DETECTORS_NAV_ID },
{ id: DETECTORS_RULE_NAV_ID, parent: DETECTORS_NAV_ID },
{ id: CORRELATIONS_RULE_NAV_ID },
{ id: THREAT_INTEL_NAV_ID},
{ id: LOG_TYPES_NAV_ID }
]

const navLinks = navlinks.map(item => ({
id: item.id,
showInAllNavGroup: item. showInAllNavGroup,
parentNavLinkId: item.parent ? item.parent : undefined,
}));

core.chrome.navGroup.addNavLinksToGroup(
DEFAULT_NAV_GROUPS['security-analytics'],
navLinks
);
}

setDarkMode(core.uiSettings.get('theme:darkMode'));

const config = this.initializerContext.config.get();
Expand Down
8 changes: 8 additions & 0 deletions public/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ export const PLUGIN_NAME = 'opensearch_security_analytics_dashboards';
export const OS_NOTIFICATION_PLUGIN = 'opensearch-notifications';

export const DEFAULT_EMPTY_DATA = '-';
export const THREAT_ALERTS_NAV_ID = `threat_alerts`;
export const FINDINGS_NAV_ID = `findings`;
export const CORRELATIONS_NAV_ID = `correlations`;
export const DETECTORS_NAV_ID = `detectors`;
export const DETECTORS_RULE_NAV_ID = `detectors_rules`;
export const CORRELATIONS_RULE_NAV_ID = `correlation_rules`;
export const THREAT_INTEL_NAV_ID = `threat_intelligence`;
export const LOG_TYPES_NAV_ID = `log_types`;

export let isDarkMode: boolean = false;

Expand Down

0 comments on commit 4e3a06b

Please sign in to comment.