From 391e85146ea9b75f3fd9b265fb611b321e5efb75 Mon Sep 17 00:00:00 2001 From: Filip Zajdel <35106656+FilipZajdel@users.noreply.github.com> Date: Wed, 20 Mar 2024 08:59:37 +0100 Subject: [PATCH] app: add query params to filter the apps (#34) VSC-2486 Signed-off-by: Filip Zajdel --- README.md | 9 +++++++++ site/src/app/Root.tsx | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 2adef3a..6482d6c 100644 --- a/README.md +++ b/README.md @@ -113,3 +113,12 @@ To verify that your application index is correctly picked up by the [nRF Connect 1. In the extension's **Welcome View**, select [**Create a new application** > **Browse application index**](https://nrfconnect.github.io/vscode-nrf-connect/reference/ui_sidebar_welcome.html#create-a-new-application). Your custom `nrf-connect.appIndexUri` will be used to list the applications in the index. + +## Query parameters + +The Index exposes a number of query parameters that allows to efficiently filter the applications. + +| Parameter | Type | Description | Example | +|-----------|------|-------------|---------| +| app | string | Show applications that include the **app** in their name, title, description, or tags | ?app=air+quality | + diff --git a/site/src/app/Root.tsx b/site/src/app/Root.tsx index 0e6a32b..5d3ef0a 100644 --- a/site/src/app/Root.tsx +++ b/site/src/app/Root.tsx @@ -49,6 +49,15 @@ function Root(props: Props) { return () => dialogRef.current?.removeEventListener('close', onDialogClose); }); + useEffect(() => { + const searchParams = new URLSearchParams(window.location.search); + const appFilter = searchParams.get("app"); + + if (appFilter) { + dispatchFilters({ type: 'textSearch', payload: appFilter }); + } + }, []); + const showingApp = useMemo( () => props.apps.find((app) => app.id === showingAppId), [showingAppId],