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

Function draw_update

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

Source from the content-addressed store, hash-verified

664// ---------------------------------------------------------------------------
665
666pub fn draw_update(frame: &mut Frame<'_>, app: &App, area: Rect) {
667 let t = &app.theme;
668 let Some(form) = &app.update_provider_form else {
669 return;
670 };
671
672 let modal_width = 60u16.min(area.width.saturating_sub(4));
673 // name(1) + type(1) + spacer(1) + key_label(1) + value(1) + cursor_hint(1) + spacer(1) + status(1) + hint(1)
674 let content_height = 9;
675 let modal_height = (content_height + 4).min(area.height.saturating_sub(2));
676 let popup_area = centered_rect(modal_width, modal_height, area);
677
678 frame.render_widget(Clear, popup_area);
679
680 let block = Block::default()
681 .title(Span::styled(" Update Provider ", t.heading))
682 .borders(Borders::ALL)
683 .border_style(t.accent)
684 .padding(Padding::new(2, 2, 1, 1));
685
686 let inner = block.inner(popup_area);
687 frame.render_widget(block, popup_area);
688
689 let chunks = Layout::default()
690 .direction(Direction::Vertical)
691 .constraints([
692 Constraint::Length(1), // name
693 Constraint::Length(1), // type
694 Constraint::Length(1), // spacer
695 Constraint::Length(1), // key label
696 Constraint::Length(1), // value input
697 Constraint::Length(1), // cursor hint
698 Constraint::Length(1), // spacer
699 Constraint::Length(1), // status
700 Constraint::Length(1), // hint
701 Constraint::Min(0),
702 ])
703 .split(inner);
704
705 frame.render_widget(
706 Paragraph::new(Line::from(vec![
707 Span::styled("Name: ", t.muted),
708 Span::styled(&form.provider_name, t.heading),
709 ])),
710 chunks[0],
711 );
712
713 frame.render_widget(
714 Paragraph::new(Line::from(vec![
715 Span::styled("Type: ", t.muted),
716 Span::styled(&form.provider_type, t.text),
717 ])),
718 chunks[1],
719 );
720
721 let key_label = if form.credential_key.is_empty() {
722 "New value:"
723 } else {

Callers 1

drawFunction · 0.85

Calls 3

centered_rectFunction · 0.85
lenMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected