From 00d677cb600947c11bd1806ec8e3493bb1e66e06 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Tue, 16 Jan 2024 18:47:14 +0100 Subject: [PATCH] storaged: make mounting dialog options re-usable --- pkg/storaged/block/format-dialog.jsx | 26 +------ pkg/storaged/filesystem/mounting-dialog.jsx | 77 ++++++++++++--------- pkg/storaged/stratis/filesystem.jsx | 28 +------- pkg/storaged/stratis/pool.jsx | 25 +------ 4 files changed, 50 insertions(+), 106 deletions(-) diff --git a/pkg/storaged/block/format-dialog.jsx b/pkg/storaged/block/format-dialog.jsx index b30edfbe3dcf..cef152c6f5c9 100644 --- a/pkg/storaged/block/format-dialog.jsx +++ b/pkg/storaged/block/format-dialog.jsx @@ -41,6 +41,7 @@ import { import { get_fstab_config, is_valid_mount_point } from "../filesystem/utils.jsx"; import { init_existing_passphrase, unlock_with_type } from "../crypto/keyslots.jsx"; import { job_progress_wrapper } from "../jobs-panel.jsx"; +import { at_boot_input } from "../filesystem/mounting-dialog.jsx"; const _ = cockpit.gettext; @@ -380,30 +381,7 @@ function format_dialog_internal(client, path, start, size, enable_dos_extended, }) ] }), - SelectOne("at_boot", _("At boot"), - { - visible: is_filesystem, - value: at_boot, - explanation: mount_explanation[at_boot], - choices: [ - { - value: "local", - title: _("Mount before services start"), - }, - { - value: "nofail", - title: _("Mount without waiting, ignore failure"), - }, - { - value: "netdev", - title: _("Mount after network becomes available, ignore failure"), - }, - { - value: "never", - title: _("Do not mount"), - }, - ] - }), + at_boot_input(at_boot, is_filesystem), CheckBoxes("mount_options", _("Mount options"), { visible: is_filesystem, diff --git a/pkg/storaged/filesystem/mounting-dialog.jsx b/pkg/storaged/filesystem/mounting-dialog.jsx index d73283e18823..6d6c9ba01fa4 100644 --- a/pkg/storaged/filesystem/mounting-dialog.jsx +++ b/pkg/storaged/filesystem/mounting-dialog.jsx @@ -42,6 +42,47 @@ import { const _ = cockpit.gettext; +export const mount_options = (opt_ro, extra_options) => { + return CheckBoxes("mount_options", _("Mount options"), + { + value: { + ro: opt_ro, + extra: extra_options || false + }, + fields: [ + { title: _("Mount read only"), tag: "ro" }, + { title: _("Custom mount options"), tag: "extra", type: "checkboxWithInput" }, + ] + }); +}; + +export const at_boot_input = (at_boot, is_filesystem) => { + return SelectOne("at_boot", _("At boot"), + { + visible: is_filesystem, + value: at_boot, + explanation: mount_explanation[at_boot], + choices: [ + { + value: "local", + title: _("Mount before services start"), + }, + { + value: "nofail", + title: _("Mount without waiting, ignore failure"), + }, + { + value: "netdev", + title: _("Mount after network becomes available, ignore failure"), + }, + { + value: "never", + title: _("Do not mount"), + }, + ] + }); +}; + export function mounting_dialog(client, block, mode, forced_options, subvol) { const block_fsys = client.blocks_fsys[block.path]; const [old_config, old_dir, old_opts, old_parents] = get_fstab_config(block, true, subvol); @@ -210,40 +251,8 @@ export function mounting_dialog(client, block, mode, forced_options, subvol) { true, subvol) }), - CheckBoxes("mount_options", _("Mount options"), - { - value: { - ro: opt_ro, - extra: extra_options || false - }, - fields: [ - { title: _("Mount read only"), tag: "ro" }, - { title: _("Custom mount options"), tag: "extra", type: "checkboxWithInput" }, - ] - }), - SelectOne("at_boot", _("At boot"), - { - value: at_boot, - explanation: mount_explanation[at_boot], - choices: [ - { - value: "local", - title: _("Mount before services start"), - }, - { - value: "nofail", - title: _("Mount without waiting, ignore failure"), - }, - { - value: "netdev", - title: _("Mount after network becomes available, ignore failure"), - }, - { - value: "never", - title: _("Do not mount"), - }, - ] - }), + mount_options(opt_ro, extra_options), + at_boot_input(at_boot), ]; if (block.IdUsage == "crypto" && mode == "mount") diff --git a/pkg/storaged/stratis/filesystem.jsx b/pkg/storaged/stratis/filesystem.jsx index 25aa43c62dfc..7bf7223478ff 100644 --- a/pkg/storaged/stratis/filesystem.jsx +++ b/pkg/storaged/stratis/filesystem.jsx @@ -25,7 +25,7 @@ import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index. import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js"; import { - dialog_open, TextInput, CheckBoxes, SelectOne, BlockingMessage, TeardownMessage, + dialog_open, TextInput, CheckBoxes, BlockingMessage, TeardownMessage, init_active_usage_processes, } from "../dialog.jsx"; import { StorageUsageBar, StorageLink } from "../storage-controls.jsx"; @@ -40,7 +40,7 @@ import { get_fstab_config, mount_point_text, } from "../filesystem/utils.jsx"; import { MismountAlert, check_mismounted_fsys } from "../filesystem/mismounting.jsx"; -import { mounting_dialog } from "../filesystem/mounting-dialog.jsx"; +import { mounting_dialog, at_boot_input } from "../filesystem/mounting-dialog.jsx"; import { fmt_size, get_active_usage, teardown_active_usage } from "../utils.js"; import { std_reply, validate_fs_name, set_mount_options, destroy_filesystem } from "./utils.jsx"; import { mount_explanation } from "../block/format-dialog.jsx"; @@ -108,29 +108,7 @@ export function make_stratis_filesystem_page(parent, pool, fsys, { title: _("Custom mount options"), tag: "extra", type: "checkboxWithInput" }, ] }), - SelectOne("at_boot", _("At boot"), - { - value: "nofail", - explanation: mount_explanation.nofail, - choices: [ - { - value: "local", - title: _("Mount before services start"), - }, - { - value: "nofail", - title: _("Mount without waiting, ignore failure"), - }, - { - value: "netdev", - title: _("Mount after network becomes available, ignore failure"), - }, - { - value: "never", - title: _("Do not mount"), - }, - ] - }), + at_boot_input("nofail"), ], update: function (dlg, vals, trigger) { if (trigger == "at_boot") diff --git a/pkg/storaged/stratis/pool.jsx b/pkg/storaged/stratis/pool.jsx index 0dfbd0235df9..5a1d1f27162e 100644 --- a/pkg/storaged/stratis/pool.jsx +++ b/pkg/storaged/stratis/pool.jsx @@ -51,6 +51,7 @@ import { import { validate_url, get_tang_adv } from "../crypto/tang.jsx"; import { is_valid_mount_point } from "../filesystem/utils.jsx"; import { mount_explanation } from "../block/format-dialog.jsx"; +import { at_boot_input } from "../filesystem/mounting-dialog.jsx"; import { validate_pool_name, std_reply, with_keydesc, with_stored_passphrase, @@ -120,29 +121,7 @@ function create_fs(pool) { { title: _("Custom mount options"), tag: "extra", type: "checkboxWithInput" }, ] }), - SelectOne("at_boot", _("At boot"), - { - value: client.in_anaconda_mode() ? "local" : "nofail", - explanation: mount_explanation.nofail, - choices: [ - { - value: "local", - title: _("Mount before services start"), - }, - { - value: "nofail", - title: _("Mount without waiting, ignore failure"), - }, - { - value: "netdev", - title: _("Mount after network becomes available, ignore failure"), - }, - { - value: "never", - title: _("Do not mount"), - }, - ] - }), + at_boot_input(client.in_anaconda_mode() ? "local" : "nofail"), ], update: function (dlg, vals, trigger) { if (trigger == "at_boot")