fix: right-align connection access in the header
This commit is contained in:
+29
-3
@@ -546,16 +546,21 @@ fn draw_bars(
|
|||||||
let base = Style::default();
|
let base = Style::default();
|
||||||
let badge = Style::default().bg(Color::Cyan).fg(Color::Black);
|
let badge = Style::default().bg(Color::Cyan).fg(Color::Black);
|
||||||
let edge = base.fg(Color::Cyan);
|
let edge = base.fg(Color::Cyan);
|
||||||
|
let access = access.map_or("NOT CONNECTED", AccessMode::label);
|
||||||
|
let [brand_area, access_area] = Layout::horizontal([
|
||||||
|
Constraint::Min(0),
|
||||||
|
Constraint::Length(access.len() as u16),
|
||||||
|
])
|
||||||
|
.areas(top);
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
Paragraph::new(Line::from(vec![
|
Paragraph::new(Line::from(vec![
|
||||||
Span::styled(" dbdash ", badge),
|
Span::styled(" dbdash ", badge),
|
||||||
Span::styled("▓░", edge),
|
Span::styled("▓░", edge),
|
||||||
Span::raw(" "),
|
|
||||||
Span::raw(access.map_or("NOT CONNECTED", AccessMode::label)),
|
|
||||||
]))
|
]))
|
||||||
.style(base),
|
.style(base),
|
||||||
top,
|
brand_area,
|
||||||
);
|
);
|
||||||
|
frame.render_widget(Paragraph::new(access).right_aligned().style(base), access_area);
|
||||||
frame.render_widget(Paragraph::new("").style(base), bottom);
|
frame.render_widget(Paragraph::new("").style(base), bottom);
|
||||||
let position = position.map(|(line, column)| format!(" {line}:{column} "));
|
let position = position.map(|(line, column)| format!(" {line}:{column} "));
|
||||||
let position = position.as_deref().unwrap_or(" N/A ");
|
let position = position.as_deref().unwrap_or(" N/A ");
|
||||||
@@ -1597,6 +1602,27 @@ mod tests {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn access_status_stays_at_the_top_right() -> Result<()> {
|
||||||
|
for width in [24, 80] {
|
||||||
|
for access in [Some(AccessMode::ReadOnly), Some(AccessMode::ReadWrite), None] {
|
||||||
|
let mut terminal = ratatui::Terminal::new(
|
||||||
|
ratatui::backend::TestBackend::new(width, 6),
|
||||||
|
)?;
|
||||||
|
terminal.draw(|frame| {
|
||||||
|
let [top, _, bottom] = shell_areas(frame.area());
|
||||||
|
draw_bars(frame, top, bottom, "", "", access, false, None);
|
||||||
|
})?;
|
||||||
|
let header: String = (0..width)
|
||||||
|
.map(|x| terminal.backend().buffer()[(x, 0)].symbol())
|
||||||
|
.collect();
|
||||||
|
assert!(header.starts_with(" dbdash ▓░"));
|
||||||
|
assert!(header.ends_with(access.map_or("NOT CONNECTED", AccessMode::label)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ca_selector_persists_per_profile_and_keeps_missing_selections_fail_closed() -> Result<()> {
|
fn ca_selector_persists_per_profile_and_keeps_missing_selections_fail_closed() -> Result<()> {
|
||||||
let directory = tempfile::tempdir()?;
|
let directory = tempfile::tempdir()?;
|
||||||
|
|||||||
+1
-1
@@ -82,7 +82,7 @@ Navigation:
|
|||||||
Enter on the connected database collapses/expands it without reconnecting.
|
Enter on the connected database collapses/expands it without reconnecting.
|
||||||
Keybindings float above the workspace; Up/Down/jk scroll, Home/End/g/G jump.
|
Keybindings float above the workspace; Up/Down/jk scroll, Home/End/g/G jump.
|
||||||
Query Insert mode and connection/password fields keep ? as literal text.
|
Query Insert mode and connection/password fields keep ? as literal text.
|
||||||
Full-width bars show dbdash/live READ ONLY or READ WRITE above and mode/database below.
|
Full-width bars show dbdash at top-left, live access mode at top-right, and mode/database below.
|
||||||
Saved PostgreSQL connections show database · user@host:port beside the mode,
|
Saved PostgreSQL connections show database · user@host:port beside the mode,
|
||||||
regardless of custom sidebar names; passwords are never included.
|
regardless of custom sidebar names; passwords are never included.
|
||||||
The database provider sits immediately left of the bottom-right position badge.
|
The database provider sits immediately left of the bottom-right position badge.
|
||||||
|
|||||||
Reference in New Issue
Block a user