Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: Don't offer to mount while formatting in Anaconda mode #19807

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions pkg/storaged/block/format-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,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,
Expand Down Expand Up @@ -409,18 +421,17 @@ 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 });
}
if (vals.type == "efi" && !vals.mount_point)
dlg.set_values({ mount_point: "/boot/efi" });
}
},
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) {
Expand Down
41 changes: 22 additions & 19 deletions pkg/storaged/dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,29 +408,32 @@ export const dialog_open = (def) => {
}

const footer_props = (running_title, running_promise) => {
let actions = [];
const actions = [];

function add_action(variant) {
actions.push({
caption: variant.Title,
style: actions.length == 0 ? "primary" : "secondary",
danger: def.Action.Danger || def.Action.DangerButton,
disabled: running_promise != null || (def.Action.disable_on_error &&
errors && errors.toString() != "[object Object]"),
clicked: progress_callback => run_action(progress_callback, variant.tag),
});
}

if (def.Action) {
actions = [
{
caption: def.Action.Title,
style: "primary",
danger: def.Action.Danger || def.Action.DangerButton,
disabled: running_promise != null || (def.Action.disable_on_error &&
errors && errors.toString() != "[object Object]"),
clicked: progress_callback => run_action(progress_callback, null),
}
];
if (def.Action.Title) {
add_action({
Title: def.Action.Title,
tag: null,
});
}

if (def.Action.Variants)
if (def.Action.Variants) {
for (const v of def.Action.Variants) {
actions.push({
caption: v.Title,
style: "secondary",
danger: def.Action.Danger || def.Action.DangerButton,
disabled: running_promise != null,
clicked: progress_callback => run_action(progress_callback, v.tag),
});
add_action(v);
}
}
}

const extra = (
Expand Down
40 changes: 27 additions & 13 deletions pkg/storaged/filesystem/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test. Details

} 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 = <><br />{extra_text}</>;

return (
<>
{ mount_point_text &&
<Flex>
{ mount_point_text &&
<FlexItem>{ mount_point_text }</FlexItem>
}
<FlexItem>
<StorageLink onClick={() => mounting_dialog(client,
content_block || backing_block,
Expand All @@ -174,7 +185,6 @@ export const MountPoint = ({ fstab_config, forced_options, backing_block, conten
</StorageLink>
</FlexItem>
</Flex>
}
{ extra_text }
</>);
};
Expand All @@ -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)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test. Details

else
mp_text = _("(not mounted)");
}
return mp_text;
};
15 changes: 13 additions & 2 deletions pkg/storaged/stratis/pool.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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)
Expand Down
Loading