feat: refine settings feedback and controls
This commit is contained in:
1 parent
45d9b85abf
commit
17aff8ec6d
8 files changed
+174
-57
No files matched your search
@@ -49,6 +49,15 @@ pub fn push_error(event: ErrorEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn push_message(level: Level, message: impl Into<String>) {
|
||||||
|
push_error(ErrorEvent {
|
||||||
|
id: 0,
|
||||||
|
level,
|
||||||
|
message: message.into(),
|
||||||
|
pushed_at: Instant::now(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn has_errors() -> bool {
|
pub fn has_errors() -> bool {
|
||||||
match ERROR_EVENTS.lock() {
|
match ERROR_EVENTS.lock() {
|
||||||
|
|||||||
@@ -272,6 +272,17 @@ impl App {
|
|||||||
}
|
}
|
||||||
self.focused
|
self.focused
|
||||||
}
|
}
|
||||||
|
Some(confirm_popup::ConfirmTarget::JvmArguments { .. }) => {
|
||||||
|
self.focused = FocusedArea::InstanceSettings;
|
||||||
|
let confirmed = self.instance_settings.as_mut().and_then(|state| {
|
||||||
|
state.clear_jvm_args();
|
||||||
|
state.confirmed_save()
|
||||||
|
});
|
||||||
|
if let Some((updated, desktop)) = confirmed {
|
||||||
|
self.apply_instance_settings(*updated, desktop, false);
|
||||||
|
}
|
||||||
|
self.focused
|
||||||
|
}
|
||||||
None => FocusedArea::Instances,
|
None => FocusedArea::Instances,
|
||||||
};
|
};
|
||||||
confirm_popup::clear_pending();
|
confirm_popup::clear_pending();
|
||||||
@@ -294,6 +305,9 @@ impl App {
|
|||||||
}
|
}
|
||||||
FocusedArea::InstanceSettings
|
FocusedArea::InstanceSettings
|
||||||
}
|
}
|
||||||
|
Some(confirm_popup::ConfirmTarget::JvmArguments { .. }) => {
|
||||||
|
FocusedArea::InstanceSettings
|
||||||
|
}
|
||||||
_ => FocusedArea::Instances,
|
_ => FocusedArea::Instances,
|
||||||
};
|
};
|
||||||
confirm_popup::clear_pending();
|
confirm_popup::clear_pending();
|
||||||
@@ -735,11 +749,19 @@ impl App {
|
|||||||
self.apply_instance_settings(*updated, desktop, false);
|
self.apply_instance_settings(*updated, desktop, false);
|
||||||
}
|
}
|
||||||
widgets::popups::instance_settings::Action::ConfirmRuntime { name } => {
|
widgets::popups::instance_settings::Action::ConfirmRuntime { name } => {
|
||||||
|
error_buffer::push_message(
|
||||||
|
tracing::Level::WARN,
|
||||||
|
"Some installed mods may be incompatible",
|
||||||
|
);
|
||||||
confirm_popup::set_pending(confirm_popup::ConfirmTarget::InstanceRuntime {
|
confirm_popup::set_pending(confirm_popup::ConfirmTarget::InstanceRuntime {
|
||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
self.focused = FocusedArea::ConfirmDelete;
|
self.focused = FocusedArea::ConfirmDelete;
|
||||||
}
|
}
|
||||||
|
widgets::popups::instance_settings::Action::ConfirmClearJvmArgs { name } => {
|
||||||
|
confirm_popup::set_pending(confirm_popup::ConfirmTarget::JvmArguments { name });
|
||||||
|
self.focused = FocusedArea::ConfirmDelete;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-1
@@ -658,11 +658,22 @@ fn runtime_settings_use_the_shared_confirmation_popup() {
|
|||||||
ui.draw();
|
ui.draw();
|
||||||
assert!(ui.screen().contains("Change runtime"));
|
assert!(ui.screen().contains("Change runtime"));
|
||||||
assert!(!ui.screen().contains("Target:"));
|
assert!(!ui.screen().contains("Target:"));
|
||||||
|
assert!(ui.screen().contains("Apply this runtime change"));
|
||||||
assert!(
|
assert!(
|
||||||
ui.screen()
|
!ui.screen()
|
||||||
.contains("Some installed mods may be incompatible")
|
.contains("Some installed mods may be incompatible")
|
||||||
);
|
);
|
||||||
assert!(!ui.screen().contains("incompatible."));
|
assert!(!ui.screen().contains("incompatible."));
|
||||||
|
assert!(
|
||||||
|
crate::feedback::errors::ERROR_EVENTS
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.any(|event| {
|
||||||
|
event.level == tracing::Level::WARN
|
||||||
|
&& event.message == "Some installed mods may be incompatible"
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
ui.key(KeyCode::Esc);
|
ui.key(KeyCode::Esc);
|
||||||
assert_eq!(ui.app.focused, FocusedArea::InstanceSettings);
|
assert_eq!(ui.app.focused, FocusedArea::InstanceSettings);
|
||||||
@@ -670,6 +681,48 @@ fn runtime_settings_use_the_shared_confirmation_popup() {
|
|||||||
assert_eq!(ui.app.focused, FocusedArea::Settings);
|
assert_eq!(ui.app.focused, FocusedArea::Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn clearing_jvm_arguments_requires_confirmation_and_autosaves() {
|
||||||
|
let mut ui = UiHarness::new();
|
||||||
|
ui.add_instance("jvm-clear-test");
|
||||||
|
ui.key(KeyCode::Char('E'));
|
||||||
|
ui.app.instance_settings.as_mut().unwrap().draft.jvm_args =
|
||||||
|
vec!["-XX:+UseG1GC".to_owned(), "-Xss1M".to_owned()];
|
||||||
|
|
||||||
|
for _ in 0..6 {
|
||||||
|
ui.key(KeyCode::Char('j'));
|
||||||
|
}
|
||||||
|
ui.key(KeyCode::Char('d'));
|
||||||
|
|
||||||
|
assert_eq!(ui.app.focused, FocusedArea::ConfirmDelete);
|
||||||
|
assert!(matches!(
|
||||||
|
confirm::pending_target(),
|
||||||
|
Some(confirm::ConfirmTarget::JvmArguments { name }) if name == "jvm-clear-test"
|
||||||
|
));
|
||||||
|
assert_eq!(
|
||||||
|
ui.app
|
||||||
|
.instance_settings
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.draft
|
||||||
|
.jvm_args
|
||||||
|
.len(),
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
|
ui.key(KeyCode::Enter);
|
||||||
|
|
||||||
|
assert_eq!(ui.app.focused, FocusedArea::InstanceSettings);
|
||||||
|
assert!(
|
||||||
|
ui.app
|
||||||
|
.instances_state
|
||||||
|
.selected_instance()
|
||||||
|
.unwrap()
|
||||||
|
.jvm_args
|
||||||
|
.is_empty()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn instance_settings_validation_errors_use_the_toast_buffer() {
|
fn instance_settings_validation_errors_use_the_toast_buffer() {
|
||||||
let mut ui = UiHarness::new();
|
let mut ui = UiHarness::new();
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ pub enum ConfirmTarget {
|
|||||||
InstanceRuntime {
|
InstanceRuntime {
|
||||||
name: String,
|
name: String,
|
||||||
},
|
},
|
||||||
|
JvmArguments {
|
||||||
|
name: String,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfirmTarget {
|
impl ConfirmTarget {
|
||||||
@@ -55,6 +58,7 @@ impl ConfirmTarget {
|
|||||||
match self {
|
match self {
|
||||||
Self::OrphanDependencies { .. } => " Remove unused dependencies ".to_owned(),
|
Self::OrphanDependencies { .. } => " Remove unused dependencies ".to_owned(),
|
||||||
Self::InstanceRuntime { .. } => " Change runtime ".to_owned(),
|
Self::InstanceRuntime { .. } => " Change runtime ".to_owned(),
|
||||||
|
Self::JvmArguments { .. } => " Clear JVM arguments ".to_owned(),
|
||||||
_ => format!(" Delete '{}' ", self.name()),
|
_ => format!(" Delete '{}' ", self.name()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,9 +97,8 @@ impl ConfirmTarget {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n"),
|
.join("\n"),
|
||||||
ConfirmTarget::InstanceRuntime { .. } => {
|
ConfirmTarget::InstanceRuntime { .. } => "Apply this runtime change".to_owned(),
|
||||||
"Some installed mods may be incompatible".to_owned()
|
ConfirmTarget::JvmArguments { .. } => "Remove all JVM arguments".to_owned(),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +110,7 @@ impl ConfirmTarget {
|
|||||||
ConfirmTarget::Content { name, .. } => name,
|
ConfirmTarget::Content { name, .. } => name,
|
||||||
ConfirmTarget::OrphanDependencies { .. } => "unused dependencies",
|
ConfirmTarget::OrphanDependencies { .. } => "unused dependencies",
|
||||||
ConfirmTarget::InstanceRuntime { name, .. } => name,
|
ConfirmTarget::InstanceRuntime { name, .. } => name,
|
||||||
|
ConfirmTarget::JvmArguments { name, .. } => name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +119,7 @@ impl ConfirmTarget {
|
|||||||
Self::Content { dependents, .. } if !dependents.is_empty() => " delete anyway",
|
Self::Content { dependents, .. } if !dependents.is_empty() => " delete anyway",
|
||||||
Self::OrphanDependencies { .. } => " remove all",
|
Self::OrphanDependencies { .. } => " remove all",
|
||||||
Self::InstanceRuntime { .. } => " change",
|
Self::InstanceRuntime { .. } => " change",
|
||||||
|
Self::JvmArguments { .. } => " clear",
|
||||||
_ => " confirm",
|
_ => " confirm",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,7 +186,6 @@ pub struct ConfirmPopup {
|
|||||||
title: String,
|
title: String,
|
||||||
body: String,
|
body: String,
|
||||||
confirm_label: &'static str,
|
confirm_label: &'static str,
|
||||||
runtime_confirmation: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfirmPopup {
|
impl ConfirmPopup {
|
||||||
@@ -190,7 +194,6 @@ impl ConfirmPopup {
|
|||||||
title: target.title(),
|
title: target.title(),
|
||||||
body: target.body(),
|
body: target.body(),
|
||||||
confirm_label: target.confirm_label(),
|
confirm_label: target.confirm_label(),
|
||||||
runtime_confirmation: matches!(target, ConfirmTarget::InstanceRuntime { .. }),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,9 +217,7 @@ impl Widget for ConfirmPopup {
|
|||||||
let text = theme.text();
|
let text = theme.text();
|
||||||
let text_dim = theme.text_dim();
|
let text_dim = theme.text_dim();
|
||||||
let error = theme.error();
|
let error = theme.error();
|
||||||
let warning = theme.warning();
|
|
||||||
let body = self.body;
|
let body = self.body;
|
||||||
let runtime_confirmation = self.runtime_confirmation;
|
|
||||||
let styled_list = body.contains("• ");
|
let styled_list = body.contains("• ");
|
||||||
let popup = PopupFrame {
|
let popup = PopupFrame {
|
||||||
title,
|
title,
|
||||||
@@ -233,8 +234,6 @@ impl Widget for ConfirmPopup {
|
|||||||
Span::styled("• ", Style::default().fg(accent)),
|
Span::styled("• ", Style::default().fg(accent)),
|
||||||
Span::styled(value.to_owned(), Style::default().fg(text)),
|
Span::styled(value.to_owned(), Style::default().fg(text)),
|
||||||
])
|
])
|
||||||
} else if runtime_confirmation && line.starts_with("Some installed mods") {
|
|
||||||
Line::styled(line.to_owned(), Style::default().fg(warning))
|
|
||||||
} 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))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -479,20 +479,21 @@ fn render_picker(frame: &mut Frame, area: Rect, values: &[String], selected: usi
|
|||||||
super::select_list::render(items, selected, area, frame.buffer_mut());
|
super::select_list::render(items, selected, area, frame.buffer_mut());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_java_picker(frame: &mut Frame, area: Rect, state: &State) {
|
fn render_java_picker(frame: &mut Frame, area: Rect, state: &mut State) {
|
||||||
let theme = THEME.as_ref();
|
let theme = THEME.as_ref();
|
||||||
let mut list_area = area;
|
let mut list_area = area;
|
||||||
if let Some(status) = state.java_picker.status() {
|
if let Some(status) = state.java_picker.take_status() {
|
||||||
let (message, color) = match status {
|
match status {
|
||||||
Ok(message) => (message.to_owned(), theme.text_dim()),
|
Ok(message) => {
|
||||||
Err(error) => (error, theme.error()),
|
frame.render_widget(
|
||||||
};
|
Paragraph::new(message).style(Style::default().fg(theme.text_dim())),
|
||||||
frame.render_widget(
|
Rect { height: 1, ..area },
|
||||||
Paragraph::new(message).style(Style::default().fg(color)),
|
);
|
||||||
Rect { height: 1, ..area },
|
list_area.y = list_area.y.saturating_add(1);
|
||||||
);
|
list_area.height = list_area.height.saturating_sub(1);
|
||||||
list_area.y = list_area.y.saturating_add(1);
|
}
|
||||||
list_area.height = list_area.height.saturating_sub(1);
|
Err(error) => crate::feedback::errors::push_message(tracing::Level::ERROR, error),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super::select_list::render(
|
super::select_list::render(
|
||||||
state.java_picker.items(),
|
state.java_picker.items(),
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ enum PickerLoad {
|
|||||||
Idle,
|
Idle,
|
||||||
Loading,
|
Loading,
|
||||||
Loaded,
|
Loaded,
|
||||||
Error(String),
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -107,6 +107,7 @@ pub enum Action {
|
|||||||
Save(Box<InstanceConfig>, bool),
|
Save(Box<InstanceConfig>, bool),
|
||||||
Error(String),
|
Error(String),
|
||||||
ConfirmRuntime { name: String },
|
ConfirmRuntime { name: String },
|
||||||
|
ConfirmClearJvmArgs { name: String },
|
||||||
OpenRaw,
|
OpenRaw,
|
||||||
Close,
|
Close,
|
||||||
}
|
}
|
||||||
@@ -361,7 +362,13 @@ impl State {
|
|||||||
.lock()
|
.lock()
|
||||||
.unwrap_or_else(std::sync::PoisonError::into_inner) = match result {
|
.unwrap_or_else(std::sync::PoisonError::into_inner) = match result {
|
||||||
Ok(versions) => LoadState::Loaded(versions),
|
Ok(versions) => LoadState::Loaded(versions),
|
||||||
Err(error) => LoadState::Error(error),
|
Err(error) => {
|
||||||
|
crate::feedback::errors::push_message(
|
||||||
|
tracing::Level::ERROR,
|
||||||
|
format!("Failed to load game versions: {error}"),
|
||||||
|
);
|
||||||
|
LoadState::Error(error)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
crate::feedback::request_redraw();
|
crate::feedback::request_redraw();
|
||||||
});
|
});
|
||||||
@@ -389,7 +396,13 @@ impl State {
|
|||||||
.lock()
|
.lock()
|
||||||
.unwrap_or_else(std::sync::PoisonError::into_inner) = match result {
|
.unwrap_or_else(std::sync::PoisonError::into_inner) = match result {
|
||||||
Ok(versions) => LoadState::Loaded(versions),
|
Ok(versions) => LoadState::Loaded(versions),
|
||||||
Err(error) => LoadState::Error(error),
|
Err(error) => {
|
||||||
|
crate::feedback::errors::push_message(
|
||||||
|
tracing::Level::ERROR,
|
||||||
|
format!("Failed to load loader versions: {error}"),
|
||||||
|
);
|
||||||
|
LoadState::Error(error)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
crate::feedback::request_redraw();
|
crate::feedback::request_redraw();
|
||||||
});
|
});
|
||||||
@@ -734,6 +747,11 @@ impl State {
|
|||||||
self.apply_default_memory();
|
self.apply_default_memory();
|
||||||
}
|
}
|
||||||
KeyCode::Char('d') if self.selected == 7 => self.apply_default_resolution(),
|
KeyCode::Char('d') if self.selected == 7 => self.apply_default_resolution(),
|
||||||
|
KeyCode::Char('d') if self.selected == 6 && !self.draft.jvm_args.is_empty() => {
|
||||||
|
return Action::ConfirmClearJvmArgs {
|
||||||
|
name: self.draft.name.clone(),
|
||||||
|
};
|
||||||
|
}
|
||||||
KeyCode::Char('c') if self.selected == 7 => {
|
KeyCode::Char('c') if self.selected == 7 => {
|
||||||
self.editing = Some(new_text_area(vec![self.value(7)]));
|
self.editing = Some(new_text_area(vec![self.value(7)]));
|
||||||
}
|
}
|
||||||
@@ -753,6 +771,11 @@ impl State {
|
|||||||
.then(|| (Box::new(self.draft.clone()), self.desktop))
|
.then(|| (Box::new(self.draft.clone()), self.desktop))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_jvm_args(&mut self) {
|
||||||
|
self.draft.jvm_args.clear();
|
||||||
|
self.error = None;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn mark_saved(&mut self, saved: &InstanceConfig, desktop: bool) {
|
pub fn mark_saved(&mut self, saved: &InstanceConfig, desktop: bool) {
|
||||||
self.original = saved.clone();
|
self.original = saved.clone();
|
||||||
self.draft = saved.clone();
|
self.draft = saved.clone();
|
||||||
@@ -891,6 +914,13 @@ pub fn render(frame: &mut Frame, area: Rect, state: &mut State) {
|
|||||||
("d", " default"),
|
("d", " default"),
|
||||||
("Esc", " back"),
|
("Esc", " back"),
|
||||||
])
|
])
|
||||||
|
} else if state.selected == 6 {
|
||||||
|
super::keybind_line(&[
|
||||||
|
("j/k", ""),
|
||||||
|
("Enter", " edit"),
|
||||||
|
("d", " clear"),
|
||||||
|
("Esc", " back"),
|
||||||
|
])
|
||||||
} else if matches!(state.selected, 0..=2) {
|
} else if matches!(state.selected, 0..=2) {
|
||||||
super::keybind_line(&[
|
super::keybind_line(&[
|
||||||
("j/k", ""),
|
("j/k", ""),
|
||||||
@@ -1115,22 +1145,23 @@ fn jvm_row_count(state: &State, width: u16) -> usize {
|
|||||||
rows
|
rows
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_choice_picker(frame: &mut Frame, area: Rect, state: &State) {
|
fn render_choice_picker(frame: &mut Frame, area: Rect, state: &mut State) {
|
||||||
let theme = THEME.as_ref();
|
let theme = THEME.as_ref();
|
||||||
let mut list_area = area;
|
let mut list_area = area;
|
||||||
if state.choice_picker == Some(ChoicePicker::Java)
|
if state.choice_picker == Some(ChoicePicker::Java)
|
||||||
&& let Some(status) = state.java_picker.status()
|
&& let Some(status) = state.java_picker.take_status()
|
||||||
{
|
{
|
||||||
let (message, color) = match status {
|
match status {
|
||||||
Ok(message) => (message.to_owned(), theme.text_dim()),
|
Ok(message) => {
|
||||||
Err(error) => (error, theme.error()),
|
frame.render_widget(
|
||||||
};
|
Paragraph::new(message).style(Style::default().fg(theme.text_dim())),
|
||||||
frame.render_widget(
|
Rect { height: 1, ..area },
|
||||||
Paragraph::new(message).style(Style::default().fg(color)),
|
);
|
||||||
Rect { height: 1, ..area },
|
list_area.y = list_area.y.saturating_add(1);
|
||||||
);
|
list_area.height = list_area.height.saturating_sub(1);
|
||||||
list_area.y = list_area.y.saturating_add(1);
|
}
|
||||||
list_area.height = list_area.height.saturating_sub(1);
|
Err(error) => crate::feedback::errors::push_message(tracing::Level::ERROR, error),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let items = match state.choice_picker {
|
let items = match state.choice_picker {
|
||||||
Some(ChoicePicker::Java) => state.java_picker.items(),
|
Some(ChoicePicker::Java) => state.java_picker.items(),
|
||||||
@@ -1200,7 +1231,7 @@ fn render_version_picker(frame: &mut Frame, area: Rect, state: &State) {
|
|||||||
LoadState::Idle => PickerLoad::Idle,
|
LoadState::Idle => PickerLoad::Idle,
|
||||||
LoadState::Loading => PickerLoad::Loading,
|
LoadState::Loading => PickerLoad::Loading,
|
||||||
LoadState::Loaded(_) => PickerLoad::Loaded,
|
LoadState::Loaded(_) => PickerLoad::Loaded,
|
||||||
LoadState::Error(error) => PickerLoad::Error(error.clone()),
|
LoadState::Error(_) => PickerLoad::Error,
|
||||||
},
|
},
|
||||||
Some(VersionPicker::Loader) => match &*state
|
Some(VersionPicker::Loader) => match &*state
|
||||||
.loader_versions
|
.loader_versions
|
||||||
@@ -1210,7 +1241,7 @@ fn render_version_picker(frame: &mut Frame, area: Rect, state: &State) {
|
|||||||
LoadState::Idle => PickerLoad::Idle,
|
LoadState::Idle => PickerLoad::Idle,
|
||||||
LoadState::Loading => PickerLoad::Loading,
|
LoadState::Loading => PickerLoad::Loading,
|
||||||
LoadState::Loaded(_) => PickerLoad::Loaded,
|
LoadState::Loaded(_) => PickerLoad::Loaded,
|
||||||
LoadState::Error(error) => PickerLoad::Error(error.clone()),
|
LoadState::Error(_) => PickerLoad::Error,
|
||||||
},
|
},
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
@@ -1219,11 +1250,8 @@ fn render_version_picker(frame: &mut Frame, area: Rect, state: &State) {
|
|||||||
Paragraph::new("Loading versions...").style(Style::default().fg(theme.text_dim())),
|
Paragraph::new("Loading versions...").style(Style::default().fg(theme.text_dim())),
|
||||||
area,
|
area,
|
||||||
),
|
),
|
||||||
PickerLoad::Error(error) => frame.render_widget(
|
PickerLoad::Error => frame.render_widget(
|
||||||
Paragraph::new(format!(
|
Paragraph::new("Reopen to retry").style(Style::default().fg(theme.text_dim())),
|
||||||
"Failed to load versions: {error}. Reopen to retry."
|
|
||||||
))
|
|
||||||
.style(Style::default().fg(theme.error())),
|
|
||||||
area,
|
area,
|
||||||
),
|
),
|
||||||
PickerLoad::Loaded => {
|
PickerLoad::Loaded => {
|
||||||
|
|||||||
@@ -168,19 +168,23 @@ impl JavaPicker {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn status(&self) -> Option<Result<&'static str, String>> {
|
pub(crate) fn take_status(&mut self) -> Option<Result<&'static str, String>> {
|
||||||
match &*self
|
let mut load = self
|
||||||
.load
|
.load
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
.unwrap_or_else(std::sync::PoisonError::into_inner);
|
||||||
{
|
match &*load {
|
||||||
LoadState::Idle => None,
|
LoadState::Idle => None,
|
||||||
LoadState::Loading => Some(Ok("Detecting installed Java runtimes…")),
|
LoadState::Loading => Some(Ok("Detecting installed Java runtimes…")),
|
||||||
LoadState::Loaded(installations) if installations.is_empty() => {
|
LoadState::Loaded(installations) if installations.is_empty() => {
|
||||||
Some(Ok("No additional Java runtimes found."))
|
Some(Ok("No additional Java runtimes found."))
|
||||||
}
|
}
|
||||||
LoadState::Loaded(_) => None,
|
LoadState::Loaded(_) => None,
|
||||||
LoadState::Error(error) => Some(Err(error.clone())),
|
LoadState::Error(error) => {
|
||||||
|
let error = error.clone();
|
||||||
|
*load = LoadState::Loaded(Vec::new());
|
||||||
|
Some(Err(error))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,10 +342,11 @@ pub(crate) fn handle_text_area_input(input: &mut TextArea<'_>, key: &KeyEvent) {
|
|||||||
|
|
||||||
pub(crate) fn auto_label() -> Span<'static> {
|
pub(crate) fn auto_label() -> Span<'static> {
|
||||||
Span::styled(
|
Span::styled(
|
||||||
"Auto",
|
" Auto ",
|
||||||
Style::default()
|
Style::default()
|
||||||
.fg(THEME.as_ref().text_dim())
|
.fg(THEME.as_ref().text_bright())
|
||||||
.add_modifier(Modifier::ITALIC),
|
.bg(THEME.as_ref().info())
|
||||||
|
.add_modifier(Modifier::BOLD),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -329,10 +329,10 @@ fn render_instance_info(
|
|||||||
} else {
|
} else {
|
||||||
value_style
|
value_style
|
||||||
};
|
};
|
||||||
let desktop = if crate::instance::desktop::exists(&inst.name) {
|
let shortcut = if crate::instance::desktop::exists(&inst.name) {
|
||||||
"yes"
|
"enabled"
|
||||||
} else {
|
} else {
|
||||||
"no"
|
"disabled"
|
||||||
};
|
};
|
||||||
let lines = vec![
|
let lines = vec![
|
||||||
Line::from(vec![
|
Line::from(vec![
|
||||||
@@ -344,8 +344,8 @@ fn render_instance_info(
|
|||||||
Span::styled(state.java_label.as_str(), active_style),
|
Span::styled(state.java_label.as_str(), active_style),
|
||||||
]),
|
]),
|
||||||
Line::from(vec![
|
Line::from(vec![
|
||||||
Span::styled("Desktop ", label_style),
|
Span::styled("Shortcut ", label_style),
|
||||||
Span::styled(desktop, active_style),
|
Span::styled(shortcut, active_style),
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user