diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-06 02:27:06 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-06 02:27:06 +0300 |
| commit | 9e9bc8a144667a6b7debfd4f0c7a31ff0e11493a (patch) | |
| tree | 03f1259f91fd9edeacfd4b904f2e84d4acf25232 /src/client/shell/endpoint_notices.rs | |
| parent | 35b0dff96579f099e0436290085024424ffb289c (diff) | |
feat: manage multiple ssh machines from one client (#3670)
Diffstat (limited to 'src/client/shell/endpoint_notices.rs')
| -rw-r--r-- | src/client/shell/endpoint_notices.rs | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/client/shell/endpoint_notices.rs b/src/client/shell/endpoint_notices.rs new file mode 100644 index 00000000..e796d2c5 --- /dev/null +++ b/src/client/shell/endpoint_notices.rs @@ -0,0 +1,80 @@ +use super::*; +use ratatui::widgets::{Clear, Widget}; + +pub(super) fn render_mobile_banner( + buffer: &mut Buffer, + area: Rect, + notice: &ClientVisibleEndpointNotice, + offset_for_warning: bool, + palette: &Palette, +) -> Rect { + super::notifications::render_mobile_notice_banner( + buffer, + area, + ¬ice.title, + Some(¬ice.body), + palette.red, + offset_for_warning, + palette, + ) +} + +pub(super) fn render_lifecycle_banner( + buffer: &mut Buffer, + area: Rect, + label: &str, + status: ClientEndpointStatus, + top_offset: u16, + palette: &Palette, +) -> Rect { + if area.is_empty() || status == ClientEndpointStatus::Online { + return Rect::default(); + } + let (symbol, state, color) = endpoint_status_presentation(status, palette); + let text = format!("{symbol} {label} ยท {state}"); + let width = u16::try_from(unicode_width::UnicodeWidthStr::width(text.as_str()) + 2) + .unwrap_or(u16::MAX) + .min(area.width); + let y = area + .y + .saturating_add(top_offset) + .min(area.bottom().saturating_sub(1)); + let rect = Rect::new(area.right().saturating_sub(width), y, width, 1); + Clear.render(rect, buffer); + buffer.set_style(rect, Style::default().bg(palette.surface0)); + super::render::put_text( + buffer, + rect.x.saturating_add(1), + rect.y, + rect.width.saturating_sub(2), + &text, + Style::default().fg(color).bg(palette.surface0), + ); + rect +} + +pub(super) fn render_notice( + buffer: &mut Buffer, + area: Rect, + notice: &ClientVisibleEndpointNotice, + top_offset: u16, + palette: &Palette, +) -> Rect { + super::notifications::render_notification_card( + buffer, + area, + ¬ice.title, + ¬ice.body, + crate::config::ToastHerdrPosition::TopRight, + top_offset, + match notice.key.kind { + ClientEndpointNoticeKind::Unsupported | ClientEndpointNoticeKind::Rejected => { + palette.red + } + ClientEndpointNoticeKind::Timeout | ClientEndpointNoticeKind::Unavailable => { + palette.yellow + } + }, + palette, + ) +} |
