Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 1x 1x | import { Link, useParams } from "react-router-dom";
import { Modal, Button, Icon } from "@canonical/react-components";
import type { SigningKey } from "../../types/shared";
import { Dispatch, SetStateAction } from "react";
type Props = {
setModalOpen: Dispatch<SetStateAction<boolean>>;
handleDisable: (signingKey: SigningKey) => void;
isDeleting: boolean;
signingKey: SigningKey;
};
function DeactivateSigningKeyModal({
setModalOpen,
handleDisable,
isDeleting,
signingKey,
}: Props): React.JSX.Element {
const { id } = useParams();
return signingKey.models && signingKey.models.length > 0 ? (
<Modal
title={
<>
<Icon name="warning" />
{` Deactivate ${signingKey.name}`}
</>
}
close={() => {
setModalOpen(false);
}}
>
<h3>{signingKey.name} is used in :</h3>
<ul>
{signingKey.models &&
signingKey.models.length > 0 &&
signingKey.models.map((model) => (
<li key={model}>
<Link to={`/admin/${id}/models/${model}/policies`}>{model}</Link>
</li>
))}
</ul>
<p>
You need to update each policy with a new key first to be able to delete
this one.
</p>
</Modal>
) : (
<Modal
close={() => {
setModalOpen(false);
}}
title="Confirm disable"
buttonRow={
<>
<Button
dense
className="u-no-margin--bottom"
onClick={() => {
setModalOpen(false);
}}
>
Cancel
</Button>
<Button
dense
className="p-button--negative u-no-margin--bottom u-no-margin--right"
onClick={() => {
handleDisable(signingKey);
}}
disabled={isDeleting}
>
Disable
</Button>
</>
}
>
{isDeleting ? (
<p>
<Icon name="spinner" className="u-animation--spin" />
Deleting signing key...
</p>
) : (
<p>{`Warning: This will permanently disable the signing key ${signingKey.name}.`}</p>
)}
</Modal>
);
}
export default DeactivateSigningKeyModal;
|