Skip to content

Commit

Permalink
app: add query params to filter the apps (#34)
Browse files Browse the repository at this point in the history
VSC-2486

Signed-off-by: Filip Zajdel <[email protected]>
  • Loading branch information
FilipZajdel authored Mar 20, 2024
1 parent 4d16a00 commit 391e851
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

9 changes: 9 additions & 0 deletions site/src/app/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 391e851

Please sign in to comment.