extensions_ui: Add general structure for filtering extensions by what they provide (#24325)

This PR adds the general structure for filtering the extensions list by
what the extensions provide.

Currently flagged for Zed staff until we get some design direction on
how best to present the filter.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2025-02-06 00:09:37 +00:00
committed by GitHub
parent d81a4ec7ec
commit 4e5b11a0a7
5 changed files with 81 additions and 9 deletions
+14 -1
View File
@@ -8,8 +8,9 @@ mod extension_store_test;
use anyhow::{anyhow, bail, Context as _, Result};
use async_compression::futures::bufread::GzipDecoder;
use async_tar::Archive;
use client::ExtensionProvides;
use client::{proto, telemetry::Telemetry, Client, ExtensionMetadata, GetExtensionsResponse};
use collections::{btree_map, BTreeMap, HashMap, HashSet};
use collections::{btree_map, BTreeMap, BTreeSet, HashMap, HashSet};
use extension::extension_builder::{CompileExtensionOptions, ExtensionBuilder};
pub use extension::ExtensionManifest;
use extension::{
@@ -464,6 +465,7 @@ impl ExtensionStore {
pub fn fetch_extensions(
&self,
search: Option<&str>,
provides_filter: Option<&BTreeSet<ExtensionProvides>>,
cx: &mut Context<Self>,
) -> Task<Result<Vec<ExtensionMetadata>>> {
let version = CURRENT_SCHEMA_VERSION.to_string();
@@ -472,6 +474,17 @@ impl ExtensionStore {
query.push(("filter", search));
}
let provides_filter = provides_filter.map(|provides_filter| {
provides_filter
.iter()
.map(|provides| provides.to_string())
.collect::<Vec<_>>()
.join(",")
});
if let Some(provides_filter) = provides_filter.as_deref() {
query.push(("provides", provides_filter));
}
self.fetch_extensions_from_api("/extensions", &query, cx)
}