Skip to content

Commit

Permalink
Expanding top level objects if no search term.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmackdev committed Aug 16, 2023
1 parent 5d2323f commit 5acb94b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pubsubman_gui/src/ui/messages_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use chrono::{DateTime, Local};
use egui::scroll_area::ScrollBarVisibility;
use egui_json_tree::{JsonTree, JsonTreeResponse};
use egui_json_tree::{Expand, JsonTree, JsonTreeResponse};
use pubsubman_backend::{
message::FrontendMessage,
model::{PubsubMessage, SubscriptionName, TopicName},
Expand Down Expand Up @@ -228,15 +228,19 @@ where
Err(_) => Value::String(message.data.clone()),
};

let default_expand = if search_term.is_empty() {
Expand::ToLevel(0)
} else {
Expand::SearchResults(search_term.to_string())
};

// Wrapping in this scroll area to get this column to expand to full width.
egui::ScrollArea::neither()
.auto_shrink([false, true])
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
.show(ui, |ui| {
let response = JsonTree::new(&message.id, &value)
.default_expand(egui_json_tree::Expand::SearchResults(
search_term.to_string(),
))
.default_expand(default_expand)
.show(ui);

json_tree_responses.push(response);
Expand Down

0 comments on commit 5acb94b

Please sign in to comment.