Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Adjust labels of buttons in extension list based on status (#8319)
Marshall Bowersc59aab5090b7
diff --git a/crates/extension/src/extension_store.rs b/crates/extension/src/extension_store.rsindex 7bd3768a87f..c87a38d6950 100644--- a/crates/extension/src/extension_store.rs+++ b/crates/extension/src/extension_store.rs@@ -52,6 +52,20 @@ pub enum ExtensionStatus {Removing,}+impl ExtensionStatus {+ pub fn is_installing(&self) -> bool {+ matches!(self, Self::Installing)+ }++ pub fn is_upgrading(&self) -> bool {+ matches!(self, Self::Upgrading)+ }++ pub fn is_removing(&self) -> bool {+ matches!(self, Self::Removing)+ }+}+pub struct ExtensionStore {manifest: Arc<RwLock<Manifest>>,fs: Arc<dyn Fs>,diff --git a/crates/extensions_ui/src/extensions_ui.rs b/crates/extensions_ui/src/extensions_ui.rsindex d971e200eb9..8a4a533e194 100644--- a/crates/extensions_ui/src/extensions_ui.rs+++ b/crates/extensions_ui/src/extensions_ui.rs@@ -181,36 +181,48 @@ impl ExtensionsPage {};let install_or_uninstall_button = match status {- ExtensionStatus::NotInstalled | ExtensionStatus::Installing => {- Button::new(SharedString::from(extension.id.clone()), "Install")- .on_click(cx.listener({- let extension_id = extension.id.clone();- let version = extension.version.clone();- move |this, _, cx| {- this.telemetry- .report_app_event("extensions: install extension".to_string());- this.install_extension(extension_id.clone(), version.clone(), cx);- }- }))- .disabled(matches!(status, ExtensionStatus::Installing))- }+ ExtensionStatus::NotInstalled | ExtensionStatus::Installing => Button::new(+ SharedString::from(extension.id.clone()),+ if status.is_installing() {+ "Installing..."+ } else {+ "Install"+ },+ )+ .on_click(cx.listener({+ let extension_id = extension.id.clone();+ let version = extension.version.clone();+ move |this, _, cx| {+ this.telemetry+ .report_app_event("extensions: install extension".to_string());+ this.install_extension(extension_id.clone(), version.clone(), cx);+ }+ }))+ .disabled(status.is_installing()),ExtensionStatus::Installed(_)| ExtensionStatus::Upgrading- | ExtensionStatus::Removing => {- Button::new(SharedString::from(extension.id.clone()), "Uninstall")- .on_click(cx.listener({- let extension_id = extension.id.clone();- move |this, _, cx| {- this.telemetry- .report_app_event("extensions: uninstall extension".to_string());- this.uninstall_extension(extension_id.clone(), cx);- }- }))- .disabled(matches!(- status,- ExtensionStatus::Upgrading | ExtensionStatus::Removing- ))- }+ | ExtensionStatus::Removing => Button::new(+ SharedString::from(extension.id.clone()),+ if status.is_upgrading() {+ "Upgrading..."+ } else if status.is_removing() {+ "Removing..."+ } else {+ "Uninstall"+ },+ )+ .on_click(cx.listener({+ let extension_id = extension.id.clone();+ move |this, _, cx| {+ this.telemetry+ .report_app_event("extensions: uninstall extension".to_string());+ this.uninstall_extension(extension_id.clone(), cx);+ }+ }))+ .disabled(matches!(+ status,+ ExtensionStatus::Upgrading | ExtensionStatus::Removing+ )),}.color(Color::Accent);