mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-10 04:09:37 +00:00
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:
parent
fda21232ae
commit
3e44e97177
1 changed files with 18 additions and 6 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue