ssh: Clean up bits of the main modal UI (#19604)

This PR main relevant change is removing the logic we had inserted for
keyboard nav scroll as that was unreliable; we need to figure out a
better solution still. I'm also removing the visible on hover behavior
for the scrollbar as that was making us lose the click and drag feature
the component has. Lastly, I added a bit of right-margin in the delete
icon button so that's not too crammed with the scrollbar.

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2024-10-23 09:49:44 -03:00 committed by GitHub
parent 1bded42b2a
commit 1cb9f64917
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 25 deletions

View file

@ -373,24 +373,12 @@ impl RemoteServerProjects {
} }
} }
fn scroll_to_selected(&self, _: &mut ViewContext<Self>) {
if let Mode::Default(scroll_state) = &self.mode {
if let ui::ScrollableHandle::NonUniform(scroll_handle) = scroll_state.scroll_handle() {
if let Some(active_item) = self.selectable_items.active_item {
scroll_handle.scroll_to_item(active_item);
}
}
}
}
fn next_item(&mut self, _: &menu::SelectNext, cx: &mut ViewContext<Self>) { fn next_item(&mut self, _: &menu::SelectNext, cx: &mut ViewContext<Self>) {
if !matches!(self.mode, Mode::Default(_) | Mode::ViewServerOptions(_, _)) { if !matches!(self.mode, Mode::Default(_) | Mode::ViewServerOptions(_, _)) {
return; return;
} }
self.selectable_items.next(cx); self.selectable_items.next(cx);
cx.notify();
self.scroll_to_selected(cx);
} }
fn prev_item(&mut self, _: &menu::SelectPrev, cx: &mut ViewContext<Self>) { fn prev_item(&mut self, _: &menu::SelectPrev, cx: &mut ViewContext<Self>) {
@ -398,8 +386,6 @@ impl RemoteServerProjects {
return; return;
} }
self.selectable_items.prev(cx); self.selectable_items.prev(cx);
cx.notify();
self.scroll_to_selected(cx);
} }
pub fn project_picker( pub fn project_picker(
@ -818,14 +804,19 @@ impl RemoteServerProjects {
.child(Label::new(project.paths.join(", "))) .child(Label::new(project.paths.join(", ")))
.on_click(cx.listener(move |this, _, cx| callback(this, cx))) .on_click(cx.listener(move |this, _, cx| callback(this, cx)))
.end_hover_slot::<AnyElement>(Some( .end_hover_slot::<AnyElement>(Some(
IconButton::new("remove-remote-project", IconName::TrashAlt) div()
.icon_size(IconSize::Small) .mr_2()
.shape(IconButtonShape::Square) .child(
.on_click( // Right-margin to offset it from the Scrollbar
cx.listener(move |this, _, cx| this.delete_ssh_project(server_ix, ix, cx)), IconButton::new("remove-remote-project", IconName::TrashAlt)
.icon_size(IconSize::Small)
.shape(IconButtonShape::Square)
.size(ButtonSize::Large)
.tooltip(|cx| Tooltip::text("Delete Remote Project", cx))
.on_click(cx.listener(move |this, _, cx| {
this.delete_ssh_project(server_ix, ix, cx)
})),
) )
.size(ButtonSize::Large)
.tooltip(|cx| Tooltip::text("Delete Remote Project", cx))
.into_any_element(), .into_any_element(),
)) ))
} }
@ -1217,7 +1208,6 @@ impl RemoteServerProjects {
List::new() List::new()
.empty_message( .empty_message(
v_flex() v_flex()
// .child(ListSeparator)
.child(div().px_3().child( .child(div().px_3().child(
Label::new("No remote servers registered yet.").color(Color::Muted), Label::new("No remote servers registered yet.").color(Color::Muted),
)) ))
@ -1241,7 +1231,6 @@ impl RemoteServerProjects {
Section::new().padded(false).child( Section::new().padded(false).child(
v_flex() v_flex()
.min_h(rems(20.)) .min_h(rems(20.))
.group("remote-projects-section")
.size_full() .size_full()
.relative() .relative()
.child(ListSeparator) .child(ListSeparator)
@ -1263,7 +1252,6 @@ impl RemoteServerProjects {
) )
.child( .child(
div() div()
.visible_on_hover("remote-projects-section")
.occlude() .occlude()
.h_full() .h_full()
.absolute() .absolute()

View file

@ -1397,7 +1397,7 @@ impl SshRemoteConnection {
check_interval check_interval
); );
delegate.set_status( delegate.set_status(
Some("Waiting for another Zed instance to finish uploading binary..."), Some("Waiting for another Zed instance to finish uploading binary"),
cx, cx,
); );
smol::Timer::after(check_interval).await; smol::Timer::after(check_interval).await;