2022-04-11 19:04:41 +00:00
|
|
|
import React, { useEffect } from "react";
|
|
|
|
|
|
|
|
|
|
import Modal from "components/Modal";
|
|
|
|
|
import Button from "components/buttons/Button";
|
|
|
|
|
|
|
|
|
|
const baseClass = "delete-integration-modal";
|
|
|
|
|
|
|
|
|
|
interface IDeleteIntegrationModalProps {
|
|
|
|
|
url: string;
|
2022-05-06 16:31:11 +00:00
|
|
|
projectKey: string;
|
2022-04-11 19:04:41 +00:00
|
|
|
onSubmit: () => void;
|
|
|
|
|
onCancel: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DeleteIntegrationModal = ({
|
|
|
|
|
url,
|
2022-05-06 16:31:11 +00:00
|
|
|
projectKey,
|
2022-04-11 19:04:41 +00:00
|
|
|
onSubmit,
|
|
|
|
|
onCancel,
|
|
|
|
|
}: IDeleteIntegrationModalProps): JSX.Element => {
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const listener = (event: KeyboardEvent) => {
|
|
|
|
|
if (event.code === "Enter" || event.code === "NumpadEnter") {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
onSubmit();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
document.addEventListener("keydown", listener);
|
|
|
|
|
return () => {
|
|
|
|
|
document.removeEventListener("keydown", listener);
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal title={"Delete integration"} onExit={onCancel} className={baseClass}>
|
|
|
|
|
<form className={`${baseClass}__form`}>
|
|
|
|
|
<p>
|
|
|
|
|
This action will delete the{" "}
|
2022-05-06 16:31:11 +00:00
|
|
|
<span className={`${baseClass}__url`}>
|
|
|
|
|
{url} - {projectKey}
|
|
|
|
|
</span>{" "}
|
|
|
|
|
integration.
|
2022-04-11 19:04:41 +00:00
|
|
|
</p>
|
|
|
|
|
<p>The automations that use this integration will be turned off.</p>
|
2022-04-27 20:40:28 +00:00
|
|
|
<div className="modal-cta-wrap">
|
|
|
|
|
<Button onClick={onCancel} variant="inverse-alert">
|
2022-04-11 19:04:41 +00:00
|
|
|
Cancel
|
|
|
|
|
</Button>
|
2022-04-27 20:40:28 +00:00
|
|
|
<Button type="button" onClick={onSubmit} variant="alert">
|
|
|
|
|
Delete
|
|
|
|
|
</Button>
|
2022-04-11 19:04:41 +00:00
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default DeleteIntegrationModal;
|