From acbad4c7b791fd7bac8479a62d7ddc3b317d98ed Mon Sep 17 00:00:00 2001 From: Mikayla Date: Mon, 20 Nov 2023 10:34:22 -0800 Subject: [PATCH 01/10] WIP --- script/bundle | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/script/bundle b/script/bundle index 4561cec7c43ab1652c08bb3417d03b1e454904c2..417e286ec83195955204dfdbfce2e83ae43b2d47 100755 --- a/script/bundle +++ b/script/bundle @@ -10,6 +10,7 @@ local_only=false overwrite_local_app=false bundle_name="" zed_crate="zed" +binary_name="Zed" # This must match the team in the provsiioning profile. APPLE_NOTORIZATION_TEAM="MQ55VZLNZQ" @@ -50,7 +51,10 @@ do target_dir="debug" ;; f) overwrite_local_app=true;; - 2) zed_crate="zed2";; + 2) + zed_crate="zed2" + binary_name="Zed2" + ;; h) help_info exit 0 @@ -116,7 +120,7 @@ if [ "$local_arch" = false ]; then echo "Creating fat binaries" lipo \ -create \ - target/{x86_64-apple-darwin,aarch64-apple-darwin}/${target_dir}/Zed \ + target/{x86_64-apple-darwin,aarch64-apple-darwin}/${target_dir}/${binary_name} \ -output \ "${app_path}/Contents/MacOS/${zed_crate}" lipo \ From babd41916af4fff75b81044a9f8c68f53747da17 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 20 Nov 2023 10:46:16 -0800 Subject: [PATCH 02/10] Remove gpui (1) dependencies from zed2 Co-authored-by: Mikayla --- Cargo.lock | 6 ++---- crates/channel2/Cargo.toml | 2 +- crates/collab_ui2/Cargo.toml | 2 +- crates/project_panel2/Cargo.toml | 1 - crates/project_panel2/src/project_panel.rs | 1 - crates/zed2/Cargo.toml | 1 - 6 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4153e0c8c65bd80852184d075b11cbf0ea7cf5c4..904d99edf33f4189781499b0f732d0e325d79f64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1398,7 +1398,7 @@ dependencies = [ "smol", "sum_tree", "tempfile", - "text", + "text2", "thiserror", "time", "tiny_http", @@ -1867,7 +1867,7 @@ dependencies = [ "editor2", "feature_flags2", "futures 0.3.28", - "fuzzy", + "fuzzy2", "gpui2", "language2", "lazy_static", @@ -6761,7 +6761,6 @@ dependencies = [ "anyhow", "client2", "collections", - "context_menu", "db2", "editor2", "futures 0.3.28", @@ -11632,7 +11631,6 @@ dependencies = [ "fs2", "fsevent", "futures 0.3.28", - "fuzzy", "go_to_line2", "gpui2", "ignore", diff --git a/crates/channel2/Cargo.toml b/crates/channel2/Cargo.toml index c292d4e8ddbe50d0fe58c882d690181d58345b75..7af5aa1224d043895c3119e896dd12441f960d64 100644 --- a/crates/channel2/Cargo.toml +++ b/crates/channel2/Cargo.toml @@ -18,7 +18,7 @@ db = { package = "db2", path = "../db2" } gpui = { package = "gpui2", path = "../gpui2" } util = { path = "../util" } rpc = { package = "rpc2", path = "../rpc2" } -text = { path = "../text" } +text = { package = "text2", path = "../text2" } language = { package = "language2", path = "../language2" } settings = { package = "settings2", path = "../settings2" } feature_flags = { package = "feature_flags2", path = "../feature_flags2" } diff --git a/crates/collab_ui2/Cargo.toml b/crates/collab_ui2/Cargo.toml index 4660880ecdc39378aada464a145412dbbdd7b943..c7c00d7696c567d27b231733c50bd33c0c1e314b 100644 --- a/crates/collab_ui2/Cargo.toml +++ b/crates/collab_ui2/Cargo.toml @@ -33,7 +33,7 @@ collections = { path = "../collections" } # drag_and_drop = { path = "../drag_and_drop" } editor = { package="editor2", path = "../editor2" } #feedback = { path = "../feedback" } -fuzzy = { path = "../fuzzy" } +fuzzy = { package = "fuzzy2", path = "../fuzzy2" } gpui = { package = "gpui2", path = "../gpui2" } language = { package = "language2", path = "../language2" } menu = { package = "menu2", path = "../menu2" } diff --git a/crates/project_panel2/Cargo.toml b/crates/project_panel2/Cargo.toml index bd6bc59a652c9945280233bd8588a15ea25834e4..48abfbe1def3493c46e0ddbb21ad077232a41a70 100644 --- a/crates/project_panel2/Cargo.toml +++ b/crates/project_panel2/Cargo.toml @@ -9,7 +9,6 @@ path = "src/project_panel.rs" doctest = false [dependencies] -context_menu = { path = "../context_menu" } collections = { path = "../collections" } db = { path = "../db2", package = "db2" } editor = { path = "../editor2", package = "editor2" } diff --git a/crates/project_panel2/src/project_panel.rs b/crates/project_panel2/src/project_panel.rs index 57ede0c961e037cb22d961ee87a1c24b91f7170c..333d2c624296ec86fc32fec1cc4b58c5590d2032 100644 --- a/crates/project_panel2/src/project_panel.rs +++ b/crates/project_panel2/src/project_panel.rs @@ -247,7 +247,6 @@ impl ProjectPanel { let mut old_dock_position = this.position(cx); ProjectPanelSettings::register(cx); cx.observe_global::(move |this, cx| { - dbg!("OLA!"); let new_dock_position = this.position(cx); if new_dock_position != old_dock_position { old_dock_position = new_dock_position; diff --git a/crates/zed2/Cargo.toml b/crates/zed2/Cargo.toml index 6b9169e65a4d7c0bbb57e4177cb430da630920ac..e7fa3a7e34c15bf10df976445abcada6596e6f92 100644 --- a/crates/zed2/Cargo.toml +++ b/crates/zed2/Cargo.toml @@ -39,7 +39,6 @@ file_finder = { package="file_finder2", path = "../file_finder2" } # search = { path = "../search" } fs = { package = "fs2", path = "../fs2" } fsevent = { path = "../fsevent" } -fuzzy = { path = "../fuzzy" } go_to_line = { package = "go_to_line2", path = "../go_to_line2" } gpui = { package = "gpui2", path = "../gpui2" } install_cli = { package = "install_cli2", path = "../install_cli2" } From c571273ab43f164f3ec52523ceeb4cdb5435a598 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 20 Nov 2023 11:00:12 -0800 Subject: [PATCH 03/10] Allow bundling in debug mode with both architectures Co-authored-by: Mikayla --- script/bundle | 1 - 1 file changed, 1 deletion(-) diff --git a/script/bundle b/script/bundle index 417e286ec83195955204dfdbfce2e83ae43b2d47..95a789885f49a299bc33df7c7648bb273e10f8e9 100755 --- a/script/bundle +++ b/script/bundle @@ -39,7 +39,6 @@ do export CARGO_INCREMENTAL=true export CARGO_BUNDLE_SKIP_BUILD=true build_flag=""; - local_arch=true target_dir="debug" ;; l) From 6e84f740aa2c47367da93d71d9353705cb006db7 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 20 Nov 2023 11:01:37 -0800 Subject: [PATCH 04/10] Set -e in bump-nightly script Co-authored-by: Mikayla --- script/bump-nightly | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/bump-nightly b/script/bump-nightly index 92cdd191ebc4494bd1fad01d1a358abc6c16d10b..2b126d9afca616e69a7b636d0feb3c38a407abd7 100755 --- a/script/bump-nightly +++ b/script/bump-nightly @@ -1,5 +1,7 @@ #!/bin/bash +set -e + branch=$(git rev-parse --abbrev-ref HEAD) if [ "$branch" != "main" ]; then echo "You must be on main to run this script" From eb307b22f0c54d0eff30ebe22e2ca954267230ba Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Mon, 20 Nov 2023 14:58:31 -0500 Subject: [PATCH 05/10] Rework `List` to use `children` (#3369) This PR reworks the `List` component to use `children` instead of accepting a `Vec` in its constructor. This is a step towards making the `List` component more open. Release Notes: - N/A --- crates/terminal_view2/src/terminal_view.rs | 13 +- crates/ui2/src/components/context_menu.rs | 58 +++--- crates/ui2/src/components/list.rs | 113 +++-------- crates/ui2/src/static_data.rs | 206 +++++++++++---------- crates/ui2/src/to_extract/collab_panel.rs | 20 +- crates/ui2/src/to_extract/project_panel.rs | 20 +- crates/workspace2/src/dock.rs | 8 +- 7 files changed, 205 insertions(+), 233 deletions(-) diff --git a/crates/terminal_view2/src/terminal_view.rs b/crates/terminal_view2/src/terminal_view.rs index 3cbea11072eca30258ca33ae414705dedda57d55..330e289aa8292ec3083532bd44111907d9d7b03a 100644 --- a/crates/terminal_view2/src/terminal_view.rs +++ b/crates/terminal_view2/src/terminal_view.rs @@ -300,11 +300,14 @@ impl TerminalView { cx: &mut ViewContext, ) { self.context_menu = Some(ContextMenu::build(cx, |menu, _| { - menu.action(ListEntry::new(Label::new("Clear")), Box::new(Clear)) - .action( - ListEntry::new(Label::new("Close")), - Box::new(CloseActiveItem { save_intent: None }), - ) + menu.action( + ListEntry::new("clear", Label::new("Clear")), + Box::new(Clear), + ) + .action( + ListEntry::new("close", Label::new("Close")), + Box::new(CloseActiveItem { save_intent: None }), + ) })); dbg!(&position); // todo!() diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rs index 3814dca4711ab6ef319093af11de58a6554a8413..eb9daf3cda730c6004c08fa9c96a377f7100736b 100644 --- a/crates/ui2/src/components/context_menu.rs +++ b/crates/ui2/src/components/context_menu.rs @@ -1,7 +1,7 @@ use std::cell::RefCell; use std::rc::Rc; -use crate::{prelude::*, v_stack, List, ListItem}; +use crate::{prelude::*, v_stack, List}; use crate::{ListEntry, ListSeparator, ListSubHeader}; use gpui::{ overlay, px, Action, AnchorCorner, AnyElement, AppContext, Bounds, DispatchPhase, Div, @@ -9,7 +9,7 @@ use gpui::{ MouseDownEvent, Pixels, Point, Render, RenderOnce, View, VisualContext, WeakView, }; -pub enum ContextMenuItem { +pub enum ContextMenuItem { Separator(ListSeparator), Header(ListSubHeader), Entry( @@ -18,7 +18,7 @@ pub enum ContextMenuItem { ), } -pub struct ContextMenu { +pub struct ContextMenu { items: Vec>, focus_handle: FocusHandle, handle: WeakView, @@ -105,25 +105,25 @@ impl Render for ContextMenu { // .bg(cx.theme().colors().elevated_surface_background) // .border() // .border_color(cx.theme().colors().border) - .child(List::new( - self.items - .iter() - .map(|item| match item { - ContextMenuItem::Separator(separator) => { - ListItem::Separator(separator.clone()) - } - ContextMenuItem::Header(header) => ListItem::Header(header.clone()), - ContextMenuItem::Entry(entry, callback) => { - let callback = callback.clone(); - let handle = self.handle.clone(); - ListItem::Entry(entry.clone().on_click(move |this, cx| { + .child( + List::new().children(self.items.iter().map(|item| match item { + ContextMenuItem::Separator(separator) => { + separator.clone().render_into_any() + } + ContextMenuItem::Header(header) => header.clone().render_into_any(), + ContextMenuItem::Entry(entry, callback) => { + let callback = callback.clone(); + let handle = self.handle.clone(); + entry + .clone() + .on_click(move |this, cx| { handle.update(cx, |view, cx| callback(view, cx)).ok(); cx.emit(Manager::Dismiss); - })) - } - }) - .collect(), - )), + }) + .render_into_any() + } + })), + ), ) } } @@ -322,13 +322,17 @@ mod stories { ContextMenu::build(cx, |menu, _| { menu.header(header) .separator() - .entry(ListEntry::new(Label::new("Print current time")), |v, cx| { - println!("dispatching PrintCurrentTime action"); - cx.dispatch_action(PrintCurrentDate.boxed_clone()) - }) - .entry(ListEntry::new(Label::new("Print best food")), |v, cx| { - cx.dispatch_action(PrintBestFood.boxed_clone()) - }) + .entry( + ListEntry::new("Print current time", Label::new("Print current time")), + |v, cx| { + println!("dispatching PrintCurrentTime action"); + cx.dispatch_action(PrintCurrentDate.boxed_clone()) + }, + ) + .entry( + ListEntry::new("Print best food", Label::new("Print best food")), + |v, cx| cx.dispatch_action(PrintBestFood.boxed_clone()), + ) }) } diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs index 485253d4dfc2db6918be7133518e3e9ce0bda77f..59a97e0c5d39b20a5372f40bd4c154ce75406a99 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -1,4 +1,5 @@ -use gpui::{div, Div, RenderOnce, Stateful, StatefulInteractiveElement}; +use gpui::{div, AnyElement, Div, RenderOnce, Stateful, StatefulInteractiveElement}; +use smallvec::SmallVec; use std::rc::Rc; use crate::settings::user_settings; @@ -177,7 +178,7 @@ impl ListHeader { // } } -#[derive(Clone)] +#[derive(RenderOnce, Clone)] pub struct ListSubHeader { label: SharedString, left_icon: Option, @@ -197,8 +198,12 @@ impl ListSubHeader { self.left_icon = left_icon; self } +} + +impl Component for ListSubHeader { + type Rendered = Div; - fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Element { + fn render(self, view: &mut V, cx: &mut ViewContext) -> Self::Rendered { h_stack().flex_1().w_full().relative().py_1().child( div() .h_6() @@ -232,55 +237,9 @@ pub enum ListEntrySize { Medium, } -#[derive(Clone)] -pub enum ListItem { - Entry(ListEntry), - Separator(ListSeparator), - Header(ListSubHeader), -} - -impl From> for ListItem { - fn from(entry: ListEntry) -> Self { - Self::Entry(entry) - } -} - -impl From for ListItem { - fn from(entry: ListSeparator) -> Self { - Self::Separator(entry) - } -} - -impl From for ListItem { - fn from(entry: ListSubHeader) -> Self { - Self::Header(entry) - } -} - -impl ListItem { - pub fn new(label: Label) -> Self { - Self::Entry(ListEntry::new(label)) - } - - pub fn as_entry(&mut self) -> Option<&mut ListEntry> { - if let Self::Entry(entry) = self { - Some(entry) - } else { - None - } - } - - fn render(self, view: &mut V, ix: usize, cx: &mut ViewContext) -> Div { - match self { - ListItem::Entry(entry) => div().child(entry.render(ix, cx)), - ListItem::Separator(separator) => div().child(separator.render(view, cx)), - ListItem::Header(header) => div().child(header.render(view, cx)), - } - } -} - -// #[derive(RenderOnce)] -pub struct ListEntry { +#[derive(RenderOnce)] +pub struct ListEntry { + id: ElementId, disabled: bool, // TODO: Reintroduce this // disclosure_control_style: DisclosureControlVisibility, @@ -297,6 +256,7 @@ pub struct ListEntry { impl Clone for ListEntry { fn clone(&self) -> Self { Self { + id: self.id.clone(), disabled: self.disabled, indent_level: self.indent_level, label: self.label.clone(), @@ -311,8 +271,9 @@ impl Clone for ListEntry { } impl ListEntry { - pub fn new(label: Label) -> Self { + pub fn new(id: impl Into, label: Label) -> Self { Self { + id: id.into(), disabled: false, indent_level: 0, label, @@ -364,8 +325,12 @@ impl ListEntry { self.size = size; self } +} + +impl Component for ListEntry { + type Rendered = Stateful>; - fn render(self, ix: usize, cx: &mut ViewContext) -> Stateful> { + fn render(self, view: &mut V, cx: &mut ViewContext) -> Self::Rendered { let settings = user_settings(cx); let left_content = match self.left_slot.clone() { @@ -386,7 +351,7 @@ impl ListEntry { ListEntrySize::Medium => div().h_7(), }; div() - .id(ix) + .id(self.id) .relative() .hover(|mut style| { style.background = Some(cx.theme().colors().editor_background.into()); @@ -454,25 +419,20 @@ impl Component for ListSeparator { #[derive(RenderOnce)] pub struct List { - items: Vec>, /// Message to display when the list is empty /// Defaults to "No items" empty_message: SharedString, header: Option, toggle: Toggle, + children: SmallVec<[AnyElement; 2]>, } impl Component for List { type Rendered = Div; fn render(self, view: &mut V, cx: &mut ViewContext) -> Self::Rendered { - let list_content = match (self.items.is_empty(), self.toggle) { - (false, _) => div().children( - self.items - .into_iter() - .enumerate() - .map(|(ix, item)| item.render(view, ix, cx)), - ), + let list_content = match (self.children.is_empty(), self.toggle) { + (false, _) => div().children(self.children), (true, Toggle::Toggled(false)) => div(), (true, _) => { div().child(Label::new(self.empty_message.clone()).color(TextColor::Muted)) @@ -488,12 +448,12 @@ impl Component for List { } impl List { - pub fn new(items: Vec>) -> Self { + pub fn new() -> Self { Self { - items, empty_message: "No items".into(), header: None, toggle: Toggle::NotToggleable, + children: SmallVec::new(), } } @@ -511,25 +471,10 @@ impl List { self.toggle = toggle; self } +} - fn render(self, view: &mut V, cx: &mut ViewContext) -> impl Element { - let list_content = match (self.items.is_empty(), self.toggle) { - (false, _) => div().children( - self.items - .into_iter() - .enumerate() - .map(|(ix, item)| item.render(view, ix, cx)), - ), - (true, Toggle::Toggled(false)) => div(), - (true, _) => { - div().child(Label::new(self.empty_message.clone()).color(TextColor::Muted)) - } - }; - - v_stack() - .w_full() - .py_1() - .children(self.header.map(|header| header)) - .child(list_content) +impl ParentElement for List { + fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> { + &mut self.children } } diff --git a/crates/ui2/src/static_data.rs b/crates/ui2/src/static_data.rs index 673766c41108b2dd170e0ce08414bbe25c6872a9..84d89eb0926a9a29419541ebb27ea3731271a702 100644 --- a/crates/ui2/src/static_data.rs +++ b/crates/ui2/src/static_data.rs @@ -7,14 +7,13 @@ use gpui::{AppContext, ViewContext}; use rand::Rng; use theme2::ActiveTheme; -use crate::{binding, HighlightedText}; use crate::{ - Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus, - HighlightedLine, Icon, KeyBinding, Label, ListEntry, ListEntrySize, Livestream, MicStatus, - Notification, PaletteItem, Player, PlayerCallStatus, PlayerWithCallStatus, PublicPlayer, - ScreenShareStatus, Symbol, Tab, TextColor, Toggle, VideoStatus, + binding, Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus, + HighlightedLine, HighlightedText, Icon, KeyBinding, Label, ListEntry, ListEntrySize, + Livestream, MicStatus, Notification, NotificationAction, PaletteItem, Player, PlayerCallStatus, + PlayerWithCallStatus, PublicPlayer, ScreenShareStatus, Symbol, Tab, TextColor, Toggle, + VideoStatus, }; -use crate::{ListItem, NotificationAction}; pub fn static_tabs_example() -> Vec { vec![ @@ -478,225 +477,238 @@ pub fn static_new_notification_items_2() -> Vec> { ] } -pub fn static_project_panel_project_items() -> Vec> { +pub fn static_project_panel_project_items() -> Vec> { vec![ - ListEntry::new(Label::new("zed")) + ListEntry::new("zed", Label::new("zed")) .left_icon(Icon::FolderOpen.into()) .indent_level(0) .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new(".cargo")) + ListEntry::new(".cargo", Label::new(".cargo")) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(Label::new(".config")) + ListEntry::new(".config", Label::new(".config")) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(Label::new(".git").color(TextColor::Hidden)) + ListEntry::new(".git", Label::new(".git").color(TextColor::Hidden)) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(Label::new(".cargo")) + ListEntry::new(".cargo", Label::new(".cargo")) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(Label::new(".idea").color(TextColor::Hidden)) + ListEntry::new(".idea", Label::new(".idea").color(TextColor::Hidden)) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(Label::new("assets")) + ListEntry::new("assets", Label::new("assets")) .left_icon(Icon::Folder.into()) .indent_level(1) .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new("cargo-target").color(TextColor::Hidden)) - .left_icon(Icon::Folder.into()) - .indent_level(1), - ListEntry::new(Label::new("crates")) + ListEntry::new( + "cargo-target", + Label::new("cargo-target").color(TextColor::Hidden), + ) + .left_icon(Icon::Folder.into()) + .indent_level(1), + ListEntry::new("crates", Label::new("crates")) .left_icon(Icon::FolderOpen.into()) .indent_level(1) .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new("activity_indicator")) + ListEntry::new("activity_indicator", Label::new("activity_indicator")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new(Label::new("ai")) + ListEntry::new("ai", Label::new("ai")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new(Label::new("audio")) + ListEntry::new("audio", Label::new("audio")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new(Label::new("auto_update")) + ListEntry::new("auto_update", Label::new("auto_update")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new(Label::new("breadcrumbs")) + ListEntry::new("breadcrumbs", Label::new("breadcrumbs")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new(Label::new("call")) + ListEntry::new("call", Label::new("call")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new(Label::new("sqlez").color(TextColor::Modified)) + ListEntry::new("sqlez", Label::new("sqlez").color(TextColor::Modified)) .left_icon(Icon::Folder.into()) .indent_level(2) .toggle(Toggle::Toggled(false)), - ListEntry::new(Label::new("gpui2")) + ListEntry::new("gpui2", Label::new("gpui2")) .left_icon(Icon::FolderOpen.into()) .indent_level(2) .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new("src")) + ListEntry::new("src", Label::new("src")) .left_icon(Icon::FolderOpen.into()) .indent_level(3) .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new("derive_element.rs")) + ListEntry::new("derive_element.rs", Label::new("derive_element.rs")) .left_icon(Icon::FileRust.into()) .indent_level(4), - ListEntry::new(Label::new("storybook").color(TextColor::Modified)) - .left_icon(Icon::FolderOpen.into()) - .indent_level(1) - .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new("docs").color(TextColor::Default)) + ListEntry::new( + "storybook", + Label::new("storybook").color(TextColor::Modified), + ) + .left_icon(Icon::FolderOpen.into()) + .indent_level(1) + .toggle(Toggle::Toggled(true)), + ListEntry::new("docs", Label::new("docs").color(TextColor::Default)) .left_icon(Icon::Folder.into()) .indent_level(2) .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new("src").color(TextColor::Modified)) + ListEntry::new("src", Label::new("src").color(TextColor::Modified)) .left_icon(Icon::FolderOpen.into()) .indent_level(3) .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new("ui").color(TextColor::Modified)) + ListEntry::new("ui", Label::new("ui").color(TextColor::Modified)) .left_icon(Icon::FolderOpen.into()) .indent_level(4) .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new("component").color(TextColor::Created)) - .left_icon(Icon::FolderOpen.into()) - .indent_level(5) - .toggle(Toggle::Toggled(true)), - ListEntry::new(Label::new("facepile.rs").color(TextColor::Default)) - .left_icon(Icon::FileRust.into()) - .indent_level(6), - ListEntry::new(Label::new("follow_group.rs").color(TextColor::Default)) + ListEntry::new( + "component", + Label::new("component").color(TextColor::Created), + ) + .left_icon(Icon::FolderOpen.into()) + .indent_level(5) + .toggle(Toggle::Toggled(true)), + ListEntry::new( + "facepile.rs", + Label::new("facepile.rs").color(TextColor::Default), + ) + .left_icon(Icon::FileRust.into()) + .indent_level(6), + ListEntry::new( + "follow_group.rs", + Label::new("follow_group.rs").color(TextColor::Default), + ) + .left_icon(Icon::FileRust.into()) + .indent_level(6), + ListEntry::new( + "list_item.rs", + Label::new("list_item.rs").color(TextColor::Created), + ) + .left_icon(Icon::FileRust.into()) + .indent_level(6), + ListEntry::new("tab.rs", Label::new("tab.rs").color(TextColor::Default)) .left_icon(Icon::FileRust.into()) .indent_level(6), - ListEntry::new(Label::new("list_item.rs").color(TextColor::Created)) - .left_icon(Icon::FileRust.into()) - .indent_level(6), - ListEntry::new(Label::new("tab.rs").color(TextColor::Default)) - .left_icon(Icon::FileRust.into()) - .indent_level(6), - ListEntry::new(Label::new("target").color(TextColor::Hidden)) + ListEntry::new("target", Label::new("target").color(TextColor::Hidden)) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(Label::new(".dockerignore")) + ListEntry::new(".dockerignore", Label::new(".dockerignore")) .left_icon(Icon::FileGeneric.into()) .indent_level(1), - ListEntry::new(Label::new(".DS_Store").color(TextColor::Hidden)) - .left_icon(Icon::FileGeneric.into()) - .indent_level(1), - ListEntry::new(Label::new("Cargo.lock")) + ListEntry::new( + ".DS_Store", + Label::new(".DS_Store").color(TextColor::Hidden), + ) + .left_icon(Icon::FileGeneric.into()) + .indent_level(1), + ListEntry::new("Cargo.lock", Label::new("Cargo.lock")) .left_icon(Icon::FileLock.into()) .indent_level(1), - ListEntry::new(Label::new("Cargo.toml")) + ListEntry::new("Cargo.toml", Label::new("Cargo.toml")) .left_icon(Icon::FileToml.into()) .indent_level(1), - ListEntry::new(Label::new("Dockerfile")) + ListEntry::new("Dockerfile", Label::new("Dockerfile")) .left_icon(Icon::FileGeneric.into()) .indent_level(1), - ListEntry::new(Label::new("Procfile")) + ListEntry::new("Procfile", Label::new("Procfile")) .left_icon(Icon::FileGeneric.into()) .indent_level(1), - ListEntry::new(Label::new("README.md")) + ListEntry::new("README.md", Label::new("README.md")) .left_icon(Icon::FileDoc.into()) .indent_level(1), ] - .into_iter() - .map(From::from) - .collect() } -pub fn static_project_panel_single_items() -> Vec> { +pub fn static_project_panel_single_items() -> Vec> { vec![ - ListEntry::new(Label::new("todo.md")) + ListEntry::new("todo.md", Label::new("todo.md")) .left_icon(Icon::FileDoc.into()) .indent_level(0), - ListEntry::new(Label::new("README.md")) + ListEntry::new("README.md", Label::new("README.md")) .left_icon(Icon::FileDoc.into()) .indent_level(0), - ListEntry::new(Label::new("config.json")) + ListEntry::new("config.json", Label::new("config.json")) .left_icon(Icon::FileGeneric.into()) .indent_level(0), ] - .into_iter() - .map(From::from) - .collect() } -pub fn static_collab_panel_current_call() -> Vec> { +pub fn static_collab_panel_current_call() -> Vec> { vec![ - ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"), - ListEntry::new(Label::new("nathansobo")) + ListEntry::new("as-cii", Label::new("as-cii")) + .left_avatar("http://github.com/as-cii.png?s=50"), + ListEntry::new("nathansobo", Label::new("nathansobo")) .left_avatar("http://github.com/nathansobo.png?s=50"), - ListEntry::new(Label::new("maxbrunsfeld")) + ListEntry::new("maxbrunsfeld", Label::new("maxbrunsfeld")) .left_avatar("http://github.com/maxbrunsfeld.png?s=50"), ] - .into_iter() - .map(From::from) - .collect() } -pub fn static_collab_panel_channels() -> Vec> { +pub fn static_collab_panel_channels() -> Vec> { vec![ - ListEntry::new(Label::new("zed")) + ListEntry::new("zed", Label::new("zed")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(0), - ListEntry::new(Label::new("community")) + ListEntry::new("community", Label::new("community")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(1), - ListEntry::new(Label::new("dashboards")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListEntry::new(Label::new("feedback")) + ListEntry::new("dashboards", Label::new("dashboards")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new(Label::new("teams-in-channels-alpha")) + ListEntry::new("feedback", Label::new("feedback")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new(Label::new("current-projects")) + ListEntry::new( + "teams-in-channels-alpha", + Label::new("teams-in-channels-alpha"), + ) + .left_icon(Icon::Hash.into()) + .size(ListEntrySize::Medium) + .indent_level(2), + ListEntry::new("current-projects", Label::new("current-projects")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(1), - ListEntry::new(Label::new("codegen")) + ListEntry::new("codegen", Label::new("codegen")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new(Label::new("gpui2")) + ListEntry::new("gpui2", Label::new("gpui2")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new(Label::new("livestreaming")) + ListEntry::new("livestreaming", Label::new("livestreaming")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new(Label::new("open-source")) + ListEntry::new("open-source", Label::new("open-source")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new(Label::new("replace")) + ListEntry::new("replace", Label::new("replace")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new(Label::new("semantic-index")) + ListEntry::new("semantic-index", Label::new("semantic-index")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new(Label::new("vim")) + ListEntry::new("vim", Label::new("vim")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new(Label::new("web-tech")) + ListEntry::new("web-tech", Label::new("web-tech")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), ] - .into_iter() - .map(From::from) - .collect() } pub fn example_editor_actions() -> Vec { diff --git a/crates/ui2/src/to_extract/collab_panel.rs b/crates/ui2/src/to_extract/collab_panel.rs index e5fafa62f143a15415610236a460f4271874f527..aa12e354bccb7c98158d71059a0ed97d44a0fce9 100644 --- a/crates/ui2/src/to_extract/collab_panel.rs +++ b/crates/ui2/src/to_extract/collab_panel.rs @@ -28,41 +28,45 @@ impl Component for CollabPanel { .border_color(cx.theme().colors().border) .border_b() .child( - List::new(static_collab_panel_current_call()) + List::new() .header( ListHeader::new("CRDB") .left_icon(Icon::Hash.into()) .toggle(Toggle::Toggled(true)), ) - .toggle(Toggle::Toggled(true)), + .toggle(Toggle::Toggled(true)) + .children(static_collab_panel_current_call()), ), ) .child( v_stack().id("channels").py_1().child( - List::new(static_collab_panel_channels()) + List::new() .header(ListHeader::new("CHANNELS").toggle(Toggle::Toggled(true))) .empty_message("No channels yet. Add a channel to get started.") - .toggle(Toggle::Toggled(true)), + .toggle(Toggle::Toggled(true)) + .children(static_collab_panel_channels()), ), ) .child( v_stack().id("contacts-online").py_1().child( - List::new(static_collab_panel_current_call()) + List::new() .header( ListHeader::new("CONTACTS – ONLINE") .toggle(Toggle::Toggled(true)), ) - .toggle(Toggle::Toggled(true)), + .toggle(Toggle::Toggled(true)) + .children(static_collab_panel_current_call()), ), ) .child( v_stack().id("contacts-offline").py_1().child( - List::new(static_collab_panel_current_call()) + List::new() .header( ListHeader::new("CONTACTS – OFFLINE") .toggle(Toggle::Toggled(false)), ) - .toggle(Toggle::Toggled(false)), + .toggle(Toggle::Toggled(false)) + .children(static_collab_panel_current_call()), ), ), ) diff --git a/crates/ui2/src/to_extract/project_panel.rs b/crates/ui2/src/to_extract/project_panel.rs index 06735356c7f0b178900220742d4a6617c3dea9da..cd19c6a8a8acd75dad93b6d1810591ba8caf02ee 100644 --- a/crates/ui2/src/to_extract/project_panel.rs +++ b/crates/ui2/src/to_extract/project_panel.rs @@ -29,14 +29,16 @@ impl Component for ProjectPanel { .flex_col() .overflow_y_scroll() .child( - List::new(static_project_panel_single_items()) + List::new() .header(ListHeader::new("FILES")) - .empty_message("No files in directory"), + .empty_message("No files in directory") + .children(static_project_panel_single_items()), ) .child( - List::new(static_project_panel_project_items()) + List::new() .header(ListHeader::new("PROJECT")) - .empty_message("No folders in directory"), + .empty_message("No folders in directory") + .children(static_project_panel_project_items()), ), ) .child( @@ -67,14 +69,16 @@ impl ProjectPanel { .flex_col() .overflow_y_scroll() .child( - List::new(static_project_panel_single_items()) + List::new() .header(ListHeader::new("FILES")) - .empty_message("No files in directory"), + .empty_message("No files in directory") + .children(static_project_panel_single_items()), ) .child( - List::new(static_project_panel_project_items()) + List::new() .header(ListHeader::new("PROJECT")) - .empty_message("No folders in directory"), + .empty_message("No folders in directory") + .children(static_project_panel_project_items()), ), ) .child( diff --git a/crates/workspace2/src/dock.rs b/crates/workspace2/src/dock.rs index 9d812676038b9e41a00e1848f48d93ca05cab77a..d41f2b007873253fed21e53401338f59569f58a4 100644 --- a/crates/workspace2/src/dock.rs +++ b/crates/workspace2/src/dock.rs @@ -719,10 +719,10 @@ impl Render for PanelButtons { { let panel = panel.clone(); menu = menu.entry( - ListEntry::new(Label::new(format!( - "Dock {}", - position.to_label() - ))), + ListEntry::new( + SharedString::from(format!("dock-{position:?}")), + Label::new(format!("Dock {}", position.to_label())), + ), move |_, cx| { panel.set_position(position, cx); }, From 27318554872275e5cd9d013e5f383e69759ae406 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 20 Nov 2023 12:10:35 -0800 Subject: [PATCH 06/10] Fix error when building live_kit_client2 for two architectures concurrently Co-authored-by: Julia --- crates/live_kit_client2/build.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/live_kit_client2/build.rs b/crates/live_kit_client2/build.rs index b346b3168bc608006b6c32e4cfbd2c54ff0f9f1c..a2b7ef866d998c05352f656def209c82a5aac0af 100644 --- a/crates/live_kit_client2/build.rs +++ b/crates/live_kit_client2/build.rs @@ -61,12 +61,14 @@ fn build_bridge(swift_target: &SwiftTarget) { let swift_package_root = swift_package_root(); let swift_target_folder = swift_target_folder(); + let swift_cache_folder = swift_cache_folder(); if !Command::new("swift") .arg("build") .arg("--disable-automatic-resolution") .args(["--configuration", &env::var("PROFILE").unwrap()]) .args(["--triple", &swift_target.target.triple]) .args(["--build-path".into(), swift_target_folder]) + .args(["--cache-path".into(), swift_cache_folder]) .current_dir(&swift_package_root) .status() .unwrap() @@ -133,9 +135,17 @@ fn swift_package_root() -> PathBuf { } fn swift_target_folder() -> PathBuf { + let target = env::var("TARGET").unwrap(); env::current_dir() .unwrap() - .join(format!("../../target/{SWIFT_PACKAGE_NAME}")) + .join(format!("../../target/{target}/{SWIFT_PACKAGE_NAME}_target")) +} + +fn swift_cache_folder() -> PathBuf { + let target = env::var("TARGET").unwrap(); + env::current_dir() + .unwrap() + .join(format!("../../target/{target}/{SWIFT_PACKAGE_NAME}_cache")) } fn copy_dir(source: &Path, destination: &Path) { From 652e3b0bb6929ab4d90276f7538e54bb08f7e2ab Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Mon, 20 Nov 2023 16:13:06 -0500 Subject: [PATCH 07/10] Rename `ListEntry` to `ListItem` (#3371) This PR renames the `ListEntry` component to `ListItem` to better reflect its intent. Release Notes: - N/A --- crates/terminal_view2/src/terminal_view.rs | 15 +-- crates/ui2/src/components/context_menu.rs | 12 +- crates/ui2/src/components/list.rs | 8 +- crates/ui2/src/static_data.rs | 124 ++++++++++----------- crates/workspace2/src/dock.rs | 4 +- 5 files changed, 80 insertions(+), 83 deletions(-) diff --git a/crates/terminal_view2/src/terminal_view.rs b/crates/terminal_view2/src/terminal_view.rs index 330e289aa8292ec3083532bd44111907d9d7b03a..0d813986273e18e1f6e6ebe69ea007b95762125b 100644 --- a/crates/terminal_view2/src/terminal_view.rs +++ b/crates/terminal_view2/src/terminal_view.rs @@ -31,7 +31,7 @@ use workspace::{ notifications::NotifyResultExt, register_deserializable_item, searchable::{SearchEvent, SearchOptions, SearchableItem}, - ui::{ContextMenu, Icon, IconElement, Label, ListEntry}, + ui::{ContextMenu, Icon, IconElement, Label, ListItem}, CloseActiveItem, NewCenterTerminal, Pane, ToolbarItemLocation, Workspace, WorkspaceId, }; @@ -300,14 +300,11 @@ impl TerminalView { cx: &mut ViewContext, ) { self.context_menu = Some(ContextMenu::build(cx, |menu, _| { - menu.action( - ListEntry::new("clear", Label::new("Clear")), - Box::new(Clear), - ) - .action( - ListEntry::new("close", Label::new("Close")), - Box::new(CloseActiveItem { save_intent: None }), - ) + menu.action(ListItem::new("clear", Label::new("Clear")), Box::new(Clear)) + .action( + ListItem::new("close", Label::new("Close")), + Box::new(CloseActiveItem { save_intent: None }), + ) })); dbg!(&position); // todo!() diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rs index eb9daf3cda730c6004c08fa9c96a377f7100736b..2c2d45f4f0df5d49e29600d2e72899e92e3d3f8c 100644 --- a/crates/ui2/src/components/context_menu.rs +++ b/crates/ui2/src/components/context_menu.rs @@ -2,7 +2,7 @@ use std::cell::RefCell; use std::rc::Rc; use crate::{prelude::*, v_stack, List}; -use crate::{ListEntry, ListSeparator, ListSubHeader}; +use crate::{ListItem, ListSeparator, ListSubHeader}; use gpui::{ overlay, px, Action, AnchorCorner, AnyElement, AppContext, Bounds, DispatchPhase, Div, EventEmitter, FocusHandle, FocusableView, LayoutId, ManagedView, Manager, MouseButton, @@ -13,7 +13,7 @@ pub enum ContextMenuItem { Separator(ListSeparator), Header(ListSubHeader), Entry( - ListEntry>, + ListItem>, Rc)>, ), } @@ -63,7 +63,7 @@ impl ContextMenu { pub fn entry( mut self, - view: ListEntry, + view: ListItem, on_click: impl Fn(&mut V, &mut ViewContext) + 'static, ) -> Self { self.items @@ -71,7 +71,7 @@ impl ContextMenu { self } - pub fn action(self, view: ListEntry, action: Box) -> Self { + pub fn action(self, view: ListItem, action: Box) -> Self { // todo: add the keybindings to the list entry self.entry(view, move |_, cx| cx.dispatch_action(action.boxed_clone())) } @@ -323,14 +323,14 @@ mod stories { menu.header(header) .separator() .entry( - ListEntry::new("Print current time", Label::new("Print current time")), + ListItem::new("Print current time", Label::new("Print current time")), |v, cx| { println!("dispatching PrintCurrentTime action"); cx.dispatch_action(PrintCurrentDate.boxed_clone()) }, ) .entry( - ListEntry::new("Print best food", Label::new("Print best food")), + ListItem::new("Print best food", Label::new("Print best food")), |v, cx| cx.dispatch_action(PrintBestFood.boxed_clone()), ) }) diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs index 59a97e0c5d39b20a5372f40bd4c154ce75406a99..fb0c730db8b7fd0e2ed49c645ea6433b4887a1a9 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -238,7 +238,7 @@ pub enum ListEntrySize { } #[derive(RenderOnce)] -pub struct ListEntry { +pub struct ListItem { id: ElementId, disabled: bool, // TODO: Reintroduce this @@ -253,7 +253,7 @@ pub struct ListEntry { on_click: Option) + 'static>>, } -impl Clone for ListEntry { +impl Clone for ListItem { fn clone(&self) -> Self { Self { id: self.id.clone(), @@ -270,7 +270,7 @@ impl Clone for ListEntry { } } -impl ListEntry { +impl ListItem { pub fn new(id: impl Into, label: Label) -> Self { Self { id: id.into(), @@ -327,7 +327,7 @@ impl ListEntry { } } -impl Component for ListEntry { +impl Component for ListItem { type Rendered = Stateful>; fn render(self, view: &mut V, cx: &mut ViewContext) -> Self::Rendered { diff --git a/crates/ui2/src/static_data.rs b/crates/ui2/src/static_data.rs index 84d89eb0926a9a29419541ebb27ea3731271a702..266889a7961119979436dac7ae63261a77f49a88 100644 --- a/crates/ui2/src/static_data.rs +++ b/crates/ui2/src/static_data.rs @@ -9,8 +9,8 @@ use theme2::ActiveTheme; use crate::{ binding, Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus, - HighlightedLine, HighlightedText, Icon, KeyBinding, Label, ListEntry, ListEntrySize, - Livestream, MicStatus, Notification, NotificationAction, PaletteItem, Player, PlayerCallStatus, + HighlightedLine, HighlightedText, Icon, KeyBinding, Label, ListEntrySize, ListItem, Livestream, + MicStatus, Notification, NotificationAction, PaletteItem, Player, PlayerCallStatus, PlayerWithCallStatus, PublicPlayer, ScreenShareStatus, Symbol, Tab, TextColor, Toggle, VideoStatus, }; @@ -477,234 +477,234 @@ pub fn static_new_notification_items_2() -> Vec> { ] } -pub fn static_project_panel_project_items() -> Vec> { +pub fn static_project_panel_project_items() -> Vec> { vec![ - ListEntry::new("zed", Label::new("zed")) + ListItem::new("zed", Label::new("zed")) .left_icon(Icon::FolderOpen.into()) .indent_level(0) .toggle(Toggle::Toggled(true)), - ListEntry::new(".cargo", Label::new(".cargo")) + ListItem::new(".cargo", Label::new(".cargo")) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(".config", Label::new(".config")) + ListItem::new(".config", Label::new(".config")) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(".git", Label::new(".git").color(TextColor::Hidden)) + ListItem::new(".git", Label::new(".git").color(TextColor::Hidden)) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(".cargo", Label::new(".cargo")) + ListItem::new(".cargo", Label::new(".cargo")) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(".idea", Label::new(".idea").color(TextColor::Hidden)) + ListItem::new(".idea", Label::new(".idea").color(TextColor::Hidden)) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new("assets", Label::new("assets")) + ListItem::new("assets", Label::new("assets")) .left_icon(Icon::Folder.into()) .indent_level(1) .toggle(Toggle::Toggled(true)), - ListEntry::new( + ListItem::new( "cargo-target", Label::new("cargo-target").color(TextColor::Hidden), ) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new("crates", Label::new("crates")) + ListItem::new("crates", Label::new("crates")) .left_icon(Icon::FolderOpen.into()) .indent_level(1) .toggle(Toggle::Toggled(true)), - ListEntry::new("activity_indicator", Label::new("activity_indicator")) + ListItem::new("activity_indicator", Label::new("activity_indicator")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new("ai", Label::new("ai")) + ListItem::new("ai", Label::new("ai")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new("audio", Label::new("audio")) + ListItem::new("audio", Label::new("audio")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new("auto_update", Label::new("auto_update")) + ListItem::new("auto_update", Label::new("auto_update")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new("breadcrumbs", Label::new("breadcrumbs")) + ListItem::new("breadcrumbs", Label::new("breadcrumbs")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new("call", Label::new("call")) + ListItem::new("call", Label::new("call")) .left_icon(Icon::Folder.into()) .indent_level(2), - ListEntry::new("sqlez", Label::new("sqlez").color(TextColor::Modified)) + ListItem::new("sqlez", Label::new("sqlez").color(TextColor::Modified)) .left_icon(Icon::Folder.into()) .indent_level(2) .toggle(Toggle::Toggled(false)), - ListEntry::new("gpui2", Label::new("gpui2")) + ListItem::new("gpui2", Label::new("gpui2")) .left_icon(Icon::FolderOpen.into()) .indent_level(2) .toggle(Toggle::Toggled(true)), - ListEntry::new("src", Label::new("src")) + ListItem::new("src", Label::new("src")) .left_icon(Icon::FolderOpen.into()) .indent_level(3) .toggle(Toggle::Toggled(true)), - ListEntry::new("derive_element.rs", Label::new("derive_element.rs")) + ListItem::new("derive_element.rs", Label::new("derive_element.rs")) .left_icon(Icon::FileRust.into()) .indent_level(4), - ListEntry::new( + ListItem::new( "storybook", Label::new("storybook").color(TextColor::Modified), ) .left_icon(Icon::FolderOpen.into()) .indent_level(1) .toggle(Toggle::Toggled(true)), - ListEntry::new("docs", Label::new("docs").color(TextColor::Default)) + ListItem::new("docs", Label::new("docs").color(TextColor::Default)) .left_icon(Icon::Folder.into()) .indent_level(2) .toggle(Toggle::Toggled(true)), - ListEntry::new("src", Label::new("src").color(TextColor::Modified)) + ListItem::new("src", Label::new("src").color(TextColor::Modified)) .left_icon(Icon::FolderOpen.into()) .indent_level(3) .toggle(Toggle::Toggled(true)), - ListEntry::new("ui", Label::new("ui").color(TextColor::Modified)) + ListItem::new("ui", Label::new("ui").color(TextColor::Modified)) .left_icon(Icon::FolderOpen.into()) .indent_level(4) .toggle(Toggle::Toggled(true)), - ListEntry::new( + ListItem::new( "component", Label::new("component").color(TextColor::Created), ) .left_icon(Icon::FolderOpen.into()) .indent_level(5) .toggle(Toggle::Toggled(true)), - ListEntry::new( + ListItem::new( "facepile.rs", Label::new("facepile.rs").color(TextColor::Default), ) .left_icon(Icon::FileRust.into()) .indent_level(6), - ListEntry::new( + ListItem::new( "follow_group.rs", Label::new("follow_group.rs").color(TextColor::Default), ) .left_icon(Icon::FileRust.into()) .indent_level(6), - ListEntry::new( + ListItem::new( "list_item.rs", Label::new("list_item.rs").color(TextColor::Created), ) .left_icon(Icon::FileRust.into()) .indent_level(6), - ListEntry::new("tab.rs", Label::new("tab.rs").color(TextColor::Default)) + ListItem::new("tab.rs", Label::new("tab.rs").color(TextColor::Default)) .left_icon(Icon::FileRust.into()) .indent_level(6), - ListEntry::new("target", Label::new("target").color(TextColor::Hidden)) + ListItem::new("target", Label::new("target").color(TextColor::Hidden)) .left_icon(Icon::Folder.into()) .indent_level(1), - ListEntry::new(".dockerignore", Label::new(".dockerignore")) + ListItem::new(".dockerignore", Label::new(".dockerignore")) .left_icon(Icon::FileGeneric.into()) .indent_level(1), - ListEntry::new( + ListItem::new( ".DS_Store", Label::new(".DS_Store").color(TextColor::Hidden), ) .left_icon(Icon::FileGeneric.into()) .indent_level(1), - ListEntry::new("Cargo.lock", Label::new("Cargo.lock")) + ListItem::new("Cargo.lock", Label::new("Cargo.lock")) .left_icon(Icon::FileLock.into()) .indent_level(1), - ListEntry::new("Cargo.toml", Label::new("Cargo.toml")) + ListItem::new("Cargo.toml", Label::new("Cargo.toml")) .left_icon(Icon::FileToml.into()) .indent_level(1), - ListEntry::new("Dockerfile", Label::new("Dockerfile")) + ListItem::new("Dockerfile", Label::new("Dockerfile")) .left_icon(Icon::FileGeneric.into()) .indent_level(1), - ListEntry::new("Procfile", Label::new("Procfile")) + ListItem::new("Procfile", Label::new("Procfile")) .left_icon(Icon::FileGeneric.into()) .indent_level(1), - ListEntry::new("README.md", Label::new("README.md")) + ListItem::new("README.md", Label::new("README.md")) .left_icon(Icon::FileDoc.into()) .indent_level(1), ] } -pub fn static_project_panel_single_items() -> Vec> { +pub fn static_project_panel_single_items() -> Vec> { vec![ - ListEntry::new("todo.md", Label::new("todo.md")) + ListItem::new("todo.md", Label::new("todo.md")) .left_icon(Icon::FileDoc.into()) .indent_level(0), - ListEntry::new("README.md", Label::new("README.md")) + ListItem::new("README.md", Label::new("README.md")) .left_icon(Icon::FileDoc.into()) .indent_level(0), - ListEntry::new("config.json", Label::new("config.json")) + ListItem::new("config.json", Label::new("config.json")) .left_icon(Icon::FileGeneric.into()) .indent_level(0), ] } -pub fn static_collab_panel_current_call() -> Vec> { +pub fn static_collab_panel_current_call() -> Vec> { vec![ - ListEntry::new("as-cii", Label::new("as-cii")) + ListItem::new("as-cii", Label::new("as-cii")) .left_avatar("http://github.com/as-cii.png?s=50"), - ListEntry::new("nathansobo", Label::new("nathansobo")) + ListItem::new("nathansobo", Label::new("nathansobo")) .left_avatar("http://github.com/nathansobo.png?s=50"), - ListEntry::new("maxbrunsfeld", Label::new("maxbrunsfeld")) + ListItem::new("maxbrunsfeld", Label::new("maxbrunsfeld")) .left_avatar("http://github.com/maxbrunsfeld.png?s=50"), ] } -pub fn static_collab_panel_channels() -> Vec> { +pub fn static_collab_panel_channels() -> Vec> { vec![ - ListEntry::new("zed", Label::new("zed")) + ListItem::new("zed", Label::new("zed")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(0), - ListEntry::new("community", Label::new("community")) + ListItem::new("community", Label::new("community")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(1), - ListEntry::new("dashboards", Label::new("dashboards")) + ListItem::new("dashboards", Label::new("dashboards")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new("feedback", Label::new("feedback")) + ListItem::new("feedback", Label::new("feedback")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new( + ListItem::new( "teams-in-channels-alpha", Label::new("teams-in-channels-alpha"), ) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new("current-projects", Label::new("current-projects")) + ListItem::new("current-projects", Label::new("current-projects")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(1), - ListEntry::new("codegen", Label::new("codegen")) + ListItem::new("codegen", Label::new("codegen")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new("gpui2", Label::new("gpui2")) + ListItem::new("gpui2", Label::new("gpui2")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new("livestreaming", Label::new("livestreaming")) + ListItem::new("livestreaming", Label::new("livestreaming")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new("open-source", Label::new("open-source")) + ListItem::new("open-source", Label::new("open-source")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new("replace", Label::new("replace")) + ListItem::new("replace", Label::new("replace")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new("semantic-index", Label::new("semantic-index")) + ListItem::new("semantic-index", Label::new("semantic-index")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new("vim", Label::new("vim")) + ListItem::new("vim", Label::new("vim")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), - ListEntry::new("web-tech", Label::new("web-tech")) + ListItem::new("web-tech", Label::new("web-tech")) .left_icon(Icon::Hash.into()) .size(ListEntrySize::Medium) .indent_level(2), diff --git a/crates/workspace2/src/dock.rs b/crates/workspace2/src/dock.rs index d41f2b007873253fed21e53401338f59569f58a4..3f056a05bf7ba9dfeb7d3ba804d716ca49e2079d 100644 --- a/crates/workspace2/src/dock.rs +++ b/crates/workspace2/src/dock.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; use std::sync::Arc; use theme2::ActiveTheme; use ui::{ - h_stack, menu_handle, ContextMenu, IconButton, InteractionState, Label, ListEntry, Tooltip, + h_stack, menu_handle, ContextMenu, IconButton, InteractionState, Label, ListItem, Tooltip, }; pub enum PanelEvent { @@ -719,7 +719,7 @@ impl Render for PanelButtons { { let panel = panel.clone(); menu = menu.entry( - ListEntry::new( + ListItem::new( SharedString::from(format!("dock-{position:?}")), Label::new(format!("Dock {}", position.to_label())), ), From 3210d367277c9b6ffae19f31fcb6471e90e9ee0b Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Mon, 20 Nov 2023 16:13:18 -0500 Subject: [PATCH 08/10] Create deploy-docs --- script/deploy-docs | 195 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 script/deploy-docs diff --git a/script/deploy-docs b/script/deploy-docs new file mode 100644 index 0000000000000000000000000000000000000000..0e6fcd6d6f5f9537310f5afe425581814ace007c --- /dev/null +++ b/script/deploy-docs @@ -0,0 +1,195 @@ +#!/bin/bash + +# Set the environment variables +TARGET_DIR="../zed-docs" +PUSH_CHANGES=false +CLEAN_FOLDERS=false + +# Parse command line arguments +while getopts "pc" opt; do + case ${opt} in + p ) + PUSH_CHANGES=true + ;; + c ) + CLEAN_FOLDERS=true + ;; + \? ) + echo "Invalid option: $OPTARG" 1>&2 + exit 1 + ;; + esac +done + +if "$CLEAN_FOLDERS"; then + echo "Cleaning ./doc and ./debug folders..." + rm -rf "$TARGET_DIR/doc" + rm -rf "$TARGET_DIR/debug" +fi + +# Check if the target documentation directory exists +if [ ! -d "$TARGET_DIR" ]; then + # Prompt the user for input + read -p "The zed-docs directory does not exist. Make sure you are running this from the zed repo root." -n 1 -r + read -p "Do you want to clone the repository (y/n)? " -n 1 -r + echo # Move to a new line + + if [[ $REPLY =~ ^[Yy]$ ]]; then + # Clone the repo if the user agrees + git clone https://github.com/zed-industries/zed-docs.git "$TARGET_DIR" + else + # Exit if the user does not agree to clone the repo + echo "Exiting without cloning the repository." + exit 1 + fi +else + # If the directory exists, pull the latest changes + pushd "$TARGET_DIR" > /dev/null + git pull + popd > /dev/null +fi + +# Build the documentation +CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \ +--exclude activity_indicator \ +--exclude ai \ +--exclude ai2 \ +--exclude assistant \ +--exclude audio \ +--exclude audio2 \ +--exclude auto_update \ +--exclude auto_update2 \ +--exclude breadcrumbs \ +--exclude call \ +--exclude call2 \ +--exclude channel \ +--exclude channel2 \ +--exclude cli \ +--exclude client \ +--exclude client2 \ +--exclude clock \ +--exclude collab \ +--exclude collab2 \ +--exclude collab_ui \ +--exclude collab_ui2 \ +--exclude collections \ +--exclude command_palette \ +--exclude command_palette2 \ +--exclude component_test \ +--exclude context_menu \ +--exclude copilot \ +--exclude copilot2 \ +--exclude copilot_button \ +--exclude db \ +--exclude db2 \ +--exclude diagnostics \ +--exclude diagnostics2 \ +--exclude drag_and_drop \ +--exclude editor \ +--exclude feature_flags \ +--exclude feature_flags2 \ +--exclude feedback \ +--exclude file_finder \ +--exclude file_finder2 \ +--exclude fs \ +--exclude fs2 \ +--exclude fsevent \ +--exclude fuzzy \ +--exclude fuzzy2 \ +--exclude git \ +--exclude git3 \ +--exclude go_to_line \ +--exclude go_to_line2 \ +--exclude gpui \ +--exclude gpui_macros \ +--exclude install_cli \ +--exclude install_cli2 \ +--exclude journal \ +--exclude journal2 \ +--exclude language \ +--exclude language2 \ +--exclude language_selector \ +--exclude language_tools \ +--exclude live_kit_client \ +--exclude live_kit_client2 \ +--exclude live_kit_server \ +--exclude lsp \ +--exclude lsp2 \ +--exclude media \ +--exclude menu \ +--exclude menu2 \ +--exclude multi_buffer \ +--exclude multi_buffer2 \ +--exclude node_runtime \ +--exclude notifications \ +--exclude notifications2 \ +--exclude outline \ +--exclude picker \ +--exclude picker2 \ +--exclude plugin \ +--exclude plugin_macros \ +--exclude plugin_runtime \ +--exclude prettier \ +--exclude prettier2 \ +--exclude project \ +--exclude project2 \ +--exclude project_panel \ +--exclude project_panel2 \ +--exclude project_symbols \ +--exclude quick_action_bar \ +--exclude recent_projects \ +--exclude refineable \ +--exclude rich_text \ +--exclude rich_text2 \ +--exclude rope \ +--exclude rope2 \ +--exclude rpc \ +--exclude rpc2 \ +--exclude search \ +--exclude semantic_index \ +--exclude settings \ +--exclude settings2 \ +--exclude snippet \ +--exclude sqlez \ +--exclude sqlez_macros \ +--exclude storybook2 \ +--exclude storybook3 \ +--exclude sum_tree \ +--exclude terminal \ +--exclude terminal2 \ +--exclude terminal_view \ +--exclude terminal_view2 \ +--exclude text \ +--exclude text2 \ +--exclude theme \ +--exclude theme_importer \ +--exclude theme_selector \ +--exclude util \ +--exclude vcs_menu \ +--exclude vim \ +--exclude welcome \ +--exclude workspace2 \ +--exclude xtask \ +--exclude zed \ +--exclude zed-actions \ +--exclude zed_actions2 + +if "$PUSH_CHANGES"; then + # Commit the changes and push + pushd "$TARGET_DIR" > /dev/null + # Check if there are any changes to commit + if git diff --quiet && git diff --staged --quiet; then + echo "No changes to the documentation." + else + # Staging the changes + git add . + + # Creating a commit with the current datetime + DATETIME=$(date +"%Y-%m-%d %H:%M:%S") + git commit -m "Update docs – $DATETIME" + + # Pushing the changes + git push + fi + popd > /dev/null +fi From a87ffa58ff32347aa3831ba4d701c218eccd27c8 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Mon, 20 Nov 2023 17:07:14 -0500 Subject: [PATCH 09/10] Add more crates --- script/deploy-docs | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) mode change 100644 => 100755 script/deploy-docs diff --git a/script/deploy-docs b/script/deploy-docs old mode 100644 new mode 100755 index 0e6fcd6d6f5f9537310f5afe425581814ace007c..ce606e032768185b0f90722a380902f0f6a6cc11 --- a/script/deploy-docs +++ b/script/deploy-docs @@ -53,114 +53,76 @@ fi CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \ --exclude activity_indicator \ --exclude ai \ ---exclude ai2 \ --exclude assistant \ --exclude audio \ ---exclude audio2 \ --exclude auto_update \ ---exclude auto_update2 \ --exclude breadcrumbs \ --exclude call \ ---exclude call2 \ --exclude channel \ ---exclude channel2 \ --exclude cli \ --exclude client \ ---exclude client2 \ --exclude clock \ --exclude collab \ ---exclude collab2 \ --exclude collab_ui \ ---exclude collab_ui2 \ --exclude collections \ --exclude command_palette \ ---exclude command_palette2 \ --exclude component_test \ --exclude context_menu \ --exclude copilot \ ---exclude copilot2 \ --exclude copilot_button \ --exclude db \ ---exclude db2 \ --exclude diagnostics \ ---exclude diagnostics2 \ --exclude drag_and_drop \ --exclude editor \ --exclude feature_flags \ ---exclude feature_flags2 \ --exclude feedback \ --exclude file_finder \ ---exclude file_finder2 \ --exclude fs \ ---exclude fs2 \ --exclude fsevent \ --exclude fuzzy \ ---exclude fuzzy2 \ --exclude git \ ---exclude git3 \ --exclude go_to_line \ ---exclude go_to_line2 \ --exclude gpui \ --exclude gpui_macros \ --exclude install_cli \ ---exclude install_cli2 \ --exclude journal \ ---exclude journal2 \ --exclude language \ ---exclude language2 \ --exclude language_selector \ --exclude language_tools \ --exclude live_kit_client \ ---exclude live_kit_client2 \ --exclude live_kit_server \ --exclude lsp \ ---exclude lsp2 \ --exclude media \ --exclude menu \ ---exclude menu2 \ --exclude multi_buffer \ ---exclude multi_buffer2 \ --exclude node_runtime \ --exclude notifications \ ---exclude notifications2 \ --exclude outline \ --exclude picker \ ---exclude picker2 \ --exclude plugin \ --exclude plugin_macros \ --exclude plugin_runtime \ --exclude prettier \ ---exclude prettier2 \ --exclude project \ ---exclude project2 \ --exclude project_panel \ ---exclude project_panel2 \ --exclude project_symbols \ --exclude quick_action_bar \ --exclude recent_projects \ --exclude refineable \ --exclude rich_text \ ---exclude rich_text2 \ --exclude rope \ ---exclude rope2 \ --exclude rpc \ ---exclude rpc2 \ --exclude search \ --exclude semantic_index \ --exclude settings \ ---exclude settings2 \ --exclude snippet \ --exclude sqlez \ --exclude sqlez_macros \ ---exclude storybook2 \ --exclude storybook3 \ --exclude sum_tree \ --exclude terminal \ ---exclude terminal2 \ --exclude terminal_view \ ---exclude terminal_view2 \ --exclude text \ ---exclude text2 \ --exclude theme \ --exclude theme_importer \ --exclude theme_selector \ @@ -168,11 +130,9 @@ CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \ --exclude vcs_menu \ --exclude vim \ --exclude welcome \ ---exclude workspace2 \ --exclude xtask \ --exclude zed \ ---exclude zed-actions \ ---exclude zed_actions2 +--exclude zed-actions if "$PUSH_CHANGES"; then # Commit the changes and push From a83d62691203f5933d670c19fe78883d87512bd3 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Mon, 20 Nov 2023 17:50:25 -0500 Subject: [PATCH 10/10] Make the script a bit more resilient --- script/deploy-docs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/script/deploy-docs b/script/deploy-docs index ce606e032768185b0f90722a380902f0f6a6cc11..9632215ff4b9caa533e70c985780ae323aff1e53 100755 --- a/script/deploy-docs +++ b/script/deploy-docs @@ -1,5 +1,11 @@ #!/bin/bash +# Check if the script is run from the root of the repository +if [ ! -f "Cargo.toml" ] || [ ! -d "crates/zed" ]; then + echo "Please run the script from the root of the repository." + exit 1 +fi + # Set the environment variables TARGET_DIR="../zed-docs" PUSH_CHANGES=false @@ -21,17 +27,10 @@ while getopts "pc" opt; do esac done -if "$CLEAN_FOLDERS"; then - echo "Cleaning ./doc and ./debug folders..." - rm -rf "$TARGET_DIR/doc" - rm -rf "$TARGET_DIR/debug" -fi - # Check if the target documentation directory exists if [ ! -d "$TARGET_DIR" ]; then # Prompt the user for input - read -p "The zed-docs directory does not exist. Make sure you are running this from the zed repo root." -n 1 -r - read -p "Do you want to clone the repository (y/n)? " -n 1 -r + read -p "Can't find ../zed-docs. Do you want to clone the repository (y/n)?" -n 1 -r echo # Move to a new line if [[ $REPLY =~ ^[Yy]$ ]]; then @@ -49,6 +48,12 @@ else popd > /dev/null fi +if "$CLEAN_FOLDERS"; then + echo "Cleaning ./doc and ./debug folders..." + rm -rf "$TARGET_DIR/doc" + rm -rf "$TARGET_DIR/debug" +fi + # Build the documentation CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \ --exclude activity_indicator \