From b55bb4ceeb0658344421a0266764ac0a1f425123 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 17 Jan 2025 20:39:43 +0000 Subject: [PATCH] feat: simplify alert state management by consolidating ChangeAlertState usage and adding AlertFeedElement --- Dashboard/src/Pages/Alerts/View/Index.tsx | 75 ++++------------------- 1 file changed, 13 insertions(+), 62 deletions(-) diff --git a/Dashboard/src/Pages/Alerts/View/Index.tsx b/Dashboard/src/Pages/Alerts/View/Index.tsx index cb13ff3386..afc7308f16 100644 --- a/Dashboard/src/Pages/Alerts/View/Index.tsx +++ b/Dashboard/src/Pages/Alerts/View/Index.tsx @@ -1,11 +1,7 @@ -import ChangeAlertState, { - AlertType, -} from "../../../Components/Alert/ChangeState"; +import ChangeAlertState from "../../../Components/Alert/ChangeState"; import LabelsElement from "../../../Components/Label/Labels"; import OnCallDutyPoliciesView from "../../../Components/OnCallPolicy/OnCallPolicies"; -import EventName from "../../../Utils/EventName"; import PageComponentProps from "../../PageComponentProps"; -import BaseModel from "Common/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel"; import SortOrder from "Common/Types/BaseDatabase/SortOrder"; import { Black } from "Common/Types/BrandColors"; import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax"; @@ -23,7 +19,6 @@ import Pill from "Common/UI/Components/Pill/Pill"; import ProbeElement from "Common/UI/Components/Probe/Probe"; import FieldType from "Common/UI/Components/Types/FieldType"; import BaseAPI from "Common/UI/Utils/API/API"; -import GlobalEvent from "Common/UI/Utils/GlobalEvents"; import ModelAPI, { ListResult } from "Common/UI/Utils/ModelAPI/ModelAPI"; import Navigation from "Common/UI/Utils/Navigation"; import Alert from "Common/Models/DatabaseModels/Alert"; @@ -53,6 +48,7 @@ import HeaderAlert, { } from "Common/UI/Components/HeaderAlert/HeaderAlert"; import IconProp from "Common/Types/Icon/IconProp"; import ColorSwatch from "Common/Types/ColorSwatch"; +import AlertFeedElement from "../../../Components/Alert/AlertFeed"; const AlertView: FunctionComponent = (): ReactElement => { const modelId: ObjectID = Navigation.getLastParamAsObjectID(); @@ -483,67 +479,20 @@ const AlertView: FunctionComponent = (): ReactElement => { getElement: (item: Alert): ReactElement => { return ; }, - }, - { - field: { - _id: true, - }, - title: "Acknowledge Alert", - fieldType: FieldType.Element, - getElement: ( - _item: Alert, - onBeforeFetchData: JSONObject | undefined, - ): ReactElement => { - return ( - ) - : [] - } - alertType={AlertType.Ack} - onActionComplete={async () => { - await fetchData(); - }} - /> - ); - }, - }, - { - field: { - _id: true, - }, - title: "Resolve Alert", - fieldType: FieldType.Element, - getElement: ( - _item: Alert, - onBeforeFetchData: JSONObject | undefined, - ): ReactElement => { - return ( - ) - : [] - } - alertType={AlertType.Resolve} - onActionComplete={async () => { - GlobalEvent.dispatchEvent( - EventName.ACTIVE_ALERTS_COUNT_REFRESH, - ); - await fetchData(); - }} - /> - ); - }, - }, + } + ], modelId: modelId, }} /> + { + await fetchData(); + }} + /> +
= (): ReactElement => { /> )} + + ); };