Skip to content

Commit 2f6c2d2

Browse files
authored
Merge pull request #227 from dgageot/show-numbers
Show the numbers
2 parents 2bb0f50 + e188ed4 commit 2f6c2d2

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

src/extension/ui/src/components/tabs/ToolCatalog.tsx

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({
2323
const [expandedNotEnabled, setExpandedNotEnabled] = useState(localStorage.getItem('expandedNotEnabled') !== 'false');
2424

2525
// Memoize the filtered catalog items to prevent unnecessary recalculations
26-
const result = useMemo(() => {
26+
const all = useMemo(() => {
2727
const filteredItems = catalogItems.filter((item) => {
2828
return item.name.toLowerCase().includes(search.toLowerCase());
2929
});
@@ -38,36 +38,41 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({
3838
})
3939
: filteredItems;
4040
}, [catalogItems, search, sort]);
41+
const enabled = all.filter((item) => item.registered);
4142

4243
return (
4344
<>
44-
<Typography
45-
variant='subtitle2'
46-
sx={{ color: "text.secondary", display: "flex", alignItems: "center", cursor: "pointer", width: 'fit-content' }}
47-
onClick={() => {
48-
const newExpanded = !expandedEnabled
49-
setExpandedEnabled(newExpanded);
50-
localStorage.setItem('expandedEnabled', JSON.stringify(newExpanded));
51-
}}>
52-
Enabled tools
53-
{expandedEnabled ? <KeyboardArrowDownIcon fontSize="small" /> : <KeyboardArrowRightIcon fontSize="small" />}
54-
</Typography >
45+
{(enabled.length > 0) && (
46+
<>
47+
<Typography
48+
variant='subtitle2'
49+
sx={{ color: "text.secondary", display: "flex", alignItems: "center", cursor: "pointer", width: 'fit-content' }}
50+
onClick={() => {
51+
const newExpanded = !expandedEnabled
52+
setExpandedEnabled(newExpanded);
53+
localStorage.setItem('expandedEnabled', JSON.stringify(newExpanded));
54+
}}>
55+
{`Enabled (${enabled.length})`}
56+
{expandedEnabled ? <KeyboardArrowDownIcon fontSize="small" /> : <KeyboardArrowRightIcon fontSize="small" />}
57+
</Typography >
5558

56-
<Collapse in={expandedEnabled}>
57-
<Grid2 container spacing={1} sx={CATALOG_LAYOUT_SX}>
58-
{result.filter((item) => item.registered).map((catalogItem) => {
59-
return (
60-
<Grid2 size={{ xs: 12, sm: 6, md: 4 }} key={catalogItem.name}>
61-
<Tile
62-
item={catalogItem}
63-
client={client}
64-
registryLoading={registryLoading}
65-
/>
66-
</Grid2>
67-
);
68-
})}
69-
</Grid2>
70-
</Collapse>
59+
<Collapse in={expandedEnabled}>
60+
<Grid2 container spacing={1} sx={CATALOG_LAYOUT_SX}>
61+
{enabled.map((catalogItem) => {
62+
return (
63+
<Grid2 size={{ xs: 12, sm: 6, md: 4 }} key={catalogItem.name}>
64+
<Tile
65+
item={catalogItem}
66+
client={client}
67+
registryLoading={registryLoading}
68+
/>
69+
</Grid2>
70+
);
71+
})}
72+
</Grid2>
73+
</Collapse>
74+
</>
75+
)}
7176

7277
<Typography
7378
variant='subtitle2'
@@ -77,13 +82,13 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({
7782
setExpandedNotEnabled(newExpanded);
7883
localStorage.setItem('expandedNotEnabled', JSON.stringify(newExpanded));
7984
}}>
80-
All the tools
85+
{`All (${all.length})`}
8186
{expandedNotEnabled ? <KeyboardArrowDownIcon fontSize="small" /> : <KeyboardArrowRightIcon fontSize="small" />}
8287
</Typography>
8388

8489
<Collapse in={expandedNotEnabled}>
8590
<Grid2 container spacing={1} sx={CATALOG_LAYOUT_SX}>
86-
{result.filter((item) => true).map((catalogItem) => {
91+
{all.map((catalogItem) => {
8792
return (
8893
<Grid2 size={{ xs: 12, sm: 6, md: 4 }} key={catalogItem.name}>
8994
<Tile

0 commit comments

Comments
 (0)