Skip to content

Commit

Permalink
btrfs: show snapshots of a subvolume in the subvolume details page
Browse files Browse the repository at this point in the history
Register crossrefs for snapshots so they show under snapshots in the
detail page of a subvolume.
  • Loading branch information
jelly committed Apr 4, 2024
1 parent a133855 commit ce13bed
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions pkg/storaged/btrfs/subvolume.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
import cockpit from "cockpit";
import React from "react";

import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.js";
import { Card, CardBody, CardHeader, CardTitle } from "@patternfly/react-core/dist/esm/components/Card/index.js";
import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";

import {
StorageCard, StorageDescription, ChildrenTable, new_card, new_page, navigate_away_from_card
PageTable, StorageCard, StorageDescription, ChildrenTable,
new_card, new_page, navigate_away_from_card, register_crossref, get_crossrefs,
} from "../pages.jsx";
import { StorageUsageBar } from "../storage-controls.jsx";
import {
Expand Down Expand Up @@ -394,6 +395,14 @@ function make_btrfs_subvolume_page(parent, volume, subvol, path_prefix, subvols)
props: { subvol, mount_point, mismount_warning, block, fstab_config, forced_options },
actions,
});

if (subvol.id !== 5 && subvol.parent_uuid !== null)
register_crossref({
key: subvol.parent_uuid,
card,
size: mounted && <StorageUsageBar stats={use} short />,
});

const page = new_page(parent, card);
for (const sv of subvols) {
if (sv.parent && (sv.parent === subvol.id || sv.parent === subvol.fake_id)) {
Expand All @@ -403,6 +412,7 @@ function make_btrfs_subvolume_page(parent, volume, subvol, path_prefix, subvols)
}

const BtrfsSubvolumeCard = ({ card, subvol, mismount_warning, block, fstab_config, forced_options }) => {
const crossrefs = get_crossrefs(subvol.uuid);
return (
<StorageCard card={card} alert={mismount_warning &&
<MismountAlert warning={mismount_warning}
Expand All @@ -424,5 +434,17 @@ const BtrfsSubvolumeCard = ({ card, subvol, mismount_warning, block, fstab_confi
aria-label={_("btrfs subvolumes")}
page={card.page} />
</CardBody>
{crossrefs &&
<Card>
<CardHeader>
<CardTitle component="h2">{_("Snapshots")}</CardTitle>
</CardHeader>
<CardBody className="contains-list">
<PageTable emptyCaption={_("No snapshots found")}
aria-label={_("snapshot")}
crossrefs={crossrefs} />
</CardBody>
</Card>
}
</StorageCard>);
};

0 comments on commit ce13bed

Please sign in to comment.