remote ssh: Show connection status in tooltip (#19006)
Release Notes: - N/A --------- Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
This commit is contained in:
parent
fe1078ef68
commit
db50467bbc
1 changed files with 30 additions and 6 deletions
|
@ -264,20 +264,43 @@ impl TitleBar {
|
|||
|
||||
fn render_ssh_project_host(&self, cx: &mut ViewContext<Self>) -> Option<AnyElement> {
|
||||
let host = self.project.read(cx).ssh_connection_string(cx)?;
|
||||
let meta = SharedString::from(format!("Connected to: {host}"));
|
||||
let indicator_color = match self.project.read(cx).ssh_connection_state(cx)? {
|
||||
|
||||
let (indicator_color, meta) = match self.project.read(cx).ssh_connection_state(cx)? {
|
||||
remote::ConnectionState::Connecting => (Color::Info, format!("Connecting to: {host}")),
|
||||
remote::ConnectionState::Connected => (Color::Success, format!("Connected to: {host}")),
|
||||
remote::ConnectionState::HeartbeatMissed => (
|
||||
Color::Warning,
|
||||
format!("Connection attempt to {host} missed. Retrying..."),
|
||||
),
|
||||
remote::ConnectionState::Reconnecting => (
|
||||
Color::Warning,
|
||||
format!("Lost connection to {host}. Reconnecting..."),
|
||||
),
|
||||
remote::ConnectionState::Disconnected => {
|
||||
(Color::Error, format!("Disconnected from {host}"))
|
||||
}
|
||||
};
|
||||
|
||||
let indicator_border_color = cx.theme().colors().title_bar_background;
|
||||
|
||||
let icon_color = match self.project.read(cx).ssh_connection_state(cx)? {
|
||||
remote::ConnectionState::Connecting => Color::Info,
|
||||
remote::ConnectionState::Connected => Color::Success,
|
||||
remote::ConnectionState::Connected => Color::Default,
|
||||
remote::ConnectionState::HeartbeatMissed => Color::Warning,
|
||||
remote::ConnectionState::Reconnecting => Color::Warning,
|
||||
remote::ConnectionState::Disconnected => Color::Error,
|
||||
};
|
||||
|
||||
let meta = SharedString::from(meta);
|
||||
|
||||
let indicator = div()
|
||||
.absolute()
|
||||
.size_1p5()
|
||||
.right_0p5()
|
||||
.bottom_0p5()
|
||||
.size_2p5()
|
||||
.right_0()
|
||||
.bottom_0()
|
||||
.rounded_full()
|
||||
.border_2()
|
||||
.border_color(indicator_border_color)
|
||||
.bg(indicator_color.color(cx));
|
||||
|
||||
Some(
|
||||
|
@ -287,6 +310,7 @@ impl TitleBar {
|
|||
IconButton::new("ssh-server-icon", IconName::Server)
|
||||
.icon_size(IconSize::Small)
|
||||
.shape(IconButtonShape::Square)
|
||||
.icon_color(icon_color)
|
||||
.tooltip(move |cx| {
|
||||
Tooltip::with_meta(
|
||||
"Remote Project",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue