Skip to content

Commit

Permalink
side nav changes
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <[email protected]>
  • Loading branch information
riysaxen-amzn committed Jul 18, 2024
1 parent 70dfcc8 commit a49dfde
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 55 deletions.
129 changes: 74 additions & 55 deletions public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { PLUGIN_NAME } from '../utils/constants';
import { ALERTS_NAV_ID, DESTINATIONS_NAV_ID, MONITORS_NAV_ID, PLUGIN_NAME } from '../utils/constants';
import {
Plugin,
CoreSetup,
CoreStart,
DEFAULT_NAV_GROUPS,
WorkspaceAvailability,
AppMountParameters,
DEFAULT_APP_CATEGORIES,
} from '../../../src/core/public';
import { ACTION_ALERTING } from './actions/alerting_dashboard_action';
import { CONTEXT_MENU_TRIGGER, EmbeddableStart } from '../../../src/plugins/embeddable/public';
Expand Down Expand Up @@ -48,9 +49,9 @@ export interface AlertingStartDeps {
data: DataPublicPluginStart;
}

export class AlertingPlugin implements Plugin<AlertingSetup, AlertingStart, AlertingSetupDeps, AlertingStartDeps> {
export class AlertingPlugin implements Plugin<void, AlertingStart, AlertingSetupDeps, AlertingStartDeps> {

public setup(core: CoreSetup<AlertingStartDeps, AlertingStart>, { expressions, uiActions, dataSourceManagement, dataSource }: AlertingSetupDeps): AlertingSetup {
public setup(core: CoreSetup<AlertingStartDeps, AlertingStart>, { expressions, uiActions, dataSourceManagement, dataSource }: AlertingSetupDeps) {

const mountWrapper = async (params: AppMountParameters, redirect: string) => {
const { renderApp } = await import("./app");
Expand All @@ -72,90 +73,110 @@ export class AlertingPlugin implements Plugin<AlertingSetup, AlertingStart, Aler
mount: async (params) => {
const { renderApp } = await import('./app');
const [coreStart] = await core.getStartServices();
return renderApp(coreStart, params, "dashboard");
return renderApp(coreStart, params);
},
});

setUISettings(core.uiSettings);

// Set the HTTP client so it can be pulled into expression fns to make
// direct server-side calls
setClient(core.http);

setDataSourceManagementPlugin(dataSourceManagement);

const enabled = !!dataSource;

setDataSourceEnabled({ enabled });

// registers the expression function used to render anomalies on an Augmented Visualization
expressions.registerFunction(overlayAlertsFunction(enabled));

// Create context menu actions. Pass core, to access service for flyouts.
const actions = getActions();

// Add actions to uiActions
actions.forEach((action) => {
uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, action);
});

// Create trigger for other plugins to open flyout. Can be used by other plugins like this:
const adAction = getAdAction();
uiActions.registerTrigger(alertingTriggerAd);
uiActions.addTriggerAction(alertingTriggerAd.id, adAction);

if (core.chrome.navGroup.getNavGroupEnabled()) {
const navLink = {
id: PLUGIN_NAME,
category: DEFAULT_APP_CATEGORIES.detect,
showInAllNavGroup: true
};
// register applications with category and use case information
core.chrome.navGroup.addNavLinksToGroup(DEFAULT_NAV_GROUPS.observability,[
navLink
])
core.chrome.navGroup.addNavLinksToGroup(DEFAULT_NAV_GROUPS['security-analytics'],[
navLink
])

// channels route
core.application.register({
id: `alerts`,
id: ALERTS_NAV_ID,
title: 'Alerts',
order: 9070,
category: DEFAULT_APP_CATEGORIES.detect,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, "/dashboard");
},
});

core.application.register({
id: `monitors`,
id: MONITORS_NAV_ID,
title: 'Monitors',
order: 9070,
category: DEFAULT_APP_CATEGORIES.detect,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, "/monitors");
},
});

core.application.register({
id: `destinations`,
id: DESTINATIONS_NAV_ID,
title: 'Destinations',
order: 9070,
category: DEFAULT_APP_CATEGORIES.detect,
workspaceAvailability: WorkspaceAvailability.outsideWorkspace,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, "/destinations");
},
});

const navLinks = [
{
id: ALERTS_NAV_ID,
parentNavLinkId: PLUGIN_NAME,
},
{
id: MONITORS_NAV_ID,
parentNavLinkId: PLUGIN_NAME,
},
{
id: DESTINATIONS_NAV_ID,
parentNavLinkId: PLUGIN_NAME,
},
];
core.chrome.navGroup.addNavLinksToGroup(
DEFAULT_NAV_GROUPS['security-analytics'],
navLinks
);

core.chrome.navGroup.addNavLinksToGroup(
DEFAULT_NAV_GROUPS.observability,
[
{
id: PLUGIN_NAME,
},
{
id: `alerts`,
parentNavLinkId: PLUGIN_NAME
},
{
id: `monitors`,
parentNavLinkId: PLUGIN_NAME
},
{
id: `destinations`,
parentNavLinkId: PLUGIN_NAME
},

]
navLinks
);
}

setUISettings(core.uiSettings);

// Set the HTTP client so it can be pulled into expression fns to make
// direct server-side calls
setClient(core.http);

setDataSourceManagementPlugin(dataSourceManagement);

const enabled = !!dataSource;

setDataSourceEnabled({ enabled });

// registers the expression function used to render anomalies on an Augmented Visualization
expressions.registerFunction(overlayAlertsFunction(enabled));

// Create context menu actions. Pass core, to access service for flyouts.
const actions = getActions();

// Add actions to uiActions
actions.forEach((action) => {
uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, action);
});

// Create trigger for other plugins to open flyout. Can be used by other plugins like this:
const adAction = getAdAction();
uiActions.registerTrigger(alertingTriggerAd);
uiActions.addTriggerAction(alertingTriggerAd.id, adAction);
}

public start(core: CoreStart, { visAugmenter, embeddable, data }: AlertingStartDeps): AlertingStart {
Expand All @@ -167,6 +188,4 @@ export class AlertingPlugin implements Plugin<AlertingSetup, AlertingStart, Aler
setSavedObjectsClient(core.savedObjects.client);
return {};
}

public stop() {}
}
3 changes: 3 additions & 0 deletions utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ export const URL = {

export const MAX_THROTTLE_VALUE = 1440;
export const WRONG_THROTTLE_WARNING = `Throttle value must be greater than 0 and less than ${MAX_THROTTLE_VALUE}.`;
export const ALERTS_NAV_ID = `alerts`;
export const DESTINATIONS_NAV_ID = `destinations`;
export const MONITORS_NAV_ID = `monitors`;

0 comments on commit a49dfde

Please sign in to comment.