Add paths to connection headers (#19579)

Closes #ISSUE

<img width="562" alt="Screenshot 2024-10-22 at 3 21 22 PM"
src="https://github.com/user-attachments/assets/51afd8e8-b635-4d69-9463-2ccdaabeb955">

<img width="844" alt="Screenshot 2024-10-22 at 3 22 35 PM"
src="https://github.com/user-attachments/assets/ae57c0f8-396c-485d-b5e2-14558da98a18">

Release Notes:

- N/A

---------

Co-authored-by: Trace <violet.white.batt@gmail.com>
This commit is contained in:
Mikayla Maki 2024-10-22 16:50:33 -07:00 committed by GitHub
parent fc7874e64e
commit 48674ec54c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 3 deletions

View file

@ -312,6 +312,7 @@ impl gpui::Render for ProjectPicker {
.child(
SshConnectionHeader {
connection_string: self.connection_string.clone(),
paths: Default::default(),
nickname: self.nickname.clone(),
}
.render(cx),
@ -519,7 +520,7 @@ impl RemoteServerProjects {
workspace.update(cx, |_, cx| {
cx.defer(move |workspace, cx| {
workspace.toggle_modal(cx, |cx| {
SshConnectionModal::new(&connection_options, nickname, cx)
SshConnectionModal::new(&connection_options, Vec::new(), nickname, cx)
});
let prompt = workspace
.active_modal::<SshConnectionModal>(cx)
@ -965,6 +966,7 @@ impl RemoteServerProjects {
.child(
SshConnectionHeader {
connection_string: connection_string.clone(),
paths: Default::default(),
nickname: connection.nickname.clone(),
}
.render(cx),
@ -1152,6 +1154,7 @@ impl RemoteServerProjects {
.child(
SshConnectionHeader {
connection_string,
paths: Default::default(),
nickname: connection.nickname.clone(),
}
.render(cx),

View file

@ -130,6 +130,7 @@ pub struct SshPrompt {
pub struct SshConnectionModal {
pub(crate) prompt: View<SshPrompt>,
paths: Vec<PathBuf>,
finished: bool,
}
@ -140,6 +141,7 @@ impl SshPrompt {
cx: &mut ViewContext<Self>,
) -> Self {
let connection_string = connection_options.connection_string().into();
Self {
connection_string,
nickname,
@ -257,12 +259,14 @@ impl Render for SshPrompt {
impl SshConnectionModal {
pub(crate) fn new(
connection_options: &SshConnectionOptions,
paths: Vec<PathBuf>,
nickname: Option<SharedString>,
cx: &mut ViewContext<Self>,
) -> Self {
Self {
prompt: cx.new_view(|cx| SshPrompt::new(connection_options, nickname, cx)),
finished: false,
paths,
}
}
@ -288,6 +292,7 @@ impl SshConnectionModal {
pub(crate) struct SshConnectionHeader {
pub(crate) connection_string: SharedString,
pub(crate) paths: Vec<PathBuf>,
pub(crate) nickname: Option<SharedString>,
}
@ -316,7 +321,16 @@ impl RenderOnce for SshConnectionHeader {
h_flex()
.gap_1()
.child(Headline::new(main_label).size(HeadlineSize::XSmall))
.children(meta_label.map(|label| Label::new(label).color(Color::Muted))),
.children(
meta_label.map(|label| {
Label::new(label).color(Color::Muted).size(LabelSize::Small)
}),
)
.children(self.paths.into_iter().map(|path| {
Label::new(path.to_string_lossy().to_string())
.size(LabelSize::Small)
.color(Color::Muted)
})),
)
}
}
@ -340,6 +354,7 @@ impl Render for SshConnectionModal {
.on_action(cx.listener(Self::confirm))
.child(
SshConnectionHeader {
paths: self.paths.clone(),
connection_string,
nickname,
}
@ -652,10 +667,11 @@ pub async fn open_ssh_project(
let delegate = window.update(cx, {
let connection_options = connection_options.clone();
let nickname = nickname.clone();
let paths = paths.clone();
move |workspace, cx| {
cx.activate_window();
workspace.toggle_modal(cx, |cx| {
SshConnectionModal::new(&connection_options, nickname.clone(), cx)
SshConnectionModal::new(&connection_options, paths, nickname.clone(), cx)
});
let ui = workspace