From b8bf6eb6b9a89d3a7e05d25a3f528844617e821b Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Wed, 11 Dec 2024 20:38:35 -0700 Subject: [PATCH] feat(tui): toggle task selection pinning --- crates/turborepo-ui/src/tui/app.rs | 3 +++ crates/turborepo-ui/src/tui/event.rs | 1 + crates/turborepo-ui/src/tui/input.rs | 1 + crates/turborepo-ui/src/tui/popup.rs | 3 ++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/turborepo-ui/src/tui/app.rs b/crates/turborepo-ui/src/tui/app.rs index 7705e3bf010f5..f4f6a59c7ed1a 100644 --- a/crates/turborepo-ui/src/tui/app.rs +++ b/crates/turborepo-ui/src/tui/app.rs @@ -798,6 +798,9 @@ fn update( Event::ToggleHelpPopup => { app.showing_help_popup = !app.showing_help_popup; } + Event::TogglePinnedTask => { + app.is_task_selection_pinned = !app.is_task_selection_pinned; + } Event::Input { bytes } => { app.forward_input(&bytes)?; } diff --git a/crates/turborepo-ui/src/tui/event.rs b/crates/turborepo-ui/src/tui/event.rs index 4259938c07c2e..775a7ef4bcc17 100644 --- a/crates/turborepo-ui/src/tui/event.rs +++ b/crates/turborepo-ui/src/tui/event.rs @@ -52,6 +52,7 @@ pub enum Event { }, ToggleSidebar, ToggleHelpPopup, + TogglePinnedTask, SearchEnter, SearchExit { restore_scroll: bool, diff --git a/crates/turborepo-ui/src/tui/input.rs b/crates/turborepo-ui/src/tui/input.rs index 2a0b16b425b83..f388d912f8f1a 100644 --- a/crates/turborepo-ui/src/tui/input.rs +++ b/crates/turborepo-ui/src/tui/input.rs @@ -115,6 +115,7 @@ fn translate_key_event(options: InputOptions, key_event: KeyEvent) -> Option Some(Event::ToggleHelpPopup), + KeyCode::Char('p') => Some(Event::TogglePinnedTask), KeyCode::Up | KeyCode::Char('k') => Some(Event::Up), KeyCode::Down | KeyCode::Char('j') => Some(Event::Down), KeyCode::Enter | KeyCode::Char('i') => Some(Event::EnterInteractive), diff --git a/crates/turborepo-ui/src/tui/popup.rs b/crates/turborepo-ui/src/tui/popup.rs index d8a0e49187101..6dcd58b2f8f52 100644 --- a/crates/turborepo-ui/src/tui/popup.rs +++ b/crates/turborepo-ui/src/tui/popup.rs @@ -6,11 +6,12 @@ use ratatui::{ widgets::{Block, List, ListItem, Padding}, }; -const BIND_LIST: [&str; 11] = [ +const BIND_LIST: [&str; 12] = [ "m - Toggle this help popup", "↑ or j - Select previous task", "↓ or k - Select next task", "h - Toggle task list", + "p - Toggle pinned task selection", "/ - Filter tasks to search term", "ESC - Clear filter", "i - Interact with task",