MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / draw_gateway_list

Function draw_gateway_list

crates/openshell-tui/src/ui/dashboard.rs:37–127  ·  view source on GitHub ↗
(frame: &mut Frame<'_>, app: &App, area: Rect)

Source from the content-addressed store, hash-verified

35}
36
37fn draw_gateway_list(frame: &mut Frame<'_>, app: &App, area: Rect) {
38 let t = &app.theme;
39 let focused = app.focus == Focus::Gateways;
40
41 let header = Row::new(vec![
42 Cell::from(Span::styled(" NAME", t.muted)),
43 Cell::from(Span::styled("TYPE", t.muted)),
44 Cell::from(Span::styled("SOURCE", t.muted)),
45 Cell::from(Span::styled("STATUS", t.muted)),
46 Cell::from(Span::styled("", t.muted)),
47 ])
48 .bottom_margin(1);
49
50 let rows: Vec<Row<'_>> = app
51 .gateways
52 .iter()
53 .enumerate()
54 .map(|(i, entry)| {
55 let is_active = entry.name == app.gateway_name;
56 let is_cursor = focused && i == app.gateway_selected;
57
58 let cursor = if is_cursor { ">" } else { " " };
59 let dot = if is_active { "* " } else { " " };
60 let dot_style = if is_active { t.status_ok } else { t.muted };
61 let name_style = if is_active { t.heading } else { t.text };
62 let name_cell = Cell::from(Line::from(vec![
63 Span::styled(cursor, t.accent),
64 Span::styled(dot, dot_style),
65 Span::styled(&entry.name, name_style),
66 ]));
67
68 let type_label = if entry.is_remote { "remote" } else { "local" };
69
70 let status_cell = if is_active {
71 let status_style = if app.status_text.contains("Healthy") {
72 t.status_ok
73 } else if app.status_text.contains("Degraded") {
74 t.status_warn
75 } else if app.status_text.contains("Unhealthy") {
76 t.status_err
77 } else {
78 t.muted
79 };
80 Cell::from(Span::styled(&app.status_text, status_style))
81 } else {
82 Cell::from(Span::styled("-", t.muted))
83 };
84
85 let policy_cell = if is_active && app.global_policy_active {
86 Cell::from(Span::styled(
87 format!("Global Policy Active (v{})", app.global_policy_version),
88 t.status_warn,
89 ))
90 } else {
91 Cell::from(Span::raw(""))
92 };
93
94 Row::new(vec![

Callers 1

drawFunction · 0.85

Calls 2

draw_empty_messageFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected