Add url preview tooltip to repository link in extensions view (#8179)

Because the `repository` url field is defined via the user's
`extension.json` file, a user could insert a malicious link. I want to
be able to preview repository urls before clicking the button.

Release Notes:

- Add url preview tooltip to repository link in extensions view.
This commit is contained in:
Joseph T. Lyons 2024-02-22 03:46:01 -05:00 committed by GitHub
parent 38c3a93f0c
commit e5d971f4c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,7 +11,7 @@ use settings::Settings;
use std::time::Duration;
use std::{ops::Range, sync::Arc};
use theme::ThemeSettings;
use ui::prelude::*;
use ui::{prelude::*, Tooltip};
use workspace::{
item::{Item, ItemEvent},
@ -195,6 +195,7 @@ impl ExtensionsPage {
.color(Color::Accent);
let repository_url = extension.repository.clone();
let tooltip_text = Tooltip::text(repository_url.clone(), cx);
div().w_full().child(
v_flex()
@ -269,7 +270,8 @@ impl ExtensionsPage {
.style(ButtonStyle::Filled)
.on_click(cx.listener(move |_, _, cx| {
cx.open_url(&repository_url);
})),
}))
.tooltip(move |_| tooltip_text.clone()),
),
),
)