Skip to content

Commit 97fc103

Browse files
author
colinmcneil
committed
Use tab layout
1 parent 452e58c commit 97fc103

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

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

Lines changed: 29 additions & 12 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, TextField } 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, Tabs, Tab, Tooltip } from '@mui/material';
33
import { CatalogItemWithName, CatalogItemCard, CatalogItem } from './PromptCard';
44
import AddIcon from '@mui/icons-material/Add';
55
import { Ref } from '../Refs';
@@ -37,6 +37,7 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
3737
const [showUnregistered, setShowUnregistered] = useState<boolean>(true);
3838
const [showReloadModal, setShowReloadModal] = useState<boolean>(false);
3939
const [search, setSearch] = useState<string>('');
40+
const [tab, setTab] = useState<number>(0);
4041

4142
const filteredCatalogItems = filterCatalog(catalogItems, registryItems, showRegistered, showUnregistered, search);
4243

@@ -47,7 +48,7 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
4748
const catalog = await response.text();
4849
const items = parse(catalog)['registry'] as { [key: string]: CatalogItem }
4950
const itemsWithName = Object.entries(items).map(([name, item]) => ({ name, ...item }));
50-
const filteredItems = filterCatalog(itemsWithName, registryItems, showRegistered, showUnregistered);
51+
const filteredItems = filterCatalog(itemsWithName, registryItems, showRegistered, showUnregistered, search);
5152
setCatalogItems(filteredItems);
5253
localStorage.setItem('catalog', JSON.stringify(filteredItems));
5354
if (showNotification) {
@@ -141,25 +142,32 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
141142
}}>registry.yaml</Button>} severity="info">
142143
<Typography sx={{ width: '100%' }}>You have some prompts registered which are not available in the catalog.</Typography>
143144
</Alert>}
144-
<FormGroup sx={{ width: '100%' }}>
145-
<Stack direction="row" spacing={1} alignItems='center'>
146-
<TextField label="Search" value={search} onChange={(e) => setSearch(e.target.value)} sx={{ width: 150 }} />
147-
<FormControlLabel control={<Switch checked={showRegistered} onChange={(e) => setShowRegistered(e.target.checked)} />} label="Show Allowed Prompts" />
148-
<FormControlLabel control={<Switch checked={showUnregistered} onChange={(e) => setShowUnregistered(e.target.checked)} />} label="Show Blocked Prompts" />
149-
<Link sx={{ fontWeight: 'bold' }} href="https://vonwig.github.io/prompts.docs/tools/docs/" target="_blank" rel="noopener noreferrer" onClick={() => {
145+
<Tabs value={tab} onChange={(e, v) => setTab(v)} sx={{ mb: 0, mt: 1 }}>
146+
<Tooltip title="These are all of the prompts you have available across the catalog.">
147+
<Tab sx={{ fontSize: '1.5em' }} label="Available" />
148+
</Tooltip>
149+
<Tooltip title="These are prompts which you have allowed MCP clients to use.">
150+
<Tab sx={{ fontSize: '1.5em' }} label="Allowed" />
151+
</Tooltip>
152+
</Tabs>
153+
<FormGroup sx={{ width: '100%', mt: 0 }}>
154+
<Stack direction="row" spacing={1} alignItems='center' justifyContent="space-evenly">
155+
<TextField label="Search" value={search} onChange={(e) => setSearch(e.target.value)} />
156+
<Link sx={{ fontWeight: 'bold', justifySelf: 'flex-end', marginLeft: 'auto', }} href="https://vonwig.github.io/prompts.docs/tools/docs/" target="_blank" rel="noopener noreferrer" onClick={() => {
150157
client.host.openExternal('https://vonwig.github.io/prompts.docs/tools/docs/');
151158
}}>⇱ Documentation</Link>
152-
<Link sx={{ fontWeight: 'bold', ml: 2 }} href="https://github.com/docker/labs-ai-tools-for-devs" target="_blank" rel="noopener noreferrer" onClick={() => {
159+
<Link sx={{ fontWeight: 'bold', }} href="https://github.com/docker/labs-ai-tools-for-devs" target="_blank" rel="noopener noreferrer" onClick={() => {
153160
client.host.openExternal('https://github.com/docker/labs-ai-tools-for-devs');
154161
}}>⇱ GitHub</Link>
155-
<IconButton sx={{ marginLeft: 'auto', marginRight: 2, alignSelf: 'flex-end', justifyContent: 'flex-end' }} onClick={showSettings}>
162+
<IconButton sx={{ ml: 2, alignSelf: 'flex-end', justifyContent: 'flex-end' }} onClick={showSettings}>
156163
<Badge {...settingsBadgeProps}>
157164
<Settings sx={{ fontSize: '1.5em' }} />
158165
</Badge>
159166
</IconButton>
160167
</Stack>
161168
</FormGroup >
162-
<Grid2 container spacing={2} width='100%' maxWidth={1000}>
169+
170+
{tab === 0 && <Grid2 container spacing={2} width='100%' maxWidth={1000}>
163171
{filteredCatalogItems.map((item) => (
164172
<Grid2 size={{ xs: 12, sm: 6, md: 4 }} key={item.name}>
165173
<CatalogItemCard
@@ -185,7 +193,16 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
185193
</CardContent>
186194
</Card>
187195
</Grid2>
188-
</Grid2>
196+
</Grid2>}
197+
{tab === 1 && <Grid2 container spacing={2} width='100%' maxWidth={1000}>
198+
{Object.entries(registryItems).map(([name, item]) => (
199+
<Grid2 size={{ xs: 12, sm: 6, md: 4 }} key={name}>
200+
<CatalogItemCard item={catalogItems.find((i) => i.name === name)!} openUrl={() => {
201+
client.host.openExternal(Ref.fromRef(item.ref).toURL(true));
202+
}} canRegister={canRegister} registered={true} register={registerCatalogItem} unregister={unregisterCatalogItem} />
203+
</Grid2>
204+
))}
205+
</Grid2>}
189206
</Stack >
190207
);
191208
};

src/extension/ui/src/components/PromptCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ export function CatalogItemCard({ openUrl, item, canRegister, registered, regist
3838
/>
3939
</Stack>
4040
</a>
41-
<Typography variant="body2" sx={{ mt: 2 }}>
41+
<Typography variant="body2" sx={{ mt: 0.5 }}>
4242
{item.description}
4343
</Typography>
4444
</CardContent>
45-
<CardActions>
45+
<CardActions sx={{ pt: 0 }}>
4646
<Stack direction="row" spacing={2} sx={{ alignItems: 'center', justifyContent: 'space-between', width: '100%' }}>
4747
<Stack direction="row" spacing={2}>
4848
<Tooltip title="Prompts">

0 commit comments

Comments
 (0)