Line data Source code
1 : /*
2 : * Copyright (C) 2024 Red Hat, Inc.
3 : * SPDX-License-Identifier: LGPL-2.1-or-later
4 : */
5 :
6 113 : import cockpit from "cockpit";
7 113 : import React from "react";
8 : import client from "../client";
9 :
10 : import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.js";
11 : import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";
12 :
13 : import {
14 : new_card, ChildrenTable, StorageCard, StorageDescription
15 : } from "../pages.jsx";
16 : import { StorageUsageBar } from "../storage-controls.jsx";
17 : import { btrfs_device_usage } from "./utils.jsx";
18 : import { btrfs_device_actions } from "./device.jsx";
19 : import { BtrfsLabelDescription } from "./volume.jsx";
20 :
21 113 : const _ = cockpit.gettext;
22 :
23 : /**
24 : * For single btrfs volumes we show the data as a filesystem card with the
25 : * subvolumes directly undernearth. This differentiates from multi device
26 : * volumes, there they are shown under a different card.
27 : */
28 102 : export function make_btrfs_filesystem_card(next, backing_block, content_block) {
29 102 : return new_card({
30 102 : title: _("btrfs filesystem"),
31 102 : next,
32 102 : actions: btrfs_device_actions(backing_block, content_block),
33 102 : component: BtrfsFilesystemCard,
34 102 : props: { backing_block, content_block },
35 102 : });
36 102 : }
37 :
38 7 : const BtrfsFilesystemCard = ({ card, backing_block, content_block }) => {
39 7 : const block_btrfs = client.blocks_fsys_btrfs[content_block.path];
40 7 : const uuid = block_btrfs && block_btrfs.data.uuid;
41 7 : const use = btrfs_device_usage(client, uuid, block_btrfs.path);
42 :
43 7 : return (
44 7 : <StorageCard card={card}>
45 7 : <CardBody>
46 7 : <DescriptionList className="pf-m-horizontal-on-sm">
47 7 : <BtrfsLabelDescription block_btrfs={block_btrfs} />
48 7 : <StorageDescription title={_("UUID")} value={content_block.IdUUID} />
49 7 : { block_btrfs &&
50 7 : <StorageDescription title={_("Usage")}>
51 7 : <StorageUsageBar key="s" stats={use} />
52 7 : </StorageDescription>
53 : }
54 7 : </DescriptionList>
55 7 : </CardBody>
56 7 : <ChildrenTable
57 7 : emptyCaption={_("No subvolumes")}
58 7 : aria-label={_("btrfs subvolumes")}
59 7 : page={card.page} />
60 7 : </StorageCard>
61 : );
62 7 : };
|