Skip to content

Commit

Permalink
storage: Polish encryption actions and options a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Jun 17, 2024
1 parent 021c61f commit 19d612a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 59 deletions.
12 changes: 8 additions & 4 deletions pkg/storaged/block/actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
105 changes: 50 additions & 55 deletions pkg/storaged/block/format-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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") }
];
}
Expand All @@ -277,20 +272,20 @@ 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,
max: max_size,
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),
Expand All @@ -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),
],
Expand Down

0 comments on commit 19d612a

Please sign in to comment.