Adjust labels of buttons in extension list based on status (#8319)
This PR makes the labels of the buttons in the extension list adapt to reflect the current status. Release Notes: - Changed the button labels in the extension list to reflect the current status.
This commit is contained in:
parent
2e616f8388
commit
c59aab5090
2 changed files with 54 additions and 28 deletions
|
@ -52,6 +52,20 @@ pub enum ExtensionStatus {
|
||||||
Removing,
|
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 {
|
pub struct ExtensionStore {
|
||||||
manifest: Arc<RwLock<Manifest>>,
|
manifest: Arc<RwLock<Manifest>>,
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
|
|
|
@ -181,8 +181,14 @@ impl ExtensionsPage {
|
||||||
};
|
};
|
||||||
|
|
||||||
let install_or_uninstall_button = match status {
|
let install_or_uninstall_button = match status {
|
||||||
ExtensionStatus::NotInstalled | ExtensionStatus::Installing => {
|
ExtensionStatus::NotInstalled | ExtensionStatus::Installing => Button::new(
|
||||||
Button::new(SharedString::from(extension.id.clone()), "Install")
|
SharedString::from(extension.id.clone()),
|
||||||
|
if status.is_installing() {
|
||||||
|
"Installing..."
|
||||||
|
} else {
|
||||||
|
"Install"
|
||||||
|
},
|
||||||
|
)
|
||||||
.on_click(cx.listener({
|
.on_click(cx.listener({
|
||||||
let extension_id = extension.id.clone();
|
let extension_id = extension.id.clone();
|
||||||
let version = extension.version.clone();
|
let version = extension.version.clone();
|
||||||
|
@ -192,12 +198,19 @@ impl ExtensionsPage {
|
||||||
this.install_extension(extension_id.clone(), version.clone(), cx);
|
this.install_extension(extension_id.clone(), version.clone(), cx);
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.disabled(matches!(status, ExtensionStatus::Installing))
|
.disabled(status.is_installing()),
|
||||||
}
|
|
||||||
ExtensionStatus::Installed(_)
|
ExtensionStatus::Installed(_)
|
||||||
| ExtensionStatus::Upgrading
|
| ExtensionStatus::Upgrading
|
||||||
| ExtensionStatus::Removing => {
|
| ExtensionStatus::Removing => Button::new(
|
||||||
Button::new(SharedString::from(extension.id.clone()), "Uninstall")
|
SharedString::from(extension.id.clone()),
|
||||||
|
if status.is_upgrading() {
|
||||||
|
"Upgrading..."
|
||||||
|
} else if status.is_removing() {
|
||||||
|
"Removing..."
|
||||||
|
} else {
|
||||||
|
"Uninstall"
|
||||||
|
},
|
||||||
|
)
|
||||||
.on_click(cx.listener({
|
.on_click(cx.listener({
|
||||||
let extension_id = extension.id.clone();
|
let extension_id = extension.id.clone();
|
||||||
move |this, _, cx| {
|
move |this, _, cx| {
|
||||||
|
@ -209,8 +222,7 @@ impl ExtensionsPage {
|
||||||
.disabled(matches!(
|
.disabled(matches!(
|
||||||
status,
|
status,
|
||||||
ExtensionStatus::Upgrading | ExtensionStatus::Removing
|
ExtensionStatus::Upgrading | ExtensionStatus::Removing
|
||||||
))
|
)),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.color(Color::Accent);
|
.color(Color::Accent);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue