-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List btrfs snapshots separately in the subvolume detail page #20234
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,13 @@ | |
import cockpit from "cockpit"; | ||
import React from "react"; | ||
|
||
import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.js"; | ||
import { Button } from "@patternfly/react-core/dist/esm/components/Button/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 { | ||
|
@@ -383,6 +385,16 @@ function make_btrfs_subvolume_page(parent, volume, subvol, path_prefix, subvols) | |
return str; | ||
} | ||
|
||
let snapshot_origin = null; | ||
if (subvol.id !== 5 && subvol.parent_uuid !== null) { | ||
for (const sv of subvols) { | ||
if (sv.uuid === subvol.parent_uuid) { | ||
snapshot_origin = sv; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
const card = new_card({ | ||
title: _("btrfs subvolume"), | ||
next: null, | ||
|
@@ -392,9 +404,17 @@ function make_btrfs_subvolume_page(parent, volume, subvol, path_prefix, subvols) | |
location: mp_text, | ||
component: BtrfsSubvolumeCard, | ||
has_warning: !!mismount_warning, | ||
props: { subvol, mount_point, mismount_warning, block, fstab_config, forced_options }, | ||
props: { volume, subvol, snapshot_origin, 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 />, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This added line is not executed by any test. |
||
}); | ||
|
||
const page = new_page(parent, card); | ||
for (const sv of subvols) { | ||
if (sv.parent && (sv.parent === subvol.id || sv.parent === subvol.fake_id)) { | ||
|
@@ -403,7 +423,9 @@ function make_btrfs_subvolume_page(parent, volume, subvol, path_prefix, subvols) | |
} | ||
} | ||
|
||
const BtrfsSubvolumeCard = ({ card, subvol, mismount_warning, block, fstab_config, forced_options }) => { | ||
const BtrfsSubvolumeCard = ({ card, volume, subvol, snapshot_origin, mismount_warning, block, fstab_config, forced_options }) => { | ||
const crossrefs = get_crossrefs(subvol.uuid); | ||
|
||
return ( | ||
<StorageCard card={card} alert={mismount_warning && | ||
<MismountAlert warning={mismount_warning} | ||
|
@@ -413,6 +435,14 @@ const BtrfsSubvolumeCard = ({ card, subvol, mismount_warning, block, fstab_confi | |
<DescriptionList className="pf-m-horizontal-on-sm"> | ||
<StorageDescription title={_("Name")} value={subvol.pathname} /> | ||
<StorageDescription title={_("ID")} value={subvol.id} /> | ||
{snapshot_origin !== null && | ||
<StorageDescription title={_("Snapshot origin")}> | ||
<Button variant="link" isInline role="link" | ||
onClick={() => cockpit.location.go(["btrfs", volume.data.uuid, snapshot_origin.pathname])}> | ||
{snapshot_origin.pathname} | ||
</Button> | ||
</StorageDescription> | ||
} | ||
<StorageDescription title={_("Mount point")}> | ||
<MountPoint fstab_config={fstab_config} | ||
backing_block={block} content_block={block} | ||
|
@@ -425,5 +455,17 @@ const BtrfsSubvolumeCard = ({ card, subvol, mismount_warning, block, fstab_confi | |
aria-label={_("btrfs subvolumes")} | ||
page={card.page} /> | ||
</CardBody> | ||
{crossrefs && | ||
<Card data-test-card-title="Snapshots"> | ||
<CardHeader> | ||
<CardTitle component="h2">{_("Snapshots")}</CardTitle> | ||
</CardHeader> | ||
<CardBody className="contains-list"> | ||
<PageTable emptyCaption={_("No snapshots found")} | ||
aria-label={_("snapshot")} | ||
crossrefs={crossrefs} /> | ||
</CardBody> | ||
</Card> | ||
} | ||
</StorageCard>); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the "Delete" action here.