From 19d612aef14d2279847e50ec555fde1f501efa92 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 12 Apr 2024 11:14:04 +0300 Subject: [PATCH] storage: Polish encryption actions and options a bit --- pkg/storaged/block/actions.jsx | 12 ++- pkg/storaged/block/format-dialog.jsx | 105 +++++++++++++-------------- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/pkg/storaged/block/actions.jsx b/pkg/storaged/block/actions.jsx index d39fd89ec1a7..0678f4aa37e7 100644 --- a/pkg/storaged/block/actions.jsx +++ b/pkg/storaged/block/actions.jsx @@ -46,9 +46,13 @@ export function block_actions(block, kind) { if (kind == "crypto") { actions.push({ - title: _("Format cleartext device"), + title: _("Format as encrypted filesystem"), action: () => format_dialog(block, { is_encrypted: true }), - primary: true, + excuse, + }); + actions.push({ + title: _("Format as encrypted swap"), + action: () => format_swap_dialog(block), excuse, }); } else { @@ -63,14 +67,14 @@ export function block_actions(block, kind) { excuse, }); actions.push({ - title: _("Add encryption"), + title: _("Format with encryption only"), action: () => format_dialog(block, { add_encryption: true }), excuse, }); } } else { actions.push({ - title: kind == "crypto" ? _("Erase cleartext device") : _("Erase"), + title: kind == "crypto" ? _("Erase encrypted device") : _("Erase"), action: () => erase_dialog(block), danger: true, excuse, diff --git a/pkg/storaged/block/format-dialog.jsx b/pkg/storaged/block/format-dialog.jsx index db4654b04cf0..b2d460824e5c 100644 --- a/pkg/storaged/block/format-dialog.jsx +++ b/pkg/storaged/block/format-dialog.jsx @@ -30,7 +30,7 @@ import { import { dialog_open, - TextInput, PassInput, CheckBoxes, SelectOne, SizeSlider, + TextInput, PassInput, CheckBoxes, SelectOne, SelectOneRadio, SizeSlider, BlockingMessage, TeardownMessage, init_teardown_usage } from "../dialog.jsx"; @@ -252,13 +252,8 @@ export function format_dialog(block, options) { { tag: "nomount", Title: create_partition ? _("Create") : _("Format") } ]; - let action_variants_for_swap = [ - { tag: null, Title: create_partition ? _("Create and start") : _("Format and start") }, - { tag: "nomount", Title: create_partition ? _("Create only") : _("Format only") } - ]; - if (client.in_anaconda_mode()) { - action_variants = action_variants_for_swap = [ + action_variants = [ { tag: "nomount", Title: create_partition ? _("Create") : _("Format") } ]; } @@ -277,6 +272,12 @@ export function format_dialog(block, options) { Title: title, Teardown: TeardownMessage(usage), Fields: [ + SelectOne("type", create_partition ? _("Format") : _("Type"), + { + value: default_type, + choices: filesystem_options, + visible: () => !add_encryption, + }), SizeSlider("size", _("Size"), { value: max_size, @@ -284,13 +285,7 @@ export function format_dialog(block, options) { round: 1024 * 1024, visible: () => create_partition, }), - SelectOne("type", _("Type"), - { - value: default_type, - choices: filesystem_options, - visible: () => !add_encryption, - }), - TextInput("name", _("Name"), + TextInput("name", _("Volume label"), { value: content_block?.IdLabel, validate: (name, vals) => validate_fsys_label(name, vals.type), @@ -307,47 +302,47 @@ export function format_dialog(block, options) { variant == "nomount"); } }), - SelectOne("crypto", _("Encryption"), - { - choices: crypto_types, - value: default_crypto_type, - visible: vals => vals.type != "dos-extended" && vals.type != "biosboot" && vals.type != "efi" && vals.type != "empty" && !is_already_encrypted, - nested_fields: [ - PassInput("passphrase", _("Passphrase"), - { - validate: function (phrase, vals) { - if (phrase === "") - return _("Passphrase cannot be empty"); - }, - visible: is_encrypted, - new_password: true - }), - PassInput("passphrase2", _("Confirm"), - { - validate: function (phrase2, vals) { - if (phrase2 != vals.passphrase) - return _("Passphrases do not match"); - }, - visible: is_encrypted, - new_password: true - }), - CheckBoxes("store_passphrase", "", - { - visible: is_encrypted, - value: { - on: false, - }, - fields: [ - { title: _("Store passphrase"), tag: "on" } - ] - }), - TextInput("crypto_options", _("Encryption options"), - { - visible: is_encrypted, - value: crypto_extra_options - }) - ] - }), + SelectOneRadio("crypto", _("Encryption"), + { + choices: crypto_types, + value: default_crypto_type, + visible: vals => vals.type != "dos-extended" && vals.type != "biosboot" && vals.type != "efi" && vals.type != "empty" && !is_already_encrypted, + nested_fields: [ + PassInput("passphrase", _("Passphrase"), + { + validate: function (phrase, vals) { + if (phrase === "") + return _("Passphrase cannot be empty"); + }, + visible: is_encrypted, + new_password: true + }), + PassInput("passphrase2", _("Confirm"), + { + validate: function (phrase2, vals) { + if (phrase2 != vals.passphrase) + return _("Passphrases do not match"); + }, + visible: is_encrypted, + new_password: true + }), + CheckBoxes("store_passphrase", "", + { + visible: is_encrypted, + value: { + on: false, + }, + fields: [ + { title: _("Store passphrase"), tag: "on" } + ] + }), + TextInput("crypto_options", _("Encryption options"), + { + visible: is_encrypted, + value: crypto_extra_options + }) + ] + }), at_boot_input(at_boot, is_filesystem), mount_options(opt_ro, extra_options, is_filesystem), ],