Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyshew committed Dec 16, 2024
1 parent c00b7ed commit d0f0186
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/turborepo-ui/src/tui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<W> App<W> {
self.preferences.set_active_task(
self.is_task_selection_pinned
.then(|| active_task.to_owned()),
);
)?;
Ok(())
}

Expand All @@ -167,6 +167,7 @@ impl<W> App<W> {
self.selected_task_index = (self.selected_task_index + 1) % num_rows;
self.task_list_scroll.select(Some(self.selected_task_index));
self.is_task_selection_pinned = true;
self.persist_active_task().ok();
}
}

Expand All @@ -180,6 +181,7 @@ impl<W> App<W> {
.unwrap_or(num_rows - 1);
self.task_list_scroll.select(Some(self.selected_task_index));
self.is_task_selection_pinned = true;
self.persist_active_task().ok();
}
}

Expand Down Expand Up @@ -816,7 +818,11 @@ fn update(
app.is_task_selection_pinned = !app.is_task_selection_pinned;
}
Event::ToggleSidebar => {
app.has_sidebar = !app.has_sidebar;
let new_value = !app.preferences.is_task_list_visible();

app.preferences
.set_is_task_list_visible(Some(new_value))
.ok();
}
Event::ToggleHelpPopup => {
app.showing_help_popup = !app.showing_help_popup;
Expand Down Expand Up @@ -872,7 +878,7 @@ fn update(

fn view<W>(app: &mut App<W>, f: &mut Frame) {
let cols = app.size.pane_cols();
let horizontal = if app.has_sidebar {
let horizontal = if app.preferences.is_task_list_visible() {
Layout::horizontal([Constraint::Fill(1), Constraint::Length(cols)])
} else {
Layout::horizontal([Constraint::Max(0), Constraint::Length(cols)])
Expand All @@ -886,7 +892,7 @@ fn view<W>(app: &mut App<W>, f: &mut Frame) {
output_logs,
&active_task,
&app.section_focus,
app.has_sidebar,
app.preferences.is_task_list_visible(),
);

let table_to_render = TaskTable::new(&app.tasks_by_status);
Expand Down
5 changes: 5 additions & 0 deletions crates/turborepo-ui/src/tui/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ impl PreferenceLoader {
self.config.is_task_list_visible.unwrap_or(true)
}

pub fn set_is_task_list_visible(&mut self, value: Option<bool>) -> Result<(), Error> {
self.config.is_task_list_visible = value;
self.flush_to_disk()
}

pub fn active_task(&self) -> Option<&str> {
let active_task = self.config.active_task.as_deref()?;
Some(active_task)
Expand Down

0 comments on commit d0f0186

Please sign in to comment.