Allow extensions to be filtered on installed and not installed (#8375)
Partially resolves: https://github.com/zed-industries/zed/issues/7785 Right now, we can engage `Only show installed`, but I've been wanting to be able to filter down to just uninstalled extensions too, so I can browse things I don't have. I changed this to have 2 checkboxes, `Installed` and `Not installed` and both are on by default. You deselect them to filter down. <img width="1608" alt="SCR-20240225-etyg" src="https://github.com/zed-industries/zed/assets/19867440/e2267651-ff86-437b-ba59-89f3d338ea02"> Release Notes: - Allow extensions list to be filtered down to both installed and not installed.
This commit is contained in:
parent
882cd6e52f
commit
633e31a47f
1 changed files with 38 additions and 20 deletions
|
@ -34,7 +34,8 @@ pub struct ExtensionsPage {
|
||||||
list: UniformListScrollHandle,
|
list: UniformListScrollHandle,
|
||||||
telemetry: Arc<Telemetry>,
|
telemetry: Arc<Telemetry>,
|
||||||
is_fetching_extensions: bool,
|
is_fetching_extensions: bool,
|
||||||
is_only_showing_installed_extensions: bool,
|
is_showing_installed_extensions: bool,
|
||||||
|
is_showing_not_installed_extensions: bool,
|
||||||
extension_entries: Vec<Extension>,
|
extension_entries: Vec<Extension>,
|
||||||
query_editor: View<Editor>,
|
query_editor: View<Editor>,
|
||||||
query_contains_error: bool,
|
query_contains_error: bool,
|
||||||
|
@ -55,7 +56,8 @@ impl ExtensionsPage {
|
||||||
list: UniformListScrollHandle::new(),
|
list: UniformListScrollHandle::new(),
|
||||||
telemetry: workspace.client().telemetry().clone(),
|
telemetry: workspace.client().telemetry().clone(),
|
||||||
is_fetching_extensions: false,
|
is_fetching_extensions: false,
|
||||||
is_only_showing_installed_extensions: false,
|
is_showing_installed_extensions: true,
|
||||||
|
is_showing_not_installed_extensions: true,
|
||||||
extension_entries: Vec::new(),
|
extension_entries: Vec::new(),
|
||||||
query_contains_error: false,
|
query_contains_error: false,
|
||||||
extension_fetch_task: None,
|
extension_fetch_task: None,
|
||||||
|
@ -73,12 +75,16 @@ impl ExtensionsPage {
|
||||||
self.extension_entries
|
self.extension_entries
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|extension| {
|
.filter(|extension| {
|
||||||
if self.is_only_showing_installed_extensions {
|
let status = extension_store.extension_status(&extension.id);
|
||||||
let status = extension_store.extension_status(&extension.id);
|
|
||||||
|
|
||||||
matches!(status, ExtensionStatus::Installed(_))
|
match [
|
||||||
} else {
|
self.is_showing_installed_extensions,
|
||||||
true
|
self.is_showing_not_installed_extensions,
|
||||||
|
] {
|
||||||
|
[true, true] => true,
|
||||||
|
[true, false] => matches!(status, ExtensionStatus::Installed(_)),
|
||||||
|
[false, true] => matches!(status, ExtensionStatus::NotInstalled),
|
||||||
|
[false, false] => false,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.cloned()
|
.cloned()
|
||||||
|
@ -415,19 +421,15 @@ impl ExtensionsPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_empty_state(&self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
fn render_empty_state(&self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||||
let has_search = self.search_query(cx).is_some();
|
let is_filtering = self.search_query(cx).is_some()
|
||||||
|
|| self.is_showing_installed_extensions
|
||||||
|
|| self.is_showing_not_installed_extensions;
|
||||||
|
|
||||||
let message = if self.is_fetching_extensions {
|
let message = if self.is_fetching_extensions {
|
||||||
"Loading extensions..."
|
"Loading extensions..."
|
||||||
} else if self.is_only_showing_installed_extensions {
|
|
||||||
if has_search {
|
|
||||||
"No installed extensions that match your search."
|
|
||||||
} else {
|
|
||||||
"No installed extensions."
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if has_search {
|
if is_filtering {
|
||||||
"No extensions that match your search."
|
"No extensions that match your search criteria."
|
||||||
} else {
|
} else {
|
||||||
"No extensions."
|
"No extensions."
|
||||||
}
|
}
|
||||||
|
@ -455,15 +457,31 @@ impl Render for ExtensionsPage {
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(h_flex().child(self.render_search(cx)))
|
.child(h_flex().child(self.render_search(cx)))
|
||||||
.child(CheckboxWithLabel::new(
|
.child(CheckboxWithLabel::new(
|
||||||
"installed",
|
"Installed",
|
||||||
Label::new("Only show installed"),
|
Label::new("Installed"),
|
||||||
if self.is_only_showing_installed_extensions {
|
if self.is_showing_installed_extensions {
|
||||||
Selection::Selected
|
Selection::Selected
|
||||||
} else {
|
} else {
|
||||||
Selection::Unselected
|
Selection::Unselected
|
||||||
},
|
},
|
||||||
cx.listener(|this, selection, _cx| {
|
cx.listener(|this, selection, _cx| {
|
||||||
this.is_only_showing_installed_extensions = match selection {
|
this.is_showing_installed_extensions = match selection {
|
||||||
|
Selection::Selected => true,
|
||||||
|
Selection::Unselected => false,
|
||||||
|
Selection::Indeterminate => return,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
.child(CheckboxWithLabel::new(
|
||||||
|
"not installed",
|
||||||
|
Label::new("Not installed"),
|
||||||
|
if self.is_showing_not_installed_extensions {
|
||||||
|
Selection::Selected
|
||||||
|
} else {
|
||||||
|
Selection::Unselected
|
||||||
|
},
|
||||||
|
cx.listener(|this, selection, _cx| {
|
||||||
|
this.is_showing_not_installed_extensions = match selection {
|
||||||
Selection::Selected => true,
|
Selection::Selected => true,
|
||||||
Selection::Unselected => false,
|
Selection::Unselected => false,
|
||||||
Selection::Indeterminate => return,
|
Selection::Indeterminate => return,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue