From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 7E842FDEE for ; Tue, 25 Jul 2023 10:36:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5F33F175D7 for ; Tue, 25 Jul 2023 10:35:54 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 25 Jul 2023 10:35:53 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5A25143F55 for ; Tue, 25 Jul 2023 10:35:53 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Tue, 25 Jul 2023 10:35:41 +0200 Message-ID: <20230725083544.212737-3-c.heiss@proxmox.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725083544.212737-1-c.heiss@proxmox.com> References: <20230725083544.212737-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.051 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH installer 2/3] tui: bootdisk: rename `disks` parameter to `avail_disks` X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jul 2023 08:36:24 -0000 This better conveys its role/contents to the reader, as `disks` might be ambiguous. No functional changes. Signed-off-by: Christoph Heiss --- proxmox-tui-installer/src/views/bootdisk.rs | 45 ++++++++++++--------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/proxmox-tui-installer/src/views/bootdisk.rs b/proxmox-tui-installer/src/views/bootdisk.rs index d0f5abf..c3ac60f 100644 --- a/proxmox-tui-installer/src/views/bootdisk.rs +++ b/proxmox-tui-installer/src/views/bootdisk.rs @@ -26,13 +26,13 @@ pub struct BootdiskOptionsView { } impl BootdiskOptionsView { - pub fn new(disks: &[Disk], options: &BootdiskOptions) -> Self { + pub fn new(avail_disks: &[Disk], options: &BootdiskOptions) -> Self { let bootdisk_form = FormView::new() .child( "Target harddisk", SelectView::new() .popup() - .with_all(disks.iter().map(|d| (d.to_string(), d.clone()))), + .with_all(avail_disks.iter().map(|d| (d.to_string(), d.clone()))), ) .with_name("bootdisk-options-target-disk"); @@ -41,10 +41,10 @@ impl BootdiskOptionsView { let advanced_button = LinearLayout::horizontal() .child(DummyView.full_width()) .child(Button::new("Advanced options", { - let disks = disks.to_owned(); + let avail_disks = avail_disks.to_owned(); let options = advanced_options.clone(); move |siv| { - siv.add_layer(advanced_options_view(&disks, options.clone())); + siv.add_layer(advanced_options_view(&avail_disks, options.clone())); } })); @@ -87,7 +87,7 @@ struct AdvancedBootdiskOptionsView { } impl AdvancedBootdiskOptionsView { - fn new(disks: &[Disk], options: &BootdiskOptions) -> Self { + fn new(avail_disks: &[Disk], options: &BootdiskOptions) -> Self { let enable_btrfs = crate::setup_info().config.enable_btrfs; let filter_btrfs = |fstype: &&FsType| -> bool { enable_btrfs || !fstype.is_btrfs() }; @@ -108,8 +108,8 @@ impl AdvancedBootdiskOptionsView { .unwrap_or_default(), ) .on_submit({ - let disks = disks.to_owned(); - move |siv, fstype| Self::fstype_on_submit(siv, &disks, fstype) + let avail_disks = avail_disks.to_owned(); + move |siv, fstype| Self::fstype_on_submit(siv, &avail_disks, fstype) }); let mut view = LinearLayout::vertical() @@ -120,17 +120,17 @@ impl AdvancedBootdiskOptionsView { match &options.advanced { AdvancedBootdiskOptions::Lvm(lvm) => view.add_child(LvmBootdiskOptionsView::new(lvm)), AdvancedBootdiskOptions::Zfs(zfs) => { - view.add_child(ZfsBootdiskOptionsView::new(disks, zfs)) + view.add_child(ZfsBootdiskOptionsView::new(avail_disks, zfs)) } AdvancedBootdiskOptions::Btrfs(btrfs) => { - view.add_child(BtrfsBootdiskOptionsView::new(disks, btrfs)) + view.add_child(BtrfsBootdiskOptionsView::new(avail_disks, btrfs)) } }; Self { view } } - fn fstype_on_submit(siv: &mut Cursive, disks: &[Disk], fstype: &FsType) { + fn fstype_on_submit(siv: &mut Cursive, avail_disks: &[Disk], fstype: &FsType) { siv.call_on_name("advanced-bootdisk-options-dialog", |view: &mut Dialog| { if let Some(AdvancedBootdiskOptionsView { view }) = view.get_content_mut().downcast_mut() @@ -138,15 +138,15 @@ impl AdvancedBootdiskOptionsView { view.remove_child(3); match fstype { FsType::Ext4 | FsType::Xfs => view.add_child(LvmBootdiskOptionsView::new( - &LvmBootdiskOptions::defaults_from(&disks[0]), + &LvmBootdiskOptions::defaults_from(&avail_disks[0]), )), FsType::Zfs(_) => view.add_child(ZfsBootdiskOptionsView::new( - disks, - &ZfsBootdiskOptions::defaults_from(disks), + avail_disks, + &ZfsBootdiskOptions::defaults_from(avail_disks), )), FsType::Btrfs(_) => view.add_child(BtrfsBootdiskOptionsView::new( - disks, - &BtrfsBootdiskOptions::defaults_from(disks), + avail_disks, + &BtrfsBootdiskOptions::defaults_from(avail_disks), )), } } @@ -160,7 +160,7 @@ impl AdvancedBootdiskOptionsView { 0, SelectView::new() .popup() - .with_all(disks.iter().map(|d| (d.to_string(), d.clone()))), + .with_all(avail_disks.iter().map(|d| (d.to_string(), d.clone()))), ); } other => view.replace_child(0, TextView::new(other.to_string())), @@ -523,9 +523,18 @@ impl ViewWrapper for ZfsBootdiskOptionsView { cursive::wrap_impl!(self.view: MultiDiskOptionsView); } -fn advanced_options_view(disks: &[Disk], options_ref: BootdiskOptionsRef) -> impl View { +/// Creates a dialog containing a [`AdvancedBootdiskOptionsView`] and handling confirmation of the +/// dialog by saving the selected configuration in `options_ref`. +/// +/// # Arguments +/// +/// * `avail_disks` - Available disks for the user to select, with their usage depending on the +/// selected filesystem type +/// * `options_ref` - A `BootdiskOptionsRef`, which is used to save the filesystem/RAID +/// configuration in after confirming the dialog. +fn advanced_options_view(avail_disks: &[Disk], options_ref: BootdiskOptionsRef) -> impl View { Dialog::around(AdvancedBootdiskOptionsView::new( - disks, + avail_disks, &(*options_ref).borrow(), )) .title("Advanced bootdisk options") -- 2.41.0