Skip to content

Commit c36c08e

Browse files
committed
feat: provide warning when field filtering on
1 parent ccced1e commit c36c08e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/app.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ pub struct LogViewerApp {
3434
should_scroll_to_end_on_load: bool,
3535
// TODO 4: Add UI to set / unset field
3636
/// When set adds a field with this name and populates it with the row numbers
37-
pub row_idx_field_name: Option<String>,
37+
row_idx_field_name: Option<String>,
38+
/// Allows the user to dim the warning by clicking on it
39+
should_highlight_field_warning: bool,
3840

3941
#[serde(skip)]
4042
should_focus_search: bool,
@@ -56,6 +58,7 @@ impl Default for LogViewerApp {
5658
shortcuts: Default::default(),
5759
should_scroll_to_end_on_load: Default::default(),
5860
row_idx_field_name: Some("row#".to_string()),
61+
should_highlight_field_warning: true,
5962
should_focus_search: Default::default(),
6063
should_scroll: Default::default(),
6164
show_last_filename: true,
@@ -587,6 +590,24 @@ impl LogViewerApp {
587590
{
588591
should_apply_filter = true;
589592
}
593+
594+
let color = if self.should_highlight_field_warning {
595+
ui.visuals().warn_fg_color
596+
} else {
597+
ui.visuals().text_color()
598+
};
599+
let hint_text = if self.should_highlight_field_warning {
600+
"Click to DIM warning"
601+
} else {
602+
"Click to Highlight warning"
603+
};
604+
if ui
605+
.colored_label(color, "(Field filtering enabled)")
606+
.on_hover_text(hint_text)
607+
.clicked()
608+
{
609+
self.should_highlight_field_warning = !self.should_highlight_field_warning;
610+
};
590611
}
591612
}
592613
if should_apply_filter {

0 commit comments

Comments
 (0)