Line data Source code
1 : /*
2 : * Copyright (C) 2022 Red Hat, Inc.
3 : * SPDX-License-Identifier: LGPL-2.1-or-later
4 : */
5 :
6 15 : import cockpit from 'cockpit';
7 15 : import React from 'react';
8 : import { List, ListItem } from "@patternfly/react-core/dist/esm/components/List/index.js";
9 : import { Stack } from "@patternfly/react-core/dist/esm/layouts/Stack/index.js";
10 : import { Content, } from "@patternfly/react-core/dist/esm/components/Content/index.js";
11 :
12 : import { show_modal_dialog } from "cockpit-components-dialog.jsx";
13 :
14 15 : const _ = cockpit.gettext;
15 :
16 0 : export function delete_group_dialog(group) {
17 0 : const props = {
18 0 : id: "group-confirm-delete-dialog",
19 0 : title: cockpit.format(_("Permanently delete $0 group?"), group.name),
20 0 : body: group.userlistPrimary.length > 0
21 0 : ? <Stack hasGutter>
22 0 : <Content>
23 0 : <Content component="p">
24 0 : {_("This group is the primary group for the following users:")}
25 0 : </Content>
26 0 : </Content>
27 0 : <List>
28 0 : {group.userlistPrimary.map(account => <ListItem className='list-item' key={account}>{account}</ListItem>)}
29 0 : </List>
30 0 : </Stack>
31 0 : : null
32 0 : };
33 :
34 0 : const footer = {
35 0 : actions: [
36 0 : {
37 0 : caption: group.userlistPrimary.length > 0 ? _("Force delete") : _("Delete"),
38 0 : style: "danger",
39 0 : clicked: () => {
40 0 : const prog = ["groupdel"];
41 0 : if (group.userlistPrimary.length > 0)
42 0 : prog.push("-f");
43 0 : prog.push(group.name);
44 :
45 0 : return cockpit.spawn(prog, { superuser: "require", err: "message" });
46 0 : }
47 0 : }
48 0 : ]
49 0 : };
50 :
51 0 : show_modal_dialog(props, footer);
52 0 : }
|