extensions_ui: Add ability to open the extensions view with a pre-selected filter (#27093)

This PR adds the ability to open the extensions view via the `zed:
extensions` action with a pre-selected filter.

The "Install Themes" and "Install Icon Themes" buttons in their
respective selectors take advantage of this to set the filter when
opening the view:


https://github.com/user-attachments/assets/2e345c0f-418a-47b6-811e-cabae6c616d1

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-03-19 13:26:46 -04:00 committed by GitHub
parent d51cd15e4d
commit d722067000
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 107 additions and 33 deletions

View file

@ -11,7 +11,7 @@ use theme::{Appearance, IconTheme, ThemeMeta, ThemeRegistry, ThemeSettings};
use ui::{prelude::*, v_flex, ListItem, ListItemSpacing};
use util::ResultExt;
use workspace::{ui::HighlightedLabel, ModalView};
use zed_actions::Extensions;
use zed_actions::{ExtensionCategoryFilter, Extensions};
pub(crate) struct IconThemeSelector {
picker: Entity<Picker<IconThemeSelectorDelegate>>,
@ -301,7 +301,12 @@ impl PickerDelegate for IconThemeSelectorDelegate {
.child(
Button::new("more-icon-themes", "Install Icon Themes").on_click(
move |_event, window, cx| {
window.dispatch_action(Box::new(Extensions), cx);
window.dispatch_action(
Box::new(Extensions {
category_filter: Some(ExtensionCategoryFilter::IconThemes),
}),
cx,
);
},
),
)

View file

@ -13,7 +13,7 @@ use theme::{Appearance, Theme, ThemeMeta, ThemeRegistry, ThemeSettings};
use ui::{prelude::*, v_flex, ListItem, ListItemSpacing};
use util::ResultExt;
use workspace::{ui::HighlightedLabel, ModalView, Workspace};
use zed_actions::Extensions;
use zed_actions::{ExtensionCategoryFilter, Extensions};
use crate::icon_theme_selector::{IconThemeSelector, IconThemeSelectorDelegate};
@ -349,7 +349,12 @@ impl PickerDelegate for ThemeSelectorDelegate {
.child(
Button::new("more-themes", "Install Themes").on_click(cx.listener({
move |_, _, window, cx| {
window.dispatch_action(Box::new(Extensions), cx);
window.dispatch_action(
Box::new(Extensions {
category_filter: Some(ExtensionCategoryFilter::Themes),
}),
cx,
);
}
})),
)