-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add playbook approval feature on the UI
Fixes #2304
- Loading branch information
1 parent
3dc3389
commit a0d66e4
Showing
7 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { approvePlaybookRun } from "@flanksource-ui/api/services/playbooks"; | ||
import { toastError } from "@flanksource-ui/components/Toast/toast"; | ||
import { ConfirmationPromptDialog } from "@flanksource-ui/ui/AlertDialog/ConfirmationPromptDialog"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { AxiosError } from "axios"; | ||
|
||
type ApprovePlaybookRunModalProps = { | ||
onClose: () => void; | ||
open: boolean; | ||
playbookTitle: string; | ||
playbookRunId: string; | ||
refetch?: () => void; | ||
}; | ||
|
||
export default function ApprovePlaybookRunModal({ | ||
onClose, | ||
open, | ||
playbookTitle, | ||
playbookRunId, | ||
refetch = () => {} | ||
}: ApprovePlaybookRunModalProps) { | ||
const { mutate: approve, isLoading } = useMutation({ | ||
mutationFn: (id: string) => { | ||
return approvePlaybookRun(id); | ||
}, | ||
onError: (error: AxiosError) => { | ||
console.error("Failed to approve playbook run", error); | ||
toastError(`Failed to approve playbook run: ${error.message}`); | ||
}, | ||
onSuccess: () => { | ||
onClose(); | ||
refetch(); | ||
} | ||
}); | ||
|
||
return ( | ||
<ConfirmationPromptDialog | ||
title={`Approve Playbook ${playbookTitle} Run`} | ||
description={<p>Are you sure you want to approve this playbook run?</p>} | ||
onConfirm={() => approve(playbookRunId)} | ||
open={open} | ||
onClose={onClose} | ||
isOpen={open} | ||
yesLabel={isLoading ? "Approving..." : "Approve"} | ||
closeLabel="Cancel" | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters