Skip to content

Commit 452e58c

Browse files
author
colinmcneil
committed
Add basic search
1 parent 8c2ea01 commit 452e58c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/extension/ui/src/components/CatalogGrid.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react';
2-
import { Card, CardContent, IconButton, Alert, Stack, Button, Typography, Grid2, Select, MenuItem, FormControl, InputLabel, Switch, FormGroup, FormControlLabel, Dialog, DialogTitle, DialogContent, Checkbox, Badge, BadgeProps, Link } from '@mui/material';
2+
import { Card, CardContent, IconButton, Alert, Stack, Button, Typography, Grid2, Select, MenuItem, FormControl, InputLabel, Switch, FormGroup, FormControlLabel, Dialog, DialogTitle, DialogContent, Checkbox, Badge, BadgeProps, Link, TextField } from '@mui/material';
33
import { CatalogItemWithName, CatalogItemCard, CatalogItem } from './PromptCard';
44
import AddIcon from '@mui/icons-material/Add';
55
import { Ref } from '../Refs';
@@ -19,8 +19,8 @@ interface CatalogGridProps {
1919
settingsBadgeProps: BadgeProps;
2020
}
2121

22-
const filterCatalog = (catalogItems: CatalogItemWithName[], registryItems: { [key: string]: { ref: string } }, showRegistered: boolean, showUnregistered: boolean) =>
23-
catalogItems.filter((item) => (showRegistered || !Object.keys(registryItems).includes(item.name)) && (showUnregistered || Object.keys(registryItems).includes(item.name)));
22+
const filterCatalog = (catalogItems: CatalogItemWithName[], registryItems: { [key: string]: { ref: string } }, showRegistered: boolean, showUnregistered: boolean, search: string) =>
23+
catalogItems.filter((item) => (showRegistered || !Object.keys(registryItems).includes(item.name)) && (showUnregistered || Object.keys(registryItems).includes(item.name)) && (item.name.toLowerCase().includes(search.toLowerCase())));
2424

2525
const NEVER_SHOW_AGAIN_KEY = 'registry-sync-never-show-again';
2626

@@ -36,8 +36,9 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
3636
const [showRegistered, setShowRegistered] = useState<boolean>(true);
3737
const [showUnregistered, setShowUnregistered] = useState<boolean>(true);
3838
const [showReloadModal, setShowReloadModal] = useState<boolean>(false);
39+
const [search, setSearch] = useState<string>('');
3940

40-
const filteredCatalogItems = filterCatalog(catalogItems, registryItems, showRegistered, showUnregistered);
41+
const filteredCatalogItems = filterCatalog(catalogItems, registryItems, showRegistered, showUnregistered, search);
4142

4243
const loadCatalog = async (showNotification = true) => {
4344
const cachedCatalog = localStorage.getItem('catalog');
@@ -142,6 +143,7 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
142143
</Alert>}
143144
<FormGroup sx={{ width: '100%' }}>
144145
<Stack direction="row" spacing={1} alignItems='center'>
146+
<TextField label="Search" value={search} onChange={(e) => setSearch(e.target.value)} sx={{ width: 150 }} />
145147
<FormControlLabel control={<Switch checked={showRegistered} onChange={(e) => setShowRegistered(e.target.checked)} />} label="Show Allowed Prompts" />
146148
<FormControlLabel control={<Switch checked={showUnregistered} onChange={(e) => setShowUnregistered(e.target.checked)} />} label="Show Blocked Prompts" />
147149
<Link sx={{ fontWeight: 'bold' }} href="https://vonwig.github.io/prompts.docs/tools/docs/" target="_blank" rel="noopener noreferrer" onClick={() => {

0 commit comments

Comments
 (0)