Skip to content

Commit ba7bf2f

Browse files
committed
style: format ui changes
1 parent 5baad5f commit ba7bf2f

4 files changed

Lines changed: 47 additions & 35 deletions

File tree

src/ui/dashboard.rs

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,14 @@ fn handle_key_event(state: &mut AppState, key: event::KeyEvent) -> io::Result<bo
7777

7878
match (key.code, key.modifiers) {
7979
(KeyCode::Char('q'), _) => return Ok(true),
80-
(KeyCode::Esc, _) if state.ui.has_execution_output() => {
81-
state.ui.clear_execution_output()
82-
}
80+
(KeyCode::Esc, _) if state.ui.has_execution_output() => state.ui.clear_execution_output(),
8381
(KeyCode::Char('p'), KeyModifiers::CONTROL) => state.ui.palette.open(),
8482
(KeyCode::Char('r'), KeyModifiers::CONTROL) => {
8583
refresh_project(state)?;
8684
}
87-
(KeyCode::Char('b'), KeyModifiers::CONTROL) => {
88-
route_action(state, "docker.build")
89-
}
90-
(KeyCode::Char('d'), KeyModifiers::CONTROL) => {
91-
route_action(state, "kubernetes.deploy")
92-
}
93-
(KeyCode::Char('l'), KeyModifiers::CONTROL) => {
94-
router::route_to(state, Screen::Monitoring)
95-
}
85+
(KeyCode::Char('b'), KeyModifiers::CONTROL) => route_action(state, "docker.build"),
86+
(KeyCode::Char('d'), KeyModifiers::CONTROL) => route_action(state, "kubernetes.deploy"),
87+
(KeyCode::Char('l'), KeyModifiers::CONTROL) => router::route_to(state, Screen::Monitoring),
9688
(KeyCode::Char('t'), _) => cycle_theme(state),
9789
(KeyCode::Tab, _) | (KeyCode::BackTab, _) => {
9890
state.ui.toggle_focus();
@@ -155,7 +147,15 @@ fn handle_enter_key(state: &mut AppState) {
155147
.ui
156148
.screen_actions(&state.actions, state.current_screen)
157149
.iter()
158-
.map(|a| (a.id.clone(), a.screen, a.label.clone(), a.enabled, a.reason.clone()))
150+
.map(|a| {
151+
(
152+
a.id.clone(),
153+
a.screen,
154+
a.label.clone(),
155+
a.enabled,
156+
a.reason.clone(),
157+
)
158+
})
159159
.collect();
160160
if let Some((id, screen, label, enabled, reason)) =
161161
screen_actions.get(state.ui.selected_action).cloned()
@@ -529,7 +529,11 @@ fn render_deployments(frame: &mut Frame, area: Rect, state: &AppState, palette:
529529
let plan = deploy::pipeline::plan(&state.capabilities, &state.runtime);
530530
let layout = Layout::default()
531531
.direction(Direction::Vertical)
532-
.constraints([Constraint::Length(5), Constraint::Min(5), Constraint::Length(8)])
532+
.constraints([
533+
Constraint::Length(5),
534+
Constraint::Min(5),
535+
Constraint::Length(8),
536+
])
533537
.split(area);
534538
let ready = plan.ready();
535539

@@ -640,7 +644,12 @@ fn render_action_list(
640644
if screen_actions.is_empty() {
641645
render_empty_actions(frame, area, is_focused, palette);
642646
} else {
643-
let items = build_action_list_items(&screen_actions, is_focused, state.ui.selected_action, palette);
647+
let items = build_action_list_items(
648+
&screen_actions,
649+
is_focused,
650+
state.ui.selected_action,
651+
palette,
652+
);
644653
render_active_actions(frame, area, items, is_focused, palette);
645654
}
646655
}
@@ -652,15 +661,17 @@ fn render_empty_actions(frame: &mut Frame, area: Rect, is_focused: bool, palette
652661
Style::default().fg(palette.muted)
653662
};
654663
frame.render_widget(
655-
Paragraph::new("No actions available for this screen.\n\nUse Ctrl+P to open the command palette.")
656-
.wrap(Wrap { trim: false })
657-
.block(
658-
Block::default()
659-
.title(" Actions ")
660-
.borders(Borders::ALL)
661-
.border_style(border_style),
662-
)
663-
.style(Style::default().fg(palette.muted)),
664+
Paragraph::new(
665+
"No actions available for this screen.\n\nUse Ctrl+P to open the command palette.",
666+
)
667+
.wrap(Wrap { trim: false })
668+
.block(
669+
Block::default()
670+
.title(" Actions ")
671+
.borders(Borders::ALL)
672+
.border_style(border_style),
673+
)
674+
.style(Style::default().fg(palette.muted)),
664675
area,
665676
);
666677
}
@@ -688,7 +699,11 @@ fn build_action_list_items(
688699
Style::default().fg(palette.text)
689700
};
690701

691-
let suffix = if !action.enabled { " (unavailable)" } else { "" };
702+
let suffix = if !action.enabled {
703+
" (unavailable)"
704+
} else {
705+
""
706+
};
692707

693708
ListItem::new(Line::from(format!("{marker}{}{suffix}", action.label))).style(style)
694709
})
@@ -724,8 +739,6 @@ fn render_active_actions(
724739
);
725740
}
726741

727-
728-
729742
fn render_command_palette(
730743
frame: &mut Frame,
731744
area: Rect,
@@ -927,7 +940,6 @@ fn refresh_project(state: &mut AppState) -> io::Result<()> {
927940
Ok(())
928941
}
929942

930-
931943
fn cycle_theme(state: &mut AppState) {
932944
state.ui.active_theme = state.ui.active_theme.next();
933945
let theme_str = state
@@ -980,7 +992,6 @@ fn availability(value: bool) -> &'static str {
980992
}
981993
}
982994

983-
984995
fn render_short_list(values: &[String]) -> String {
985996
if values.is_empty() {
986997
"- No immediate next steps".to_string()

src/ui/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ pub mod statusbar;
99
pub mod theme;
1010
pub mod welcome;
1111
pub mod widgets;
12-

src/ui/state.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,7 @@ impl UiState {
239239
actions: &'a [CommandAction],
240240
screen: Screen,
241241
) -> Vec<&'a CommandAction> {
242-
actions
243-
.iter()
244-
.filter(|a| a.screen == screen)
245-
.collect()
242+
actions.iter().filter(|a| a.screen == screen).collect()
246243
}
247244
}
248245

src/ui/welcome.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ fn reload_project(state: &mut AppState, path: PathBuf) -> io::Result<()> {
6262
Ok(())
6363
}
6464

65-
pub fn render_first_launch(frame: &mut Frame, area: Rect, state: &AppState, palette: theme::Palette) {
65+
pub fn render_first_launch(
66+
frame: &mut Frame,
67+
area: Rect,
68+
state: &AppState,
69+
palette: theme::Palette,
70+
) {
6671
let welcome_area = welcome_rect(area);
6772
let outer_block = render_outer_block(frame, welcome_area, palette);
6873
let inner_area = outer_block.inner(welcome_area);

0 commit comments

Comments
 (0)