From 8a43c02b7bf8d5a9bd7c97c0ad5cfc578916e614 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 9 Jan 2024 09:53:36 +0200 Subject: [PATCH] storage: Don't offer to mount while formatting in Anaconda mode It's the normal thing to do during installation. --- pkg/storaged/block/format-dialog.jsx | 23 +++++++++++----- pkg/storaged/filesystem/utils.jsx | 40 +++++++++++++++++++--------- pkg/storaged/stratis/filesystem.jsx | 2 +- pkg/storaged/stratis/pool.jsx | 15 +++++++++-- 4 files changed, 58 insertions(+), 22 deletions(-) diff --git a/pkg/storaged/block/format-dialog.jsx b/pkg/storaged/block/format-dialog.jsx index e94f26f7f515..be0a29b6c8c5 100644 --- a/pkg/storaged/block/format-dialog.jsx +++ b/pkg/storaged/block/format-dialog.jsx @@ -271,8 +271,20 @@ function format_dialog_internal(client, path, start, size, enable_dos_extended, else at_boot = "local"; - const action_title = create_partition ? _("Create and mount") : _("Format and mount"); - const action_variant = { tag: "nomount", Title: create_partition ? _("Create only") : _("Format only") }; + let action_variants = [ + { tag: null, Title: create_partition ? _("Create and mount") : _("Format and mount") }, + { tag: "nomount", Title: create_partition ? _("Create only") : _("Format only") } + ]; + + const action_variants_for_empty = [ + { tag: null, Title: create_partition ? _("Create") : _("Format") } + ]; + + if (client.in_anaconda_mode()) { + action_variants = [ + { tag: "nomount", Title: create_partition ? _("Create") : _("Format") } + ]; + } const dlg = dialog_open({ Title: title, @@ -402,16 +414,15 @@ function format_dialog_internal(client, path, start, size, enable_dos_extended, dlg.set_options("at_boot", { explanation: mount_explanation[vals.at_boot] }); else if (trigger == "type") { if (dlg.get_value("type") == "empty") { - dlg.update_actions({ Variants: null, Title: _("Format") }); + dlg.update_actions({ Variants: action_variants_for_empty }); } else { - dlg.update_actions({ Variants: [action_variant], Title: action_title }); + dlg.update_actions({ Variants: action_variants }); } } }, Action: { - Title: action_title, + Variants: action_variants, Danger: (create_partition ? null : _("Formatting erases all data on a storage device.")), - Variants: [action_variant], wrapper: job_progress_wrapper(client, block.path, client.blocks_cleartext[block.path]?.path), disable_on_error: usage.Teardown, action: function (vals) { diff --git a/pkg/storaged/filesystem/utils.jsx b/pkg/storaged/filesystem/utils.jsx index 18ad8419057f..a2c0801f5c18 100644 --- a/pkg/storaged/filesystem/utils.jsx +++ b/pkg/storaged/filesystem/utils.jsx @@ -147,24 +147,35 @@ export const MountPoint = ({ fstab_config, forced_options, backing_block, conten } let extra_text = null; - if (!is_filesystem_mounted) { + if (client.in_anaconda_mode()) { if (!old_dir) - extra_text = _("The filesystem has no permanent mount point."); - else - extra_text = _("The filesystem is not mounted."); - } else if (backing_block != content_block) { - if (!opt_never_auto) - extra_text = _("The filesystem will be unlocked and mounted on the next boot. This might require inputting a passphrase."); + extra_text = _("The filesystem has no assigned mount point."); + } else { + if (!is_filesystem_mounted) { + if (!old_dir) + extra_text = _("The filesystem has no permanent mount point."); + else + extra_text = _("The filesystem is not mounted."); + } else if (backing_block != content_block) { + if (!opt_never_auto) + extra_text = _("The filesystem will be unlocked and mounted on the next boot. This might require inputting a passphrase."); + } + } + + if (!mount_point_text) { + mount_point_text = extra_text; + extra_text = null; } - if (extra_text && mount_point_text) + if (extra_text) extra_text = <>
{extra_text}; return ( <> - { mount_point_text && + { mount_point_text && { mount_point_text } + } mounting_dialog(client, content_block || backing_block, @@ -174,7 +185,6 @@ export const MountPoint = ({ fstab_config, forced_options, backing_block, conten - } { extra_text } ); }; @@ -185,9 +195,13 @@ export const mount_point_text = (mount_point, mounted) => { mp_text = client.strip_mount_point_prefix(mount_point); if (mp_text == false) return null; - if (!mounted) + if (!mounted && !client.in_anaconda_mode()) mp_text = mp_text + " " + _("(not mounted)"); - } else - mp_text = _("(not mounted)"); + } else { + if (client.in_anaconda_mode()) + mp_text = _("(no assigned mount point)"); + else + mp_text = _("(not mounted)"); + } return mp_text; }; diff --git a/pkg/storaged/stratis/filesystem.jsx b/pkg/storaged/stratis/filesystem.jsx index 25aa43c62dfc..9d01577855af 100644 --- a/pkg/storaged/stratis/filesystem.jsx +++ b/pkg/storaged/stratis/filesystem.jsx @@ -35,7 +35,7 @@ import { navigate_away_from_card, navigate_to_new_card_location, } from "../pages.jsx"; import { - MountPoint, + MountPoint, mount_point_text, is_valid_mount_point, is_mounted, get_fstab_config, mount_point_text, } from "../filesystem/utils.jsx"; diff --git a/pkg/storaged/stratis/pool.jsx b/pkg/storaged/stratis/pool.jsx index 13e63348e24c..0dfbd0235df9 100644 --- a/pkg/storaged/stratis/pool.jsx +++ b/pkg/storaged/stratis/pool.jsx @@ -74,6 +74,18 @@ function create_fs(pool) { const forced_options = ["x-systemd.requires=stratis-fstab-setup@" + pool.Uuid + ".service"]; const managed_fsys_sizes = client.features.stratis_managed_fsys_sizes && !pool.Overprovisioning; + let action_variants; + if (!client.in_anaconda_mode()) { + action_variants = [ + { tag: null, Title: _("Create and mount") }, + { tag: "nomount", Title: _("Create only") }, + ]; + } else { + action_variants = [ + { tag: "nomount", Title: _("Create") }, + ]; + } + dialog_open({ Title: _("Create filesystem"), Fields: [ @@ -137,8 +149,7 @@ function create_fs(pool) { dlg.set_options("at_boot", { explanation: mount_explanation[vals.at_boot] }); }, Action: { - Title: _("Create and mount"), - Variants: [{ tag: "nomount", Title: _("Create only") }], + Variants: action_variants, action: function (vals) { return client.stratis_create_filesystem(pool, vals.name, vals.size) .then(std_reply)