(frame: &mut Frame<'_>, app: &App, area: Rect, focused: bool)
| 9 | use crate::app::App; |
| 10 | |
| 11 | pub fn draw(frame: &mut Frame<'_>, app: &App, area: Rect, focused: bool) { |
| 12 | let t = &app.theme; |
| 13 | let header = Row::new(vec![ |
| 14 | Cell::from(Span::styled(" NAME", t.muted)), |
| 15 | Cell::from(Span::styled("STATUS", t.muted)), |
| 16 | Cell::from(Span::styled("CREATED", t.muted)), |
| 17 | Cell::from(Span::styled("AGE", t.muted)), |
| 18 | Cell::from(Span::styled("IMAGE", t.muted)), |
| 19 | Cell::from(Span::styled("LABELS", t.muted)), |
| 20 | Cell::from(Span::styled("NOTES", t.muted)), |
| 21 | ]) |
| 22 | .bottom_margin(1); |
| 23 | |
| 24 | let rows: Vec<Row<'_>> = (0..app.sandbox_count) |
| 25 | .map(|i| { |
| 26 | let name = app.sandbox_names.get(i).map_or("", String::as_str); |
| 27 | let phase = app.sandbox_phases.get(i).map_or("", String::as_str); |
| 28 | let created = app.sandbox_created.get(i).map_or("", String::as_str); |
| 29 | let age = app.sandbox_ages.get(i).map_or("", String::as_str); |
| 30 | let image = app.sandbox_images.get(i).map_or("", String::as_str); |
| 31 | let labels = app.sandbox_labels.get(i).map_or("", String::as_str); |
| 32 | let notes = app.sandbox_notes.get(i).map_or("", String::as_str); |
| 33 | let draft_count = app.sandbox_draft_counts.get(i).copied().unwrap_or(0); |
| 34 | |
| 35 | let phase_style = match phase { |
| 36 | "Ready" => t.status_ok, |
| 37 | "Provisioning" => t.status_warn, |
| 38 | "Error" => t.status_err, |
| 39 | _ => t.muted, |
| 40 | }; |
| 41 | |
| 42 | let selected = focused && i == app.sandbox_selected; |
| 43 | let mut name_spans = if selected { |
| 44 | vec![Span::styled("▌ ", t.accent), Span::styled(name, t.text)] |
| 45 | } else { |
| 46 | vec![Span::raw(" "), Span::styled(name, t.text)] |
| 47 | }; |
| 48 | |
| 49 | // Append notification badge when there are pending network rules. |
| 50 | if draft_count > 0 { |
| 51 | name_spans.push(Span::raw(" ")); |
| 52 | name_spans.push(Span::styled( |
| 53 | format!( |
| 54 | " {draft_count} pending rule{} ", |
| 55 | if draft_count == 1 { "" } else { "s" } |
| 56 | ), |
| 57 | t.badge, |
| 58 | )); |
| 59 | } |
| 60 | |
| 61 | let name_cell = Cell::from(Line::from(name_spans)); |
| 62 | |
| 63 | Row::new(vec![ |
| 64 | name_cell, |
| 65 | Cell::from(Span::styled(phase, phase_style)), |
| 66 | Cell::from(Span::styled(created, t.muted)), |
| 67 | Cell::from(Span::styled(age, t.muted)), |
| 68 | Cell::from(Span::styled(image, t.muted)), |
nothing calls this directly
no test coverage detected