diff --git a/pkg/storaged/block/create-pages.jsx b/pkg/storaged/block/create-pages.jsx index aea381d798b9..10c1d91fa827 100644 --- a/pkg/storaged/block/create-pages.jsx +++ b/pkg/storaged/block/create-pages.jsx @@ -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 { @@ -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) { diff --git a/pkg/storaged/block/unformatted-data.jsx b/pkg/storaged/block/unformatted-data.jsx index 6843905e9e8d..7509810c75d0 100644 --- a/pkg/storaged/block/unformatted-data.jsx +++ b/pkg/storaged/block/unformatted-data.jsx @@ -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; @@ -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), - ] }); } diff --git a/pkg/storaged/block/unrecognized-data.jsx b/pkg/storaged/block/unrecognized-data.jsx index ce682df63913..fe514b3d978f 100644 --- a/pkg/storaged/block/unrecognized-data.jsx +++ b/pkg/storaged/block/unrecognized-data.jsx @@ -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; @@ -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), - ] }); } diff --git a/pkg/storaged/btrfs/device.jsx b/pkg/storaged/btrfs/device.jsx index a31ea237a653..1e895d26cb5c 100644 --- a/pkg/storaged/btrfs/device.jsx +++ b/pkg/storaged/btrfs/device.jsx @@ -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; @@ -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({ diff --git a/pkg/storaged/crypto/encryption.jsx b/pkg/storaged/crypto/encryption.jsx index 4245de38131d..c875698d6986 100644 --- a/pkg/storaged/crypto/encryption.jsx +++ b/pkg/storaged/crypto/encryption.jsx @@ -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), + }, + ] }); } diff --git a/pkg/storaged/crypto/locked-encrypted-data.jsx b/pkg/storaged/crypto/locked-encrypted-data.jsx index 59712de98b01..2b04a06f9476 100644 --- a/pkg/storaged/crypto/locked-encrypted-data.jsx +++ b/pkg/storaged/crypto/locked-encrypted-data.jsx @@ -20,7 +20,6 @@ import cockpit from "cockpit"; import { StorageCard, new_card } from "../pages.jsx"; -import { unlock } from "./actions.jsx"; const _ = cockpit.gettext; @@ -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) }, - ] }); } diff --git a/pkg/storaged/lvm2/physical-volume.jsx b/pkg/storaged/lvm2/physical-volume.jsx index b754c0100a66..f44f7a8abf0b 100644 --- a/pkg/storaged/lvm2/physical-volume.jsx +++ b/pkg/storaged/lvm2/physical-volume.jsx @@ -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; @@ -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() { diff --git a/pkg/storaged/mdraid/mdraid-disk.jsx b/pkg/storaged/mdraid/mdraid-disk.jsx index cb85235e7b96..83ebdc23b553 100644 --- a/pkg/storaged/mdraid/mdraid-disk.jsx +++ b/pkg/storaged/mdraid/mdraid-disk.jsx @@ -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; @@ -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) { diff --git a/pkg/storaged/stratis/blockdev.jsx b/pkg/storaged/stratis/blockdev.jsx index 5e7f8cdbda51..f1d7852dd21e 100644 --- a/pkg/storaged/stratis/blockdev.jsx +++ b/pkg/storaged/stratis/blockdev.jsx @@ -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; @@ -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) { diff --git a/pkg/storaged/swap/swap.jsx b/pkg/storaged/swap/swap.jsx index 4172865f777c..1ae92c5b0ee1 100644 --- a/pkg/storaged/swap/swap.jsx +++ b/pkg/storaged/swap/swap.jsx @@ -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; @@ -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),