title_bar: Remove dependency on recent_projects (#20942)

Use actions defined in zed_actions to interface with that crate instead.
One drawback of this is that we now hide call controls when any modal is
visible (we used to hide them just when ssh modal was deployed).

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-11-21 00:43:03 +01:00 committed by GitHub
parent 33bed8d680
commit 335b112abd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 22 additions and 30 deletions

2
Cargo.lock generated
View file

@ -9684,6 +9684,7 @@ dependencies = [
"ui", "ui",
"util", "util",
"workspace", "workspace",
"zed_actions",
] ]
[[package]] [[package]]
@ -12594,7 +12595,6 @@ dependencies = [
"notifications", "notifications",
"pretty_assertions", "pretty_assertions",
"project", "project",
"recent_projects",
"remote", "remote",
"rpc", "rpc",
"serde", "serde",

View file

@ -40,6 +40,7 @@ ui.workspace = true
util.workspace = true util.workspace = true
workspace.workspace = true workspace.workspace = true
paths.workspace = true paths.workspace = true
zed_actions.workspace = true
[dev-dependencies] [dev-dependencies]
editor = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] }

View file

@ -16,7 +16,6 @@ use picker::{
Picker, PickerDelegate, Picker, PickerDelegate,
}; };
pub use remote_servers::RemoteServerProjects; pub use remote_servers::RemoteServerProjects;
use serde::Deserialize;
use settings::Settings; use settings::Settings;
pub use ssh_connections::SshSettings; pub use ssh_connections::SshSettings;
use std::{ use std::{
@ -29,19 +28,7 @@ use workspace::{
CloseIntent, ModalView, OpenOptions, SerializedWorkspaceLocation, Workspace, WorkspaceId, CloseIntent, ModalView, OpenOptions, SerializedWorkspaceLocation, Workspace, WorkspaceId,
WORKSPACE_DB, WORKSPACE_DB,
}; };
use zed_actions::{OpenRecent, OpenRemote};
#[derive(PartialEq, Clone, Deserialize, Default)]
pub struct OpenRecent {
#[serde(default = "default_create_new_window")]
pub create_new_window: bool,
}
fn default_create_new_window() -> bool {
false
}
gpui::impl_actions!(projects, [OpenRecent]);
gpui::actions!(projects, [OpenRemote]);
pub fn init(cx: &mut AppContext) { pub fn init(cx: &mut AppContext) {
SshSettings::register(cx); SshSettings::register(cx);

View file

@ -37,7 +37,6 @@ feature_flags.workspace = true
gpui.workspace = true gpui.workspace = true
notifications.workspace = true notifications.workspace = true
project.workspace = true project.workspace = true
recent_projects.workspace = true
remote.workspace = true remote.workspace = true
rpc.workspace = true rpc.workspace = true
serde.workspace = true serde.workspace = true

View file

@ -100,7 +100,7 @@ impl Render for ApplicationMenu {
.action("Open a new Project...", Box::new(workspace::Open)) .action("Open a new Project...", Box::new(workspace::Open))
.action( .action(
"Open Recent Projects...", "Open Recent Projects...",
Box::new(recent_projects::OpenRecent { Box::new(zed_actions::OpenRecent {
create_new_window: false, create_new_window: false,
}), }),
) )

View file

@ -284,9 +284,7 @@ impl TitleBar {
let is_connecting_to_project = self let is_connecting_to_project = self
.workspace .workspace
.update(cx, |workspace, cx| { .update(cx, |workspace, cx| workspace.has_active_modal(cx))
recent_projects::is_connecting_over_ssh(workspace, cx)
})
.unwrap_or(false); .unwrap_or(false);
let room = room.read(cx); let room = room.read(cx);

View file

@ -18,7 +18,6 @@ use gpui::{
StatefulInteractiveElement, Styled, Subscription, View, ViewContext, VisualContext, WeakView, StatefulInteractiveElement, Styled, Subscription, View, ViewContext, VisualContext, WeakView,
}; };
use project::{Project, RepositoryEntry}; use project::{Project, RepositoryEntry};
use recent_projects::{OpenRemote, RecentProjects};
use rpc::proto; use rpc::proto;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::sync::Arc; use std::sync::Arc;
@ -30,7 +29,7 @@ use ui::{
use util::ResultExt; use util::ResultExt;
use vcs_menu::{BranchList, OpenRecent as ToggleVcsMenu}; use vcs_menu::{BranchList, OpenRecent as ToggleVcsMenu};
use workspace::{notifications::NotifyResultExt, Workspace}; use workspace::{notifications::NotifyResultExt, Workspace};
use zed_actions::OpenBrowser; use zed_actions::{OpenBrowser, OpenRecent, OpenRemote};
#[cfg(feature = "stories")] #[cfg(feature = "stories")]
pub use stories::*; pub use stories::*;
@ -397,7 +396,6 @@ impl TitleBar {
"Open recent project".to_string() "Open recent project".to_string()
}; };
let workspace = self.workspace.clone();
Button::new("project_name_trigger", name) Button::new("project_name_trigger", name)
.when(!is_project_selected, |b| b.color(Color::Muted)) .when(!is_project_selected, |b| b.color(Color::Muted))
.style(ButtonStyle::Subtle) .style(ButtonStyle::Subtle)
@ -405,18 +403,19 @@ impl TitleBar {
.tooltip(move |cx| { .tooltip(move |cx| {
Tooltip::for_action( Tooltip::for_action(
"Recent Projects", "Recent Projects",
&recent_projects::OpenRecent { &zed_actions::OpenRecent {
create_new_window: false, create_new_window: false,
}, },
cx, cx,
) )
}) })
.on_click(cx.listener(move |_, _, cx| { .on_click(cx.listener(move |_, _, cx| {
if let Some(workspace) = workspace.upgrade() { cx.dispatch_action(
workspace.update(cx, |workspace, cx| { OpenRecent {
RecentProjects::open(workspace, false, cx); create_new_window: false,
}) }
} .boxed_clone(),
);
})) }))
} }

View file

@ -50,7 +50,7 @@ pub fn app_menus() -> Vec<Menu> {
MenuItem::action("Open…", workspace::Open), MenuItem::action("Open…", workspace::Open),
MenuItem::action( MenuItem::action(
"Open Recent...", "Open Recent...",
recent_projects::OpenRecent { zed_actions::OpenRecent {
create_new_window: true, create_new_window: true,
}, },
), ),

View file

@ -50,3 +50,11 @@ pub struct InlineAssist {
} }
impl_actions!(assistant, [InlineAssist]); impl_actions!(assistant, [InlineAssist]);
#[derive(PartialEq, Clone, Deserialize, Default)]
pub struct OpenRecent {
#[serde(default)]
pub create_new_window: bool,
}
gpui::impl_actions!(projects, [OpenRecent]);
gpui::actions!(projects, [OpenRemote]);