Line data Source code
1 43 : import React 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 : import * as client from './client.js';
12 :
13 43 : const _ = cockpit.gettext;
14 :
15 1 : const ContainerDeleteModal = ({ con, containerWillDelete, onAddNotification }) => {
16 1 : const Dialogs = useDialogs();
17 :
18 1 : const handleRemoveContainer = () => {
19 1 : const container = containerWillDelete;
20 0 : const id = container ? container.Id : "";
21 :
22 1 : Dialogs.close();
23 1 : client.delContainer(con, id, false)
24 0 : .catch(ex => {
25 0 : const error = cockpit.format(_("Failed to remove container $0"), container.Name); // not-covered: OS error
26 0 : onAddNotification({ type: 'danger', error, errorDetail: ex.message });
27 0 : });
28 1 : };
29 :
30 1 : return (
31 1 : <Modal isOpen
32 1 : position="top" variant="medium"
33 1 : titleIconVariant="warning"
34 1 : onClose={Dialogs.close}
35 1 : title={cockpit.format(_("Delete $0?"), containerWillDelete.Name)}
36 1 : footer={<>
37 1 : <Button variant="danger" className="btn-ctr-delete" onClick={handleRemoveContainer}>{_("Delete")}</Button>{' '}
38 1 : <Button variant="link" onClick={Dialogs.close}>{_("Cancel")}</Button>
39 1 : </>}
40 : >
41 1 : {_("Deleting a container will erase all data in it.")}
42 1 : </Modal>
43 : );
44 1 : };
45 :
46 43 : export default ContainerDeleteModal;
|