ssh remote: Handle disconnect on project and show overlay (#19014)

Demo:



https://github.com/user-attachments/assets/e5edf8f3-8c15-482e-a792-6eb619f83de4


Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
Thorsten Ball 2024-10-10 12:59:09 +02:00 committed by GitHub
parent e3ff2ced79
commit b75532fad7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 264 additions and 78 deletions

View file

@ -344,16 +344,17 @@ impl ProjectPanel {
let worktree_id = worktree.read(cx).id();
let entry_id = entry.id;
project_panel.update(cx, |this, _| {
if !mark_selected {
this.marked_entries.clear();
}
this.marked_entries.insert(SelectedEntry {
worktree_id,
entry_id
});
}).ok();
project_panel.update(cx, |this, _| {
if !mark_selected {
this.marked_entries.clear();
}
this.marked_entries.insert(SelectedEntry {
worktree_id,
entry_id
});
}).ok();
let is_via_ssh = project.read(cx).is_via_ssh();
workspace
.open_path_preview(
@ -368,7 +369,11 @@ impl ProjectPanel {
)
.detach_and_prompt_err("Failed to open file", cx, move |e, _| {
match e.error_code() {
ErrorCode::Disconnected => Some("Disconnected from remote project".to_string()),
ErrorCode::Disconnected => if is_via_ssh {
Some("Disconnected from SSH host".to_string())
} else {
Some("Disconnected from remote project".to_string())
},
ErrorCode::UnsharedItem => Some(format!(
"{} is not shared by the host. This could be because it has been marked as `private`",
file_path.display()
@ -493,7 +498,7 @@ impl ProjectPanel {
let is_foldable = auto_fold_dirs && self.is_foldable(entry, worktree);
let is_unfoldable = auto_fold_dirs && self.is_unfoldable(entry, worktree);
let worktree_id = worktree.id();
let is_read_only = project.is_read_only();
let is_read_only = project.is_read_only(cx);
let is_remote = project.is_via_collab() && project.dev_server_project_id().is_none();
let is_local = project.is_local();
@ -2901,7 +2906,7 @@ impl Render for ProjectPanel {
.on_action(cx.listener(Self::new_search_in_directory))
.on_action(cx.listener(Self::unfold_directory))
.on_action(cx.listener(Self::fold_directory))
.when(!project.is_read_only(), |el| {
.when(!project.is_read_only(cx), |el| {
el.on_action(cx.listener(Self::new_file))
.on_action(cx.listener(Self::new_directory))
.on_action(cx.listener(Self::rename))