Skip to content

Commit

Permalink
storage: Move "Lock" and "Unlock" actions to "Encryption" card
Browse files Browse the repository at this point in the history
That's where they belong. Filesystems are still automatically locked
and unlocked when mounting and unmounting them.
  • Loading branch information
mvollmer committed Jan 24, 2024
1 parent f19a871 commit 5c026f1
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 35 deletions.
8 changes: 5 additions & 3 deletions pkg/storaged/block/create-pages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,16 @@ export function make_block_page(parent, block, card) {
content_block = block;
}

if (is_crypto)
card = make_encryption_card(card, block);

if (!content_block) {
if (!is_crypto) {
// can not happen unless there is a bug in the code above.
console.error("Assertion failure: is_crypto == false");
}
if (fstab_config.length > 0 && !is_btrfs) {
card = make_encryption_card(card, block, true);
card = make_filesystem_card(card, block, null, fstab_config);
} else {
card = make_encryption_card(card, block, false);
card = make_locked_encrypted_data_card(card, block);
}
} else {
Expand All @@ -91,6 +90,9 @@ export function make_block_page(parent, block, card) {
const block_swap = client.blocks_swap[content_block.path];
const block_btrfs_blockdev = client.blocks_fsys_btrfs[content_block.path];

if (is_crypto)
card = make_encryption_card(card, block, is_filesystem);

if (block_btrfs_blockdev) {
card = make_btrfs_device_card(card, block, content_block, block_btrfs_blockdev);
} else if (is_filesystem) {
Expand Down
4 changes: 0 additions & 4 deletions pkg/storaged/block/unformatted-data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import cockpit from "cockpit";

import { StorageCard, new_card } from "../pages.jsx";
import { std_lock_action } from "../crypto/actions.jsx";

const _ = cockpit.gettext;

Expand All @@ -29,8 +28,5 @@ export function make_unformatted_data_card(next, backing_block, content_block) {
title: _("Unformatted data"),
next,
component: StorageCard,
actions: [
std_lock_action(backing_block, content_block),
]
});
}
4 changes: 0 additions & 4 deletions pkg/storaged/block/unrecognized-data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.
import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";

import { StorageCard, StorageDescription, new_card } from "../pages.jsx";
import { std_lock_action } from "../crypto/actions.jsx";

const _ = cockpit.gettext;

Expand All @@ -34,9 +33,6 @@ export function make_unrecognized_data_card(next, backing_block, content_block)
next,
component: UnrecognizedDataCard,
props: { backing_block, content_block },
actions: [
std_lock_action(backing_block, content_block),
]
});
}

Expand Down
4 changes: 0 additions & 4 deletions pkg/storaged/btrfs/device.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { DescriptionList } from "@patternfly/react-core/dist/esm/components/Desc

import { StorageCard, StorageDescription, new_card, register_crossref } from "../pages.jsx";
import { StorageUsageBar } from "../storage-controls.jsx";
import { std_lock_action } from "../crypto/actions.jsx";
import { btrfs_device_usage } from "./utils.jsx";

const _ = cockpit.gettext;
Expand All @@ -43,9 +42,6 @@ export function make_btrfs_device_card(next, backing_block, content_block, block
next,
component: BtrfsDeviceCard,
props: { backing_block, content_block },
actions: [
std_lock_action(backing_block, content_block),
],
});

