commit
7b291df21f
10 changed files with 73 additions and 11 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1252,6 +1252,7 @@ name = "collab_ui"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"auto_update",
|
||||||
"call",
|
"call",
|
||||||
"client",
|
"client",
|
||||||
"clock",
|
"clock",
|
||||||
|
|
|
@ -252,7 +252,11 @@ impl ActivityIndicator {
|
||||||
"Installing Zed update…".to_string(),
|
"Installing Zed update…".to_string(),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
AutoUpdateStatus::Updated => (None, "Restart to update Zed".to_string(), None),
|
AutoUpdateStatus::Updated => (
|
||||||
|
None,
|
||||||
|
"Click to restart and update Zed".to_string(),
|
||||||
|
Some(Box::new(workspace::Restart)),
|
||||||
|
),
|
||||||
AutoUpdateStatus::Errored => (
|
AutoUpdateStatus::Errored => (
|
||||||
Some(WARNING_ICON),
|
Some(WARNING_ICON),
|
||||||
"Auto update failed".to_string(),
|
"Auto update failed".to_string(),
|
||||||
|
|
|
@ -22,6 +22,7 @@ test-support = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
auto_update = { path = "../auto_update" }
|
||||||
call = { path = "../call" }
|
call = { path = "../call" }
|
||||||
client = { path = "../client" }
|
client = { path = "../client" }
|
||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
|
|
|
@ -504,7 +504,9 @@ impl CollabTitlebarItem {
|
||||||
workspace: &ViewHandle<Workspace>,
|
workspace: &ViewHandle<Workspace>,
|
||||||
cx: &mut RenderContext<Self>,
|
cx: &mut RenderContext<Self>,
|
||||||
) -> Option<ElementBox> {
|
) -> Option<ElementBox> {
|
||||||
let theme = &cx.global::<Settings>().theme;
|
enum ConnectionStatusButton {}
|
||||||
|
|
||||||
|
let theme = &cx.global::<Settings>().theme.clone();
|
||||||
match &*workspace.read(cx).client().status().borrow() {
|
match &*workspace.read(cx).client().status().borrow() {
|
||||||
client::Status::ConnectionError
|
client::Status::ConnectionError
|
||||||
| client::Status::ConnectionLost
|
| client::Status::ConnectionLost
|
||||||
|
@ -527,6 +529,7 @@ impl CollabTitlebarItem {
|
||||||
.boxed(),
|
.boxed(),
|
||||||
),
|
),
|
||||||
client::Status::UpgradeRequired => Some(
|
client::Status::UpgradeRequired => Some(
|
||||||
|
MouseEventHandler::<ConnectionStatusButton>::new(0, cx, |_, _| {
|
||||||
Label::new(
|
Label::new(
|
||||||
"Please update Zed to collaborate".to_string(),
|
"Please update Zed to collaborate".to_string(),
|
||||||
theme.workspace.titlebar.outdated_warning.text.clone(),
|
theme.workspace.titlebar.outdated_warning.text.clone(),
|
||||||
|
@ -534,6 +537,12 @@ impl CollabTitlebarItem {
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(theme.workspace.titlebar.outdated_warning.container)
|
.with_style(theme.workspace.titlebar.outdated_warning.container)
|
||||||
.aligned()
|
.aligned()
|
||||||
|
.boxed()
|
||||||
|
})
|
||||||
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
|
.on_click(MouseButton::Left, |_, cx| {
|
||||||
|
cx.dispatch_action(auto_update::Check);
|
||||||
|
})
|
||||||
.boxed(),
|
.boxed(),
|
||||||
),
|
),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
@ -81,6 +81,7 @@ pub trait Platform: Send + Sync {
|
||||||
fn app_version(&self) -> Result<AppVersion>;
|
fn app_version(&self) -> Result<AppVersion>;
|
||||||
fn os_name(&self) -> &'static str;
|
fn os_name(&self) -> &'static str;
|
||||||
fn os_version(&self) -> Result<AppVersion>;
|
fn os_version(&self) -> Result<AppVersion>;
|
||||||
|
fn restart(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait ForegroundPlatform {
|
pub(crate) trait ForegroundPlatform {
|
||||||
|
|
|
@ -45,6 +45,7 @@ use std::{
|
||||||
ffi::{c_void, CStr, OsStr},
|
ffi::{c_void, CStr, OsStr},
|
||||||
os::{raw::c_char, unix::ffi::OsStrExt},
|
os::{raw::c_char, unix::ffi::OsStrExt},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
process::Command,
|
||||||
ptr,
|
ptr,
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
slice, str,
|
slice, str,
|
||||||
|
@ -803,6 +804,33 @@ impl platform::Platform for MacPlatform {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn restart(&self) {
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
let path = std::env::current_exe();
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
let path = unsafe {
|
||||||
|
let bundle: id = NSBundle::mainBundle();
|
||||||
|
if bundle.is_null() {
|
||||||
|
std::env::current_exe()
|
||||||
|
} else {
|
||||||
|
let path: id = msg_send![bundle, bundlePath];
|
||||||
|
let path: *mut c_char = msg_send![path, UTF8String];
|
||||||
|
|
||||||
|
Ok(PathBuf::from(OsStr::from_bytes(
|
||||||
|
CStr::from_ptr(path).to_bytes(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let command = path.and_then(|path| Command::new("/usr/bin/open").arg(path).spawn());
|
||||||
|
|
||||||
|
match command {
|
||||||
|
Err(err) => log::error!("Unable to restart application {}", err),
|
||||||
|
Ok(_) => self.quit(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn path_from_objc(path: id) -> PathBuf {
|
unsafe fn path_from_objc(path: id) -> PathBuf {
|
||||||
|
|
|
@ -226,6 +226,8 @@ impl super::Platform for Platform {
|
||||||
patch: 0,
|
patch: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn restart(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -101,6 +101,7 @@ actions!(
|
||||||
NewTerminal,
|
NewTerminal,
|
||||||
NewSearch,
|
NewSearch,
|
||||||
Feedback,
|
Feedback,
|
||||||
|
Restart
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,9 @@ use terminal_view::{get_working_directory, TerminalView};
|
||||||
use fs::RealFs;
|
use fs::RealFs;
|
||||||
use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJsonFile};
|
use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJsonFile};
|
||||||
use theme::ThemeRegistry;
|
use theme::ThemeRegistry;
|
||||||
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, StaffMode, TryFutureExt};
|
#[cfg(debug_assertions)]
|
||||||
|
use util::StaffMode;
|
||||||
|
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
self, item::ItemHandle, notifications::NotifyResultExt, AppState, NewFile, OpenPaths, Workspace,
|
self, item::ItemHandle, notifications::NotifyResultExt, AppState, NewFile, OpenPaths, Workspace,
|
||||||
};
|
};
|
||||||
|
@ -567,6 +569,14 @@ async fn handle_cli_connection(
|
||||||
if let Some(request) = requests.next().await {
|
if let Some(request) = requests.next().await {
|
||||||
match request {
|
match request {
|
||||||
CliRequest::Open { paths, wait } => {
|
CliRequest::Open { paths, wait } => {
|
||||||
|
let paths = if paths.is_empty() {
|
||||||
|
workspace::last_opened_workspace_paths()
|
||||||
|
.await
|
||||||
|
.map(|location| location.paths().to_vec())
|
||||||
|
.unwrap_or(paths)
|
||||||
|
} else {
|
||||||
|
paths
|
||||||
|
};
|
||||||
let (workspace, items) = cx
|
let (workspace, items) = cx
|
||||||
.update(|cx| workspace::open_paths(&paths, &app_state, cx))
|
.update(|cx| workspace::open_paths(&paths, &app_state, cx))
|
||||||
.await;
|
.await;
|
||||||
|
|
|
@ -38,7 +38,7 @@ use std::{borrow::Cow, env, path::Path, str, sync::Arc};
|
||||||
use util::{channel::ReleaseChannel, paths, ResultExt, StaffMode};
|
use util::{channel::ReleaseChannel, paths, ResultExt, StaffMode};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
pub use workspace;
|
pub use workspace;
|
||||||
use workspace::{sidebar::SidebarSide, AppState, Workspace};
|
use workspace::{sidebar::SidebarSide, AppState, Restart, Workspace};
|
||||||
|
|
||||||
#[derive(Deserialize, Clone, PartialEq)]
|
#[derive(Deserialize, Clone, PartialEq)]
|
||||||
pub struct OpenBrowser {
|
pub struct OpenBrowser {
|
||||||
|
@ -130,6 +130,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
cx.add_global_action(quit);
|
cx.add_global_action(quit);
|
||||||
|
cx.add_global_action(restart);
|
||||||
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
|
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
|
||||||
cx.add_global_action(move |_: &IncreaseBufferFontSize, cx| {
|
cx.add_global_action(move |_: &IncreaseBufferFontSize, cx| {
|
||||||
cx.update_global::<Settings, _, _>(|settings, cx| {
|
cx.update_global::<Settings, _, _>(|settings, cx| {
|
||||||
|
@ -403,6 +404,10 @@ pub fn build_window_options(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn restart(_: &Restart, cx: &mut gpui::MutableAppContext) {
|
||||||
|
cx.platform().restart();
|
||||||
|
}
|
||||||
|
|
||||||
fn quit(_: &Quit, cx: &mut gpui::MutableAppContext) {
|
fn quit(_: &Quit, cx: &mut gpui::MutableAppContext) {
|
||||||
let mut workspaces = cx
|
let mut workspaces = cx
|
||||||
.window_ids()
|
.window_ids()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue