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

Function draw_v2

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

Source from the content-addressed store, hash-verified

88}
89
90fn draw_v2(frame: &mut Frame<'_>, app: &App, area: Rect, focused: bool) {
91 let t = &app.theme;
92 let header = Row::new(vec![
93 Cell::from(Span::styled(" NAME", t.muted)),
94 Cell::from(Span::styled("PROFILE", t.muted)),
95 Cell::from(Span::styled("CATEGORY", t.muted)),
96 Cell::from(Span::styled("CREDS", t.muted)),
97 Cell::from(Span::styled("POLICY", t.muted)),
98 ])
99 .bottom_margin(1);
100
101 let rows: Vec<Row<'_>> = app
102 .provider_entries
103 .iter()
104 .enumerate()
105 .map(|(i, entry)| {
106 let selected = focused && i == app.provider_selected;
107 let name_cell = if selected {
108 Cell::from(Line::from(vec![
109 Span::styled("> ", t.accent),
110 Span::styled(entry.name(), t.text),
111 ]))
112 } else {
113 Cell::from(Line::from(vec![
114 Span::raw(" "),
115 Span::styled(entry.name(), t.text),
116 ]))
117 };
118
119 let profile_style = if entry.profile.is_some() {
120 t.text
121 } else {
122 t.status_warn
123 };
124
125 Row::new(vec![
126 name_cell,
127 Cell::from(Span::styled(entry.profile_label(), profile_style)),
128 Cell::from(Span::styled(entry.category_label(), t.muted)),
129 Cell::from(Span::styled(entry.credential_summary(), t.muted)),
130 Cell::from(Span::styled(entry.policy_summary(), t.muted)),
131 ])
132 })
133 .collect();
134
135 let widths = [
136 Constraint::Percentage(22),
137 Constraint::Percentage(24),
138 Constraint::Percentage(16),
139 Constraint::Percentage(18),
140 Constraint::Percentage(20),
141 ];
142
143 let border_style = if focused { t.border_focused } else { t.border };
144 let title = if focused && app.confirm_provider_delete {
145 let name = app
146 .provider_names
147 .get(app.provider_selected)

Callers 1

drawFunction · 0.85

Calls 3

draw_tab_titleFunction · 0.85
draw_empty_messageFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected