Rename DockItem to Panel

Nathan Sobo created

Change summary

crates/copilot_button/src/copilot_button.rs   |  2 
crates/feedback/src/deploy_feedback_button.rs |  2 
crates/project_panel/src/project_panel.rs     |  2 
crates/terminal_view/src/terminal_button.rs   |  2 
crates/theme/src/theme.rs                     |  4 +-
crates/workspace/src/dock.rs                  | 27 ++++++++++----------
crates/workspace/src/item.rs                  |  4 +-
crates/workspace/src/workspace.rs             |  4 +-
styles/src/styleTree/statusBar.ts             |  2 
9 files changed, 25 insertions(+), 24 deletions(-)

Detailed changes

crates/project_panel/src/project_panel.rs 🔗

@@ -1327,7 +1327,7 @@ impl Entity for ProjectPanel {
     type Event = Event;
 }
 
-impl workspace::dock::DockItem for ProjectPanel {
+impl workspace::dock::Panel for ProjectPanel {
     fn should_show_badge(&self, _: &AppContext) -> bool {
         false
     }

crates/theme/src/theme.rs 🔗

@@ -344,7 +344,7 @@ pub struct StatusBar {
 pub struct StatusBarPanelButtons {
     pub group_left: ContainerStyle,
     pub group_right: ContainerStyle,
-    pub item: Interactive<DockItem>,
+    pub button: Interactive<PanelButton>,
     pub badge: ContainerStyle,
 }
 
@@ -382,7 +382,7 @@ pub struct Dock {
 }
 
 #[derive(Clone, Deserialize, Default)]
-pub struct DockItem {
+pub struct PanelButton {
     #[serde(flatten)]
     pub container: ContainerStyle,
     pub icon_color: Color,

crates/workspace/src/dock.rs 🔗

@@ -7,7 +7,7 @@ use serde::Deserialize;
 use settings::Settings;
 use std::rc::Rc;
 
-pub trait DockItem: View {
+pub trait Panel: View {
     fn should_activate_item_on_event(&self, _: &Self::Event, _: &AppContext) -> bool {
         false
     }
@@ -19,16 +19,17 @@ pub trait DockItem: View {
     }
 }
 
-pub trait DockItemHandle {
+pub trait PanelHandle {
+
     fn id(&self) -> usize;
     fn should_show_badge(&self, cx: &WindowContext) -> bool;
     fn is_focused(&self, cx: &WindowContext) -> bool;
     fn as_any(&self) -> &AnyViewHandle;
 }
 
-impl<T> DockItemHandle for ViewHandle<T>
+impl<T> PanelHandle for ViewHandle<T>
 where
-    T: DockItem,
+    T: Panel,
 {
     fn id(&self) -> usize {
         self.id()
@@ -47,8 +48,8 @@ where
     }
 }
 
-impl From<&dyn DockItemHandle> for AnyViewHandle {
-    fn from(val: &dyn DockItemHandle) -> Self {
+impl From<&dyn PanelHandle> for AnyViewHandle {
+    fn from(val: &dyn PanelHandle) -> Self {
         val.as_any().clone()
     }
 }
@@ -78,7 +79,7 @@ impl DockPosition {
 struct Item {
     icon_path: &'static str,
     tooltip: String,
-    view: Rc<dyn DockItemHandle>,
+    view: Rc<dyn PanelHandle>,
     _subscriptions: [Subscription; 2],
 }
 
@@ -88,12 +89,12 @@ pub struct PanelButtons {
 }
 
 #[derive(Clone, Debug, Deserialize, PartialEq)]
-pub struct ToggleDockItem {
+pub struct TogglePanel {
     pub dock_position: DockPosition,
     pub item_index: usize,
 }
 
-impl_actions!(workspace, [ToggleDockItem]);
+impl_actions!(workspace, [TogglePanel]);
 
 impl Dock {
     pub fn new(position: DockPosition) -> Self {
@@ -126,7 +127,7 @@ impl Dock {
         cx.notify();
     }
 
-    pub fn add_item<T: DockItem>(
+    pub fn add_item<T: Panel>(
         &mut self,
         icon_path: &'static str,
         tooltip: String,
@@ -171,7 +172,7 @@ impl Dock {
         cx.notify();
     }
 
-    pub fn active_item(&self) -> Option<&Rc<dyn DockItemHandle>> {
+    pub fn active_item(&self) -> Option<&Rc<dyn PanelHandle>> {
         if self.is_open {
             self.items.get(self.active_item_ix).map(|item| &item.view)
         } else {
@@ -235,7 +236,7 @@ impl View for PanelButtons {
         let tooltip_style = theme.tooltip.clone();
         let theme = &theme.workspace.status_bar.panel_buttons;
         let dock = self.dock.read(cx);
-        let item_style = theme.item.clone();
+        let item_style = theme.button.clone();
         let badge_style = theme.badge;
         let active_ix = dock.active_item_ix;
         let is_open = dock.is_open;
@@ -255,7 +256,7 @@ impl View for PanelButtons {
         Flex::row()
             .with_children(items.into_iter().enumerate().map(
                 |(ix, (icon_path, tooltip, item_view))| {
-                    let action = ToggleDockItem {
+                    let action = TogglePanel {
                         dock_position,
                         item_index: ix,
                     };

crates/workspace/src/item.rs 🔗

@@ -766,7 +766,7 @@ impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {
 #[cfg(test)]
 pub(crate) mod test {
     use super::{Item, ItemEvent};
-    use crate::{dock::DockItem, ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId};
+    use crate::{dock::Panel, ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId};
     use gpui::{
         elements::Empty, AnyElement, AppContext, Element, Entity, ModelHandle, Task, View,
         ViewContext, ViewHandle, WeakViewHandle,
@@ -1060,5 +1060,5 @@ pub(crate) mod test {
         }
     }
 
-    impl DockItem for TestItem {}
+    impl Panel for TestItem {}
 }

crates/workspace/src/workspace.rs 🔗

@@ -74,7 +74,7 @@ use project::{Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId};
 use serde::Deserialize;
 use settings::{Autosave, Settings};
 use shared_screen::SharedScreen;
-use dock::{Dock, PanelButtons, DockPosition, ToggleDockItem};
+use dock::{Dock, PanelButtons, DockPosition, TogglePanel};
 use status_bar::StatusBar;
 pub use status_bar::StatusItemView;
 use theme::{Theme, ThemeRegistry};
@@ -1322,7 +1322,7 @@ impl Workspace {
         cx.notify();
     }
 
-    pub fn toggle_panel(&mut self, action: &ToggleDockItem, cx: &mut ViewContext<Self>) {
+    pub fn toggle_panel(&mut self, action: &TogglePanel, cx: &mut ViewContext<Self>) {
         let dock = match action.dock_position {
             DockPosition::Left => &mut self.left_dock,
             DockPosition::Right => &mut self.right_dock,

styles/src/styleTree/statusBar.ts 🔗

@@ -96,7 +96,7 @@ export default function statusBar(colorScheme: ColorScheme) {
         panelButtons: {
             groupLeft: {},
             groupRight: {},
-            item: {
+            button: {
                 ...statusContainer,
                 iconSize: 16,
                 iconColor: foreground(layer, "variant"),