Debian Codegraph @

pkg/storaged/btrfs/filesystem.jsx

raw
1 /*
2 * Copyright (C) 2024 Red Hat, Inc.
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6 import cockpit from "cockpit";
7 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 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 export function make_btrfs_filesystem_card(next, backing_block, content_block) {
29 return new_card({
30 title: _("btrfs filesystem"),
31 next,
32 actions: btrfs_device_actions(backing_block, content_block),
33 component: BtrfsFilesystemCard,
34 props: { backing_block, content_block },
35 });
36 }
37
38 const BtrfsFilesystemCard = ({ card, backing_block, content_block }) => {
39 const block_btrfs = client.blocks_fsys_btrfs[content_block.path];
40 const uuid = block_btrfs && block_btrfs.data.uuid;
41 const use = btrfs_device_usage(client, uuid, block_btrfs.path);
42
43 return (
44 <StorageCard card={card}>
45 <CardBody>
46 <DescriptionList className="pf-m-horizontal-on-sm">
47 <BtrfsLabelDescription block_btrfs={block_btrfs} />
48 <StorageDescription title={_("UUID")} value={content_block.IdUUID} />
49 { block_btrfs &&
50 <StorageDescription title={_("Usage")}>
51 <StorageUsageBar key="s" stats={use} />
52 </StorageDescription>
53 }
54 </DescriptionList>
55 </CardBody>
56 <ChildrenTable
57 emptyCaption={_("No subvolumes")}
58 aria-label={_("btrfs subvolumes")}
59 page={card.page} />
60 </StorageCard>
61 );
62 };