Skip to content

Commit

Permalink
Refactor SideMenu component in Settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Oct 4, 2024
1 parent b559696 commit 54cd188
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 117 deletions.
63 changes: 29 additions & 34 deletions Common/Server/Utils/Monitor/MonitorResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ export default class MonitorResourceUtil {
public static async monitorResource(
dataToProcess: DataToProcess,
): Promise<ProbeApiIngestResponse> {
debugger;

let response: ProbeApiIngestResponse = {
monitorId: dataToProcess.monitorId,
criteriaMetId: undefined,
Expand Down Expand Up @@ -432,40 +430,37 @@ export default class MonitorResourceUtil {
);
}

const monitorStatusTimeline: MonitorStatusTimeline | null =
await MonitorStatusTimelineUtil.getNewMonitorStatusTimeline({
monitor: monitor,
rootCause: response.rootCause,
dataToProcess: dataToProcess,
criteriaInstance: criteriaInstanceMap[response.criteriaMetId!]!,
props: {
telemetryQuery: telemetryQuery,
},
});
await MonitorStatusTimelineUtil.updateMonitorStatusTimeline({
monitor: monitor,
rootCause: response.rootCause,
dataToProcess: dataToProcess,
criteriaInstance: criteriaInstanceMap[response.criteriaMetId!]!,
props: {
telemetryQuery: telemetryQuery,
},
});

if (monitorStatusTimeline) {
await MonitorIncident.criteriaMetCreateIncidentsAndUpdateMonitorStatus({
monitor: monitor,
rootCause: response.rootCause,
dataToProcess: dataToProcess,
autoResolveCriteriaInstanceIdIncidentIdsDictionary,
criteriaInstance: criteriaInstanceMap[response.criteriaMetId!]!,
props: {
telemetryQuery: telemetryQuery,
},
});
await MonitorIncident.criteriaMetCreateIncidentsAndUpdateMonitorStatus({
monitor: monitor,
rootCause: response.rootCause,
dataToProcess: dataToProcess,
autoResolveCriteriaInstanceIdIncidentIdsDictionary,
criteriaInstance: criteriaInstanceMap[response.criteriaMetId!]!,
props: {
telemetryQuery: telemetryQuery,
},
});

await MonitorAlert.criteriaMetCreateAlertsAndUpdateMonitorStatus({
monitor: monitor,
rootCause: response.rootCause,
dataToProcess: dataToProcess,
autoResolveCriteriaInstanceIdAlertIdsDictionary,
criteriaInstance: criteriaInstanceAlertMap[response.criteriaMetId!]!,
props: {
telemetryQuery: telemetryQuery,
},
});
}
await MonitorAlert.criteriaMetCreateAlertsAndUpdateMonitorStatus({
monitor: monitor,
rootCause: response.rootCause,
dataToProcess: dataToProcess,
autoResolveCriteriaInstanceIdAlertIdsDictionary,
criteriaInstance: criteriaInstanceAlertMap[response.criteriaMetId!]!,
props: {
telemetryQuery: telemetryQuery,
},
});
} else if (
!response.criteriaMetId &&
monitorSteps.data.defaultMonitorStatusId &&
Expand Down
2 changes: 1 addition & 1 deletion Common/Server/Utils/Monitor/MonitorStatusTimeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import logger from "../Logger";
import DataToProcess from "./DataToProcess";

export default class MonitorStatusTimelineUtil {
public static async getNewMonitorStatusTimeline(input: {
public static async updateMonitorStatusTimeline(input: {
criteriaInstance: MonitorCriteriaInstance;
monitor: Monitor;
dataToProcess: DataToProcess;
Expand Down
4 changes: 1 addition & 3 deletions Dashboard/src/Components/Alert/AlertsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ const AlertsTable: FunctionComponent<ComponentProps> = (
noItemsMessage={props.noItemsMessage || "No alerts found."}
showRefreshButton={true}
showViewIdButton={true}
viewPageRoute={RouteUtil.populateRouteParams(
RouteMap[PageMap.ALERTS]!,
)}
viewPageRoute={RouteUtil.populateRouteParams(RouteMap[PageMap.ALERTS]!)}
filters={[
{
title: "Alert ID",
Expand Down
4 changes: 2 additions & 2 deletions Dashboard/src/Pages/Settings/AlertNoteTemplates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const AlertNoteTemplates: FunctionComponent<PageComponentProps> = (
isCreateable={true}
isViewable={true}
cardProps={{
title: "Public or Private Note Templates for Alerts",
title: "Private Note Templates for Alerts",
description:
"Here is a list of all the public and private note templates for alerts.",
"Here is a list of all the private note templates for alerts.",
}}
noItemsMessage={"No note templates found."}
query={{
Expand Down
4 changes: 1 addition & 3 deletions Dashboard/src/Pages/Settings/AlertState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import Navigation from "Common/UI/Utils/Navigation";
import AlertState from "Common/Models/DatabaseModels/AlertState";
import React, { Fragment, FunctionComponent, ReactElement } from "react";

const AlertsPage: FunctionComponent<
PageComponentProps
> = (): ReactElement => {
const AlertsPage: FunctionComponent<PageComponentProps> = (): ReactElement => {
return (
<Fragment>
<ModelTable<AlertState>
Expand Down
2 changes: 1 addition & 1 deletion Dashboard/src/Pages/Settings/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const DashboardSideMenu: () => JSX.Element = (): ReactElement => {
}}
icon={IconProp.Alert}
/>

<SideMenuItem
link={{
title: "Note Templates",
Expand Down
44 changes: 13 additions & 31 deletions Dashboard/src/Routes/SettingsRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,16 @@ const SettingsMonitors: LazyExoticComponent<FunctionComponent<ComponentProps>> =
return import("../Pages/Settings/MonitorStatus");
});


const SettingsIncidents: LazyExoticComponent<
const SettingsIncidents: LazyExoticComponent<
FunctionComponent<ComponentProps>
> = lazy(() => {
return import("../Pages/Settings/IncidentState");
});


const SettingsAlerts: LazyExoticComponent<
FunctionComponent<ComponentProps>
> = lazy(() => {
return import("../Pages/Settings/AlertState");
});

const SettingsAlerts: LazyExoticComponent<FunctionComponent<ComponentProps>> =
lazy(() => {
return import("../Pages/Settings/AlertState");
});

const SettingsAlertSeverity: LazyExoticComponent<
FunctionComponent<ComponentProps>
Expand All @@ -120,7 +116,6 @@ const AlertCustomFields: LazyExoticComponent<
return import("../Pages/Settings/AlertCustomFields");
});


const AlertNoteTemplates: LazyExoticComponent<
FunctionComponent<ComponentProps>
> = lazy(() => {
Expand Down Expand Up @@ -227,7 +222,6 @@ const ScheduledMaintenanceCustomFields: LazyExoticComponent<
return import("../Pages/Settings/ScheduledMaintenanceCusomFields");
});


const ScheduledMaintenanceNoteTemplates: LazyExoticComponent<
FunctionComponent<ComponentProps>
> = lazy(() => {
Expand Down Expand Up @@ -293,8 +287,6 @@ const SettingsRoutes: FunctionComponent<ComponentProps> = (
}
/>



<PageRoute
path={RouteUtil.getLastPathForKey(
PageMap.SETTINGS_INCIDENT_TEMPLATES_VIEW,
Expand Down Expand Up @@ -389,8 +381,7 @@ const SettingsRoutes: FunctionComponent<ComponentProps> = (
}
/>


<PageRoute
<PageRoute
path={RouteUtil.getLastPathForKey(
PageMap.SETTINGS_ALERT_NOTE_TEMPLATES,
)}
Expand Down Expand Up @@ -425,7 +416,7 @@ const SettingsRoutes: FunctionComponent<ComponentProps> = (
}
/>

<PageRoute
<PageRoute
path={RouteUtil.getLastPathForKey(
PageMap.SETTINGS_ALERT_NOTE_TEMPLATES_VIEW,
2,
Expand All @@ -435,9 +426,7 @@ const SettingsRoutes: FunctionComponent<ComponentProps> = (
<AlertNoteTemplateView
{...props}
pageRoute={
RouteMap[
PageMap.SETTINGS_ALERT_NOTE_TEMPLATES_VIEW
] as Route
RouteMap[PageMap.SETTINGS_ALERT_NOTE_TEMPLATES_VIEW] as Route
}
/>
</Suspense>
Expand Down Expand Up @@ -545,8 +534,7 @@ const SettingsRoutes: FunctionComponent<ComponentProps> = (
}
/>


<PageRoute
<PageRoute
path={RouteUtil.getLastPathForKey(PageMap.SETTINGS_ALERTS_STATE)}
element={
<Suspense fallback={Loader}>
Expand Down Expand Up @@ -604,18 +592,13 @@ const SettingsRoutes: FunctionComponent<ComponentProps> = (
}
/>


<PageRoute
path={RouteUtil.getLastPathForKey(
PageMap.SETTINGS_ALERTS_SEVERITY,
)}
<PageRoute
path={RouteUtil.getLastPathForKey(PageMap.SETTINGS_ALERTS_SEVERITY)}
element={
<Suspense fallback={Loader}>
<SettingsAlertSeverity
{...props}
pageRoute={
RouteMap[PageMap.SETTINGS_ALERTS_SEVERITY] as Route
}
pageRoute={RouteMap[PageMap.SETTINGS_ALERTS_SEVERITY] as Route}
/>
</Suspense>
}
Expand Down Expand Up @@ -770,8 +753,7 @@ const SettingsRoutes: FunctionComponent<ComponentProps> = (
}
/>


<PageRoute
<PageRoute
path={RouteUtil.getLastPathForKey(
PageMap.SETTINGS_ALERT_CUSTOM_FIELDS,
)}
Expand Down
Loading

0 comments on commit 54cd188

Please sign in to comment.