Add more framework for workflow

This commit is contained in:
2Shirt 2025-11-08 18:43:50 -08:00
parent cf87ac32af
commit f51a4e85c4
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
5 changed files with 45 additions and 5 deletions

View file

@ -188,5 +188,20 @@
"<Ctrl-c>": "Quit",
"<Ctrl-z>": "Suspend"
},
"ScanWinImages": {
"<Enter>": "Process",
"<n>": "FindWimNetwork",
"<q>": "Quit",
"<Ctrl-d>": "Quit",
"<Ctrl-c>": "Quit",
"<Ctrl-z>": "Suspend"
},
"SetUserName": {
"<Enter>": "Process",
"<Esc>": "Process",
"<Ctrl-d>": "Quit",
"<Ctrl-c>": "Quit",
"<Ctrl-z>": "Suspend"
},
},
}

View file

@ -55,6 +55,8 @@ pub enum Action {
OpenTerminal,
Restart,
Shutdown,
// App (Win-Installer)
FindWimNetwork,
// Screens
DismissPopup,
DisplayPopup(PopupType, String),

View file

@ -245,10 +245,23 @@ impl App<'_> {
// }
Action::Resize(w, h) => self.handle_resize(tui, w, h)?,
Action::Render => self.render(tui)?,
Action::FindWimNetwork => {
self.state.reset_network();
// TODO: Actually scan network!
}
Action::SetMode(mode) => {
self.mode = mode;
if self.mode == Mode::ScanDisks {
self.state.reset();
match mode {
Mode::Done => {
self.action_tx.send(Action::DisplayPopup(
popup::Type::Success,
popup::fortune(),
))?;
}
Mode::ScanDisks => {
self.state.reset_all();
}
_ => {}
}
self.action_tx.send(Action::UpdateFooter(String::from(
"(Enter) to select / (t) for terminal / (p) to power off / (r) to restart",

View file

@ -40,13 +40,19 @@ impl State<'_> {
}
}
pub fn reset(&mut self) {
pub fn reset_all(&mut self) {
self.disk_index_dest = None;
self.part_index_boot = None;
self.wim_file_index = None;
self.wim_image_index = None;
if let Ok(mut sources) = self.wim_sources.lock() {
sources.reset();
sources.reset_all();
}
}
pub fn reset_network(&mut self) {
if let Ok(mut sources) = self.wim_sources.lock() {
sources.reset_network();
}
}

View file

@ -99,10 +99,14 @@ impl WimSources<'_> {
Default::default()
}
pub fn reset(&mut self) {
pub fn reset_all(&mut self) {
self.local.clear();
self.network.clear();
}
pub fn reset_network(&mut self) {
self.network.clear();
}
}
fn get_wim_xml(wim_file: &str) -> std::io::Result<File> {