Line data Source code
1 43 : import React, { useState } from 'react';
2 :
3 : import { Button } from "@patternfly/react-core/dist/esm/components/Button";
4 : import {
5 : Modal
6 : } from '@patternfly/react-core/dist/esm/deprecated/components/Modal';
7 : import { useDialogs } from "dialogs.jsx";
8 :
9 : import cockpit from 'cockpit';
10 :
11 43 : const _ = cockpit.gettext;
12 :
13 2 : const ForceRemoveModal = ({ name, reason, handleForceRemove }) => {
14 2 : const Dialogs = useDialogs();
15 2 : const [inProgress, setInProgress] = useState(false);
16 2 : return (
17 2 : <Modal isOpen
18 2 : showClose={false}
19 2 : position="top" variant="medium"
20 2 : titleIconVariant="warning"
21 2 : onClose={Dialogs.close}
22 2 : title={cockpit.format(_("Delete $0?"), name)}
23 2 : footer={<>
24 2 : <Button variant="danger" isDisabled={inProgress} isLoading={inProgress}
25 0 : onClick={() => { setInProgress(true); handleForceRemove().catch(() => setInProgress(false)) }}
26 : >
27 2 : {_("Force delete")}
28 2 : </Button>
29 2 : <Button variant="link" isDisabled={inProgress} onClick={Dialogs.close}>{_("Cancel")}</Button>
30 2 : </>}
31 : >
32 2 : {reason}
33 2 : </Modal>
34 : );
35 2 : };
36 :
37 43 : export default ForceRemoveModal;
|