]> git.proxmox.com Git - pve-installer.git/commitdiff
tui: install_progress: split out prompt logic into own function
authorChristoph Heiss <c.heiss@proxmox.com>
Fri, 10 Nov 2023 14:17:23 +0000 (15:17 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 11 Nov 2023 13:08:41 +0000 (14:08 +0100)
No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-tui-installer/src/views/install_progress.rs

index 9f4b8c4cd87216894b5615ef0d1b7d6d605d285b..fceb785871644ff2e717e062273f011fb00448d4 100644 (file)
@@ -106,26 +106,7 @@ impl InstallProgressView {
                     })),
                     UiMessage::Prompt(s) => cb_sink.send({
                         let writer = writer.clone();
-                        Box::new(move |siv| {
-                            yes_no_dialog(
-                                siv,
-                                "Prompt",
-                                &s,
-                                Box::new({
-                                    let writer = writer.clone();
-                                    move |_| {
-                                        if let Ok(mut writer) = writer.lock() {
-                                            let _ = writeln!(writer, "ok");
-                                        }
-                                    }
-                                }),
-                                Box::new(move |_| {
-                                    if let Ok(mut writer) = writer.lock() {
-                                        let _ = writeln!(writer);
-                                    }
-                                }),
-                            );
-                        })
+                        Box::new(move |siv| Self::show_prompt(siv, &s, writer))
                     }),
                     UiMessage::Progress(ratio, s) => {
                         counter.set(ratio);
@@ -186,6 +167,27 @@ impl InstallProgressView {
             });
         }
     }
+
+    fn show_prompt<W: Write + 'static>(siv: &mut Cursive, text: &str, writer: Arc<Mutex<W>>) {
+        yes_no_dialog(
+            siv,
+            "Prompt",
+            text,
+            Box::new({
+                let writer = writer.clone();
+                move |_| {
+                    if let Ok(mut writer) = writer.lock() {
+                        let _ = writeln!(writer, "ok");
+                    }
+                }
+            }),
+            Box::new(move |_| {
+                if let Ok(mut writer) = writer.lock() {
+                    let _ = writeln!(writer);
+                }
+            }),
+        );
+    }
 }
 
 impl ViewWrapper for InstallProgressView {