register_crossref({
Expand Down
18 changes: 17 additions & 1 deletion pkg/storaged/crypto/encryption.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,32 @@ import luksmeta_monitor_hack_py from "./luksmeta-monitor-hack.py";
import { is_mounted } from "../filesystem/utils.jsx";
import { StorageLink } from "../storage-controls.jsx";
import { CryptoKeyslots } from "./keyslots.jsx";
import { lock, unlock } from "./actions.jsx";

const _ = cockpit.gettext;

export function make_encryption_card(next, block) {
export function make_encryption_card(next, block, is_filesystem) {
const content_block = client.blocks_cleartext[block.path];

return new_card({
title: _("Encryption"),
next,
type_extra: _("encrypted"),
component: EncryptionCard,
props: { block },
actions: [
(content_block && !is_filesystem) &&
{
title: _("Lock"),
action: () => lock(block),
},
!content_block &&
{
title: _("Unlock"),
primary: !is_filesystem,
action: () => unlock(block),
},
]
});
}

Expand Down
4 changes: 0 additions & 4 deletions pkg/storaged/crypto/locked-encrypted-data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import cockpit from "cockpit";

import { StorageCard, new_card } from "../pages.jsx";
import { unlock } from "./actions.jsx";

const _ = cockpit.gettext;

Expand All @@ -31,8 +30,5 @@ export function make_locked_encrypted_data_card(next, block) {
page_block: block,
component: StorageCard,
props: { block },
actions: [
{ title: _("Unlock"), action: () => unlock(block) },
]
});
}
4 changes: 0 additions & 4 deletions pkg/storaged/lvm2/physical-volume.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.
import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";

import { StorageCard, StorageDescription, new_card, register_crossref } from "../pages.jsx";
import { std_lock_action } from "../crypto/actions.jsx";
import { StorageUsageBar } from "../storage-controls.jsx";

const _ = cockpit.gettext;
Expand All @@ -44,9 +43,6 @@ export function make_lvm2_physical_volume_card(next, backing_block, content_bloc
: backing_block.Size),
component: LVM2PhysicalVolumeCard,
props: { backing_block, content_block },
actions: [
std_lock_action(backing_block, content_block),
]
});

function pvol_remove() {
Expand Down
6 changes: 1 addition & 5 deletions pkg/storaged/mdraid/mdraid-disk.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { DescriptionList } from "@patternfly/react-core/dist/esm/components/Desc

import { StorageCard, StorageDescription, new_card, register_crossref } from "../pages.jsx";
import { block_short_name, fmt_size, mdraid_name } from "../utils.js";
import { std_lock_action } from "../crypto/actions.jsx";

const _ = cockpit.gettext;

Expand All @@ -40,10 +39,7 @@ export function make_mdraid_disk_card(next, backing_block, content_block) {
next,
location: mdraid_block ? block_short_name(mdraid_block) : (mdraid ? mdraid_name(mdraid) : null),
component: MDRaidDiskCard,
props: { backing_block, content_block, mdraid },
actions: [
std_lock_action(backing_block, content_block),
]
props: { backing_block, content_block, mdraid }
});

if (mdraid) {
Expand Down
4 changes: 0 additions & 4 deletions pkg/storaged/stratis/blockdev.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { DescriptionList } from "@patternfly/react-core/dist/esm/components/Desc

import { StorageCard, StorageDescription, new_card, register_crossref } from "../pages.jsx";
import { fmt_size } from "../utils.js";
import { std_lock_action } from "../crypto/actions.jsx";

const _ = cockpit.gettext;

Expand All @@ -42,9 +41,6 @@ export function make_stratis_blockdev_card(next, backing_block, content_block) {
next,
component: StratisBlockdevCard,
props: { backing_block, content_block, pool, stopped_pool },
actions: [
std_lock_action(backing_block, content_block),
]
});

if (pool || stopped_pool) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/storaged/swap/swap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
fmt_size, decode_filename, encode_filename,
parse_options, unparse_options, extract_option,
} from "../utils.js";
import { std_lock_action } from "../crypto/actions.jsx";

const _ = cockpit.gettext;

Expand Down Expand Up @@ -89,7 +88,6 @@ export function make_swap_card(next, backing_block, content_block) {
component: SwapCard,
props: { block: content_block, block_swap },
actions: [
std_lock_action(backing_block, content_block),
(block_swap && block_swap.Active
? { title: _("Stop"), action: stop }
: null),
Expand Down

0 comments on commit 5c026f1

Please sign in to comment.