From e0a4ae9c4d960a8b03651dc99ef54bac4990c926 Mon Sep 17 00:00:00 2001 From: Vladimir Filonov Date: Thu, 17 Oct 2024 16:44:42 +0400 Subject: [PATCH] feat: Possibility to run workflows for incidents manually (#2226) --- keep-ui/app/alerts/alerts.tsx | 4 +-- keep-ui/app/incidents/[id]/incident-info.tsx | 28 ++++++++++++++++++- keep-ui/app/incidents/incidents-table.tsx | 24 +++++++++++++++- .../manual-run-workflow-modal.tsx} | 16 +++++++---- keep/api/routes/workflows.py | 28 ++++++++++++------- keep/workflowmanager/workflowscheduler.py | 23 +++++++++++---- 6 files changed, 97 insertions(+), 26 deletions(-) rename keep-ui/app/{alerts/alert-run-workflow-modal.tsx => workflows/manual-run-workflow-modal.tsx} (79%) diff --git a/keep-ui/app/alerts/alerts.tsx b/keep-ui/app/alerts/alerts.tsx index 5d8ff0151..e780179ed 100644 --- a/keep-ui/app/alerts/alerts.tsx +++ b/keep-ui/app/alerts/alerts.tsx @@ -9,7 +9,7 @@ import AlertNoteModal from "./alert-note-modal"; import { useProviders } from "utils/hooks/useProviders"; import { AlertDto } from "./models"; import { AlertMethodModal } from "./alert-method-modal"; -import AlertRunWorkflowModal from "./alert-run-workflow-modal"; +import ManualRunWorkflowModal from "@/app/workflows/manual-run-workflow-modal"; import AlertDismissModal from "./alert-dismiss-modal"; import { ViewAlertModal } from "./ViewAlertModal"; import { useRouter, useSearchParams } from "next/navigation"; @@ -151,7 +151,7 @@ export default function Alerts({ presetName }: AlertsProps) { alert={noteModalAlert ?? null} /> {selectedPreset && } - setRunWorkflowModalAlert(null)} /> diff --git a/keep-ui/app/incidents/[id]/incident-info.tsx b/keep-ui/app/incidents/[id]/incident-info.tsx index 364965010..b8b1314de 100644 --- a/keep-ui/app/incidents/[id]/incident-info.tsx +++ b/keep-ui/app/incidents/[id]/incident-info.tsx @@ -3,7 +3,7 @@ import { IncidentDto } from "../models"; import CreateOrUpdateIncident from "../create-or-update-incident"; import Modal from "@/components/ui/Modal"; import React, { useState } from "react"; -import { MdBlock, MdDone, MdModeEdit } from "react-icons/md"; +import {MdBlock, MdDone, MdModeEdit, MdPlayArrow} from "react-icons/md"; import { useIncident, useIncidentFutureIncidents } from "@/utils/hooks/useIncidents"; import { @@ -23,6 +23,7 @@ import {STATUS_ICONS} from "@/app/incidents/statuses"; import remarkRehype from "remark-rehype"; import rehypeRaw from "rehype-raw"; import Markdown from "react-markdown"; +import ManualRunWorkflowModal from "@/app/workflows/manual-run-workflow-modal"; interface Props { incident: IncidentDto; @@ -92,6 +93,9 @@ export default function IncidentInformation({ incident }: Props) { const { mutate } = useIncident(incident.id); const [isFormOpen, setIsFormOpen] = useState(false); + const [runWorkflowModalIncident, setRunWorkflowModalIncident] = + useState(); + const handleCloseForm = () => { setIsFormOpen(false); }; @@ -104,6 +108,10 @@ export default function IncidentInformation({ incident }: Props) { setIsFormOpen(false); mutate(); }; + const handleRunWorkflow = () => { + setRunWorkflowModalIncident(incident); + mutate(); + }; const [changeStatusIncident, setChangeStatusIncident] = useState(); @@ -141,12 +149,26 @@ export default function IncidentInformation({ incident }: Props) { {incident.is_confirmed ? "⚔️ " : "Possible "}Incident +