ssh: Improve dismissal behaviour (#18900)
Do not always close current window in SshConnectionModal; only do so when the window was spawned from ssh modal. Assign unique IDs to "Open folder" buttons Closes #ISSUE Release Notes: - N/A
This commit is contained in:
parent
9c54bd1bd4
commit
f50bca7630
4 changed files with 33 additions and 17 deletions
|
@ -319,7 +319,9 @@ impl DevServerProjects {
|
||||||
let connection_options = ssh_connection.into();
|
let connection_options = ssh_connection.into();
|
||||||
workspace.update(cx, |_, cx| {
|
workspace.update(cx, |_, cx| {
|
||||||
cx.defer(move |workspace, cx| {
|
cx.defer(move |workspace, cx| {
|
||||||
workspace.toggle_modal(cx, |cx| SshConnectionModal::new(&connection_options, cx));
|
workspace.toggle_modal(cx, |cx| {
|
||||||
|
SshConnectionModal::new(&connection_options, false, cx)
|
||||||
|
});
|
||||||
let prompt = workspace
|
let prompt = workspace
|
||||||
.active_modal::<SshConnectionModal>(cx)
|
.active_modal::<SshConnectionModal>(cx)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -573,7 +575,7 @@ impl DevServerProjects {
|
||||||
}))
|
}))
|
||||||
.child(
|
.child(
|
||||||
h_flex().mt_1().pl_1().child(
|
h_flex().mt_1().pl_1().child(
|
||||||
Button::new("new-remote_project", "Open Folder…")
|
Button::new(("new-remote_project", ix), "Open Folder…")
|
||||||
.size(ButtonSize::Default)
|
.size(ButtonSize::Default)
|
||||||
.layer(ElevationIndex::ModalSurface)
|
.layer(ElevationIndex::ModalSurface)
|
||||||
.icon(IconName::Plus)
|
.icon(IconName::Plus)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
mod dev_servers;
|
mod dev_servers;
|
||||||
pub mod disconnected_overlay;
|
pub mod disconnected_overlay;
|
||||||
mod ssh_connections;
|
mod ssh_connections;
|
||||||
mod ssh_remotes;
|
|
||||||
use remote::SshConnectionOptions;
|
use remote::SshConnectionOptions;
|
||||||
pub use ssh_connections::open_ssh_project;
|
pub use ssh_connections::open_ssh_project;
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ use auto_update::AutoUpdater;
|
||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
use futures::channel::oneshot;
|
use futures::channel::oneshot;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
percentage, px, Action, Animation, AnimationExt, AnyWindowHandle, AsyncAppContext,
|
percentage, px, Animation, AnimationExt, AnyWindowHandle, AsyncAppContext, DismissEvent,
|
||||||
DismissEvent, EventEmitter, FocusableView, ParentElement as _, Render, SemanticVersion,
|
EventEmitter, FocusableView, ParentElement as _, Render, SemanticVersion, SharedString, Task,
|
||||||
SharedString, Task, Transformation, View,
|
Transformation, View,
|
||||||
};
|
};
|
||||||
use gpui::{AppContext, Model};
|
use gpui::{AppContext, Model};
|
||||||
use release_channel::{AppVersion, ReleaseChannel};
|
use release_channel::{AppVersion, ReleaseChannel};
|
||||||
|
@ -83,6 +83,7 @@ pub struct SshPrompt {
|
||||||
|
|
||||||
pub struct SshConnectionModal {
|
pub struct SshConnectionModal {
|
||||||
pub(crate) prompt: View<SshPrompt>,
|
pub(crate) prompt: View<SshPrompt>,
|
||||||
|
is_separate_window: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SshPrompt {
|
impl SshPrompt {
|
||||||
|
@ -207,9 +208,14 @@ impl Render for SshPrompt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SshConnectionModal {
|
impl SshConnectionModal {
|
||||||
pub fn new(connection_options: &SshConnectionOptions, cx: &mut ViewContext<Self>) -> Self {
|
pub fn new(
|
||||||
|
connection_options: &SshConnectionOptions,
|
||||||
|
is_separate_window: bool,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
prompt: cx.new_view(|cx| SshPrompt::new(connection_options, cx)),
|
prompt: cx.new_view(|cx| SshPrompt::new(connection_options, cx)),
|
||||||
|
is_separate_window,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +224,10 @@ impl SshConnectionModal {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dismiss(&mut self, _: &menu::Cancel, cx: &mut ViewContext<Self>) {
|
fn dismiss(&mut self, _: &menu::Cancel, cx: &mut ViewContext<Self>) {
|
||||||
cx.remove_window();
|
cx.emit(DismissEvent);
|
||||||
|
if self.is_separate_window {
|
||||||
|
cx.remove_window();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,6 +241,7 @@ impl Render for SshConnectionModal {
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.elevation_3(cx)
|
.elevation_3(cx)
|
||||||
|
.track_focus(&self.focus_handle(cx))
|
||||||
.on_action(cx.listener(Self::dismiss))
|
.on_action(cx.listener(Self::dismiss))
|
||||||
.on_action(cx.listener(Self::confirm))
|
.on_action(cx.listener(Self::confirm))
|
||||||
.w(px(500.))
|
.w(px(500.))
|
||||||
|
@ -250,7 +260,9 @@ impl Render for SshConnectionModal {
|
||||||
div().absolute().left_0p5().top_0p5().child(
|
div().absolute().left_0p5().top_0p5().child(
|
||||||
IconButton::new("ssh-connection-cancel", IconName::ArrowLeft)
|
IconButton::new("ssh-connection-cancel", IconName::ArrowLeft)
|
||||||
.icon_size(IconSize::XSmall)
|
.icon_size(IconSize::XSmall)
|
||||||
.on_click(|_, cx| cx.dispatch_action(menu::Cancel.boxed_clone()))
|
.on_click(cx.listener(move |this, _, cx| {
|
||||||
|
this.dismiss(&Default::default(), cx);
|
||||||
|
}))
|
||||||
.tooltip(|cx| Tooltip::for_action("Back", &menu::Cancel, cx)),
|
.tooltip(|cx| Tooltip::for_action("Back", &menu::Cancel, cx)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -464,11 +476,10 @@ pub async fn open_ssh_project(
|
||||||
open_options: workspace::OpenOptions,
|
open_options: workspace::OpenOptions,
|
||||||
cx: &mut AsyncAppContext,
|
cx: &mut AsyncAppContext,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let options = cx.update(|cx| (app_state.build_window_options)(None, cx))?;
|
|
||||||
|
|
||||||
let window = if let Some(window) = open_options.replace_window {
|
let window = if let Some(window) = open_options.replace_window {
|
||||||
window
|
window
|
||||||
} else {
|
} else {
|
||||||
|
let options = cx.update(|cx| (app_state.build_window_options)(None, cx))?;
|
||||||
cx.open_window(options, |cx| {
|
cx.open_window(options, |cx| {
|
||||||
let project = project::Project::local(
|
let project = project::Project::local(
|
||||||
app_state.client.clone(),
|
app_state.client.clone(),
|
||||||
|
@ -485,7 +496,9 @@ pub async fn open_ssh_project(
|
||||||
|
|
||||||
let delegate = window.update(cx, |workspace, cx| {
|
let delegate = window.update(cx, |workspace, cx| {
|
||||||
cx.activate_window();
|
cx.activate_window();
|
||||||
workspace.toggle_modal(cx, |cx| SshConnectionModal::new(&connection_options, cx));
|
workspace.toggle_modal(cx, |cx| {
|
||||||
|
SshConnectionModal::new(&connection_options, true, cx)
|
||||||
|
});
|
||||||
let ui = workspace
|
let ui = workspace
|
||||||
.active_modal::<SshConnectionModal>(cx)
|
.active_modal::<SshConnectionModal>(cx)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -500,8 +513,11 @@ pub async fn open_ssh_project(
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
cx.update(|cx| {
|
let did_open_ssh_project = cx
|
||||||
workspace::open_ssh_project(window, connection_options, delegate, app_state, paths, cx)
|
.update(|cx| {
|
||||||
})?
|
workspace::open_ssh_project(window, connection_options, delegate, app_state, paths, cx)
|
||||||
.await
|
})?
|
||||||
|
.await;
|
||||||
|
|
||||||
|
did_open_ssh_project
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue