From c5c38a90268ef25f2e7a15ed728faa6bef4c8a05 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 12 Apr 2024 10:58:39 +0300 Subject: [PATCH] storage: Simplify "Initialize disk" dialog Use radio buttons, and only offer MBR when it will work. --- pkg/storaged/block/actions.jsx | 6 ++--- .../initialize-disk-dialog.jsx} | 26 +++++++++---------- test/reference | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) rename pkg/storaged/{block/format-disk-dialog.jsx => partitions/initialize-disk-dialog.jsx} (73%) diff --git a/pkg/storaged/block/actions.jsx b/pkg/storaged/block/actions.jsx index 0d32ae06467d..d39fd89ec1a7 100644 --- a/pkg/storaged/block/actions.jsx +++ b/pkg/storaged/block/actions.jsx @@ -20,7 +20,7 @@ import cockpit from "cockpit"; import client from "../client"; -import { format_disk } from "./format-disk-dialog.jsx"; +import { initialize_disk_dialog } from "../partitions/initialize-disk-dialog.jsx"; import { format_dialog } from "./format-dialog.jsx"; import { format_swap_dialog } from "../swap/format-dialog.jsx"; import { erase_dialog } from "./erase-dialog.jsx"; @@ -37,8 +37,8 @@ export function block_actions(block, kind) { if (client.blocks_available[block.path]) { if (kind == "part") { actions.push({ - title: _("Create partitions"), - action: () => format_disk(block), + title: _("Initialize for partitions"), + action: () => initialize_disk_dialog(block), primary: true, excuse, }); diff --git a/pkg/storaged/block/format-disk-dialog.jsx b/pkg/storaged/partitions/initialize-disk-dialog.jsx similarity index 73% rename from pkg/storaged/block/format-disk-dialog.jsx rename to pkg/storaged/partitions/initialize-disk-dialog.jsx index 875316ff4326..dd91d3592f30 100644 --- a/pkg/storaged/block/format-disk-dialog.jsx +++ b/pkg/storaged/partitions/initialize-disk-dialog.jsx @@ -22,7 +22,7 @@ import client from "../client"; import { dialog_open, - SelectOne, + SelectOneRadioVertical, BlockingMessage, TeardownMessage, init_active_usage_processes } from "../dialog.jsx"; @@ -31,8 +31,8 @@ import { job_progress_wrapper } from "../jobs-panel.jsx"; const _ = cockpit.gettext; -export function format_disk(block) { - const usage = get_active_usage(client, block.path, _("initialize"), _("delete")); +export function initialize_disk_dialog(block) { + const usage = get_active_usage(client, block.path, _("write partition table"), _("delete")); if (usage.Blocking) { dialog_open({ @@ -42,24 +42,24 @@ export function format_disk(block) { return; } + const offer_mbr = block.Size < 2 * 1024 * 1024 * 1024 * 1024; // 2 TiB + dialog_open({ - Title: cockpit.format(_("Create partitions on $0"), block_name(block)), + Title: cockpit.format(_("Initialize $0 for partitions"), block_name(block)), Teardown: TeardownMessage(usage), Fields: [ - SelectOne("type", _("Type"), + SelectOneRadioVertical("type", _("Type"), { value: "gpt", choices: [ - { value: "dos", title: _("Compatible with all systems and devices (MBR)") }, - { - value: "gpt", - title: _("Compatible with modern system and hard disks > 2TB (GPT)") - }, - ] + { value: "gpt", title: _("Modern (GPT)") }, + { value: "dos", title: _("Legacy (MBR)") }, + ], + visible: () => offer_mbr, }), ], Action: { - Title: _("Create partition table"), + Title: _("Initialize for partitions"), wrapper: job_progress_wrapper(client, block.path), disable_on_error: usage.Teardown, action: async function (vals) { @@ -68,7 +68,7 @@ export function format_disk(block) { }; await teardown_active_usage(client, usage); - await block.Format(vals.type, options); + await block.Format(offer_mbr ? vals.type : "gpt", options); await reload_systemd(); } }, diff --git a/test/reference b/test/reference index de396c5e6ec1..612b0904a905 160000 --- a/test/reference +++ b/test/reference @@ -1 +1 @@ -Subproject commit de396c5e6ec1fff06ef1bdb1363b2f85a501ee88 +Subproject commit 612b0904a905e7a8d67778f63601e14d38ac2086