fix(tui): simplify dependency cleanup dialog

This commit is contained in:
objz committed 2026-07-28 19:59:20 +02:00
1 parent 12074f63d5
commit 7d904ccdfa
2 files changed
+25 -28

No files matched your search

+6 -3
View File
@@ -37,7 +37,7 @@ fn instance_delete_confirmation_renders_the_complete_frame() {
} }
#[test] #[test]
fn orphan_dependency_confirmation_wraps_its_complete_message() { fn orphan_dependency_confirmation_renders_simple_list() {
let mut ui = UiHarness::new(); let mut ui = UiHarness::new();
crate::tui::widgets::popups::confirm::set_pending_orphan_dependencies(vec![ crate::tui::widgets::popups::confirm::set_pending_orphan_dependencies(vec![
"mods/sodium-fabric-0.9.1+mc26.2.jar".into(), "mods/sodium-fabric-0.9.1+mc26.2.jar".into(),
@@ -47,8 +47,11 @@ fn orphan_dependency_confirmation_wraps_its_complete_message() {
ui.draw(); ui.draw();
let screen = ui.screen(); let screen = ui.screen();
assert!(screen.contains("needs these libraries anymore"), "{screen}"); assert!(
assert!(screen.contains('▣'), "{screen}"); !screen.contains("needs these libraries anymore"),
"{screen}"
);
assert!(screen.contains('•'), "{screen}");
assert!( assert!(
screen.contains("sodium-fabric-0.9.1+mc26.2.jar"), screen.contains("sodium-fabric-0.9.1+mc26.2.jar"),
"{screen}" "{screen}"
+19 -25
View File
@@ -47,7 +47,7 @@ pub enum ConfirmTarget {
impl ConfirmTarget { impl ConfirmTarget {
fn title(&self) -> String { fn title(&self) -> String {
match self { match self {
Self::OrphanDependencies { .. } => " ◇ Clean up libraries ".to_owned(), Self::OrphanDependencies { .. } => " Remove unused libraries ".to_owned(),
_ => format!(" Delete '{}' ", self.name()), _ => format!(" Delete '{}' ", self.name()),
} }
} }
@@ -63,10 +63,10 @@ impl ConfirmTarget {
} }
ConfirmTarget::Content { dependents, .. } if !dependents.is_empty() => { ConfirmTarget::Content { dependents, .. } if !dependents.is_empty() => {
format!( format!(
"Still required by installed mods:\n\n{}\n\n! Deleting this library may break those mods.", "Still required by installed mods:\n{}\n! Deleting this library may break those mods.",
dependents dependents
.iter() .iter()
.map(|name| format!(" ▣ {name}")) .map(|name| format!("• {name}"))
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join("\n") .join("\n")
) )
@@ -74,21 +74,18 @@ impl ConfirmTarget {
ConfirmTarget::Content { .. } => { ConfirmTarget::Content { .. } => {
"This will permanently remove the selected item".to_owned() "This will permanently remove the selected item".to_owned()
} }
ConfirmTarget::OrphanDependencies { paths } => { ConfirmTarget::OrphanDependencies { paths } => paths
format!( .iter()
"No installed mod needs these libraries anymore.\n\n{}", .map(|path| {
paths format!(
.iter() "• {}",
.map(|path| format!( path.file_name()
" ▣ {}", .and_then(|name| name.to_str())
path.file_name() .unwrap_or("library")
.and_then(|name| name.to_str()) )
.unwrap_or("library") })
)) .collect::<Vec<_>>()
.collect::<Vec<_>>() .join("\n"),
.join("\n")
)
}
} }
} }
@@ -204,7 +201,7 @@ impl Widget for ConfirmPopup {
let text_dim = theme.text_dim(); let text_dim = theme.text_dim();
let error = theme.error(); let error = theme.error();
let body = self.body; let body = self.body;
let styled_list = body.contains("▣ "); let styled_list = body.contains("• ");
let popup = PopupFrame { let popup = PopupFrame {
title, title,
border_color, border_color,
@@ -215,13 +212,10 @@ impl Widget for ConfirmPopup {
let lines = body let lines = body
.lines() .lines()
.map(|line| { .map(|line| {
if let Some(value) = line.trim_start().strip_prefix("▣ ") { if let Some(value) = line.strip_prefix("• ") {
Line::from(vec![ Line::from(vec![
Span::styled(" ▣ ", Style::default().fg(accent)), Span::styled("• ", Style::default().fg(accent)),
Span::styled( Span::styled(value.to_owned(), Style::default().fg(text)),
value.to_owned(),
Style::default().fg(text).add_modifier(Modifier::BOLD),
),
]) ])
} else if line.starts_with('!') { } else if line.starts_with('!') {
Line::styled(line.to_owned(), Style::default().fg(error)) Line::styled(line.to_owned(), Style::default().fg(error))