Install the latest compatible version of an extension when clicking "Install" (#10575)

This PR makes it so clicking "Install" will install the latest
compatible version of an extension instead of disabling the button when
the latest version is not compatible.

The "Upgrade" button will still be disabled when the latest version is
not compatible. We will also now display a tooltip to better indicate
why the button is disabled:

<img width="607" alt="Screenshot 2024-04-15 at 2 41 26 PM"
src="https://github.com/zed-industries/zed/assets/1486634/16ad516e-1c0c-4505-b994-158ea655641b">

Related to https://github.com/zed-industries/zed/issues/10509.

Release Notes:

- Changed the "Install" button for extensions to always install the
latest compatible version instead of becoming disabled when the latest
version of an extension is incompatible with the current Zed version.
This commit is contained in:
Marshall Bowers 2024-04-15 15:06:07 -04:00 committed by GitHub
parent fda21232ae
commit 3e44e97177
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -591,13 +591,11 @@ impl ExtensionsPage {
cx: &mut ViewContext<Self>,
) -> (Button, Option<Button>) {
let is_compatible = extension::is_version_compatible(&extension);
let disabled = !is_compatible;
match status.clone() {
ExtensionStatus::NotInstalled => (
Button::new(SharedString::from(extension.id.clone()), "Install")
.disabled(disabled)
.on_click(cx.listener({
Button::new(SharedString::from(extension.id.clone()), "Install").on_click(
cx.listener({
let extension_id = extension.id.clone();
move |this, _, cx| {
this.telemetry
@ -606,7 +604,8 @@ impl ExtensionsPage {
store.install_latest_extension(extension_id.clone(), cx)
});
}
})),
}),
),
None,
),
ExtensionStatus::Installing => (
@ -637,7 +636,20 @@ impl ExtensionsPage {
} else {
Some(
Button::new(SharedString::from(extension.id.clone()), "Upgrade")
.disabled(disabled)
.when(!is_compatible, |upgrade_button| {
upgrade_button.disabled(true).tooltip({
let version = extension.manifest.version.clone();
move |cx| {
Tooltip::text(
format!(
"v{version} is not compatible with this version of Zed.",
),
cx,
)
}
})
})
.disabled(!is_compatible)
.on_click(cx.listener({
let extension_id = extension.id.clone();
let version = extension.manifest.version.clone();