ssh: Do not require user to be signed in to use ssh remoting (#18396)

Fixes #18392

Closes #18392

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-26 16:24:11 +02:00 committed by GitHub
parent 7eea1a6f51
commit f143396825
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,7 +40,6 @@ use ui::{
}; };
use ui_input::{FieldLabelLayout, TextField}; use ui_input::{FieldLabelLayout, TextField};
use util::ResultExt; use util::ResultExt;
use workspace::notifications::NotifyResultExt;
use workspace::OpenOptions; use workspace::OpenOptions;
use workspace::{notifications::DetachAndPromptErr, AppState, ModalView, Workspace, WORKSPACE_DB}; use workspace::{notifications::DetachAndPromptErr, AppState, ModalView, Workspace, WORKSPACE_DB};
@ -1133,7 +1132,8 @@ impl DevServerProjects {
let dev_server_id = state.dev_server_id; let dev_server_id = state.dev_server_id;
let access_token = state.access_token.clone(); let access_token = state.access_token.clone();
let ssh_prompt = state.ssh_prompt.clone(); let ssh_prompt = state.ssh_prompt.clone();
let use_direct_ssh = SshSettings::get_global(cx).use_direct_ssh(); let use_direct_ssh = SshSettings::get_global(cx).use_direct_ssh()
|| Client::global(cx).status().borrow().is_signed_out();
let mut kind = state.kind; let mut kind = state.kind;
if use_direct_ssh && kind == NewServerKind::LegacySSH { if use_direct_ssh && kind == NewServerKind::LegacySSH {
@ -1407,7 +1407,6 @@ impl DevServerProjects {
is_creating = Some(*creating); is_creating = Some(*creating);
creating_dev_server = Some(*dev_server_id); creating_dev_server = Some(*dev_server_id);
}; };
let is_signed_out = Client::global(cx).status().borrow().is_signed_out();
Modal::new("remote-projects", Some(self.scroll_handle.clone())) Modal::new("remote-projects", Some(self.scroll_handle.clone()))
.header( .header(
@ -1415,82 +1414,58 @@ impl DevServerProjects {
.show_dismiss_button(true) .show_dismiss_button(true)
.child(Headline::new("Remote Projects (alpha)").size(HeadlineSize::Small)), .child(Headline::new("Remote Projects (alpha)").size(HeadlineSize::Small)),
) )
.when(is_signed_out, |modal| { .section(
modal Section::new().child(
.section(Section::new().child(div().child(Label::new( div().child(
"To continue with the remote development features, you need to sign in to Zed.", List::new()
)))) .empty_message("No dev servers registered yet.")
.footer( .header(Some(
ModalFooter::new().end_slot( ListHeader::new("Connections").end_slot(
Button::new("sign_in", "Sign in with GitHub") Button::new("register-dev-server-button", "Connect New Server")
.icon(IconName::Github) .icon(IconName::Plus)
.icon_position(IconPosition::Start) .icon_position(IconPosition::Start)
.full_width() .icon_color(Color::Muted)
.on_click(cx.listener(|_, _, cx| { .on_click(cx.listener(|this, _, cx| {
let client = Client::global(cx).clone(); this.mode = Mode::CreateDevServer(CreateDevServer {
cx.spawn(|_, mut cx| async move { kind: if SshSettings::get_global(cx)
client .use_direct_ssh()
.authenticate_and_connect(true, &cx) {
.await NewServerKind::DirectSSH
.notify_async_err(&mut cx); } else {
}) NewServerKind::LegacySSH
.detach(); },
cx.emit(gpui::DismissEvent); ..Default::default()
})), });
), this.dev_server_name_input.update(
) cx,
}) |text_field, cx| {
.when(!is_signed_out, |modal| { text_field.editor().update(cx, |editor, cx| {
modal.section( editor.set_text("", cx);
Section::new().child( });
div().child( },
List::new() );
.empty_message("No dev servers registered yet.") cx.notify();
.header(Some( })),
ListHeader::new("Connections").end_slot( ),
Button::new("register-dev-server-button", "Connect New Server") ))
.icon(IconName::Plus) .children(ssh_connections.iter().cloned().enumerate().map(
.icon_position(IconPosition::Start) |(ix, connection)| {
.icon_color(Color::Muted)
.on_click(cx.listener(|this, _, cx| {
this.mode = Mode::CreateDevServer(
CreateDevServer {
kind: if SshSettings::get_global(cx).use_direct_ssh() { NewServerKind::DirectSSH } else { NewServerKind::LegacySSH },
..Default::default()
}
);
this.dev_server_name_input.update(
cx,
|text_field, cx| {
text_field.editor().update(
cx,
|editor, cx| {
editor.set_text("", cx);
},
);
},
);
cx.notify();
})),
),
))
.children(ssh_connections.iter().cloned().enumerate().map(|(ix, connection)| {
self.render_ssh_connection(ix, connection, cx) self.render_ssh_connection(ix, connection, cx)
.into_any_element() .into_any_element()
})) },
.children(dev_servers.iter().map(|dev_server| { ))
let creating = if creating_dev_server == Some(dev_server.id) { .children(dev_servers.iter().map(|dev_server| {
is_creating let creating = if creating_dev_server == Some(dev_server.id) {
} else { is_creating
None } else {
}; None
self.render_dev_server(dev_server, creating, cx) };
.into_any_element() self.render_dev_server(dev_server, creating, cx)
})), .into_any_element()
), })),
), ),
) ),
}) )
} }
} }