Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/src/workspace/tab_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ impl HeaderToolbarChipSelection {
Self::Custom { right, .. } => right.clone(),
}
}

pub fn contains_item(&self, item: &super::header_toolbar_item::HeaderToolbarItemKind) -> bool {
self.left_items().contains(item) || self.right_items().contains(item)
}
}

settings::macros::implement_setting_for_enum!(
Expand Down
43 changes: 43 additions & 0 deletions app/src/workspace/tab_settings_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::*;
use crate::test_util::settings::initialize_settings_for_tests;
use crate::workspace::header_toolbar_item::HeaderToolbarItemKind;
use settings::Setting;
use warpui::{App, SingletonEntity};

Expand Down Expand Up @@ -56,3 +57,45 @@ fn show_vertical_tab_panel_in_restored_windows_uses_vertical_tabs_path() {
"show_panel_in_restored_windows"
);
}

#[test]
fn header_toolbar_chip_selection_default_contains_code_review() {
let config = HeaderToolbarChipSelection::Default;
assert!(config.contains_item(&HeaderToolbarItemKind::CodeReview));
}

#[test]
fn header_toolbar_chip_selection_custom_without_code_review_reports_absent() {
let config = HeaderToolbarChipSelection::Custom {
left: vec![
HeaderToolbarItemKind::TabsPanel,
HeaderToolbarItemKind::ToolsPanel,
],
right: vec![HeaderToolbarItemKind::NotificationsMailbox],
};
assert!(!config.contains_item(&HeaderToolbarItemKind::CodeReview));
assert!(config.contains_item(&HeaderToolbarItemKind::TabsPanel));
assert!(config.contains_item(&HeaderToolbarItemKind::ToolsPanel));
assert!(config.contains_item(&HeaderToolbarItemKind::NotificationsMailbox));
assert!(!config.contains_item(&HeaderToolbarItemKind::AgentManagement));
}

#[test]
fn header_toolbar_chip_selection_custom_with_code_review_on_left_reports_present() {
let config = HeaderToolbarChipSelection::Custom {
left: vec![HeaderToolbarItemKind::CodeReview],
right: vec![],
};
assert!(config.contains_item(&HeaderToolbarItemKind::CodeReview));
}

#[test]
fn header_toolbar_chip_selection_custom_empty_reports_all_absent() {
let config = HeaderToolbarChipSelection::Custom {
left: vec![],
right: vec![],
};
for item in HeaderToolbarItemKind::all_items() {
assert!(!config.contains_item(&item));
}
}
34 changes: 27 additions & 7 deletions app/src/workspace/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7979,10 +7979,6 @@ impl Workspace {
context: Option<&CodeReviewPaneContext>,
ctx: &mut ViewContext<Self>,
) {
if !*TabSettings::as_ref(ctx).show_code_review_button {
return;
}

// If context is provided, use it directly. Otherwise, derive from active pane group.
let context_data: Option<(
Option<PathBuf>,
Expand Down Expand Up @@ -18285,6 +18281,18 @@ impl Workspace {
self.render_config_panel_maximized(pane_group, &config, app),
app,
);
} else if !config.contains_item(&HeaderToolbarItemKind::CodeReview) {
Self::add_panel_with_separator(
&mut main_content,
&mut prev_panel_added,
self.render_config_panel(
&HeaderToolbarItemKind::CodeReview,
pane_group,
&config,
app,
),
app,
);
}
} else if !is_right_maximized {
main_content = main_content.with_child(Shrinkable::new(1.0, terminal_content).finish());
Expand Down Expand Up @@ -18915,6 +18923,18 @@ impl Workspace {
self.render_config_panel_maximized(pane_group, &config, app),
app,
);
} else if !config.contains_item(&HeaderToolbarItemKind::CodeReview) {
Self::add_panel_with_separator(
&mut panels_view,
&mut prev_panel_added,
self.render_config_panel(
&HeaderToolbarItemKind::CodeReview,
pane_group,
&config,
app,
),
app,
);
}
}

Expand Down Expand Up @@ -18974,7 +18994,7 @@ impl Workspace {
}

/// Renders a configurable panel for the given toolbar item, if it is open.
/// Returns `None` if the panel should not be rendered (item not available,
/// Returns `None` if the panel should not be rendered (item not supported,
/// panel not open, or item is not a panel type).
fn render_config_panel(
&self,
Expand All @@ -18983,7 +19003,7 @@ impl Workspace {
config: &HeaderToolbarChipSelection,
app: &AppContext,
) -> Option<Box<dyn Element>> {
if !item.is_available(app) || !item.is_panel() {
if !item.is_supported(app) || !item.is_panel() {
return None;
}
match item {
Expand Down Expand Up @@ -19029,7 +19049,7 @@ impl Workspace {
if !pane_group.right_panel_open || !pane_group.is_right_panel_maximized {
return None;
}
if !HeaderToolbarItemKind::CodeReview.is_available(app) {
if !HeaderToolbarItemKind::CodeReview.is_supported(app) {
return None;
}
Some(Shrinkable::new(1.0, ChildView::new(&self.right_panel_view).finish()).finish())
Expand Down
Loading