Skip to content

Commit

Permalink
storaged: make mounting dialog options re-usable
Browse files Browse the repository at this point in the history
  • Loading branch information
jelly committed Jan 17, 2024
1 parent 1135fcb commit 00d677c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 106 deletions.
26 changes: 2 additions & 24 deletions pkg/storaged/block/format-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
77 changes: 43 additions & 34 deletions pkg/storaged/filesystem/mounting-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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")
Expand Down
28 changes: 3 additions & 25 deletions pkg/storaged/stratis/filesystem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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")
Expand Down
25 changes: 2 additions & 23 deletions pkg/storaged/stratis/pool.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 00d677c

Please sign in to comment.