@@ -2,7 +2,7 @@ import { v1 } from '@docker/extension-api-client-types';
2
2
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' ;
3
3
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight' ;
4
4
import { Collapse , Grid2 , Typography } from '@mui/material' ;
5
- import React , { useMemo , useState } from 'react' ;
5
+ import React , { useEffect , useMemo , useState } from 'react' ;
6
6
import { CATALOG_LAYOUT_SX } from '../../Constants' ;
7
7
import { useCatalogAll } from '../../queries/useCatalog' ;
8
8
import Tile from '../tile/Index' ;
@@ -19,8 +19,8 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({
19
19
sort,
20
20
} ) => {
21
21
const { catalogItems, registryLoading } = useCatalogAll ( client ) ;
22
- const [ expandedEnabled , setExpandedEnabled ] = useState ( true ) ;
23
- const [ expandedNotEnabled , setExpandedNotEnabled ] = useState ( true ) ;
22
+ const [ expandedEnabled , setExpandedEnabled ] = useState ( localStorage . getItem ( 'expandedEnabled' ) !== 'false' ) ;
23
+ const [ expandedNotEnabled , setExpandedNotEnabled ] = useState ( localStorage . getItem ( 'expandedNotEnabled' ) !== 'false' ) ;
24
24
25
25
// Memoize the filtered catalog items to prevent unnecessary recalculations
26
26
const result = useMemo ( ( ) => {
@@ -44,10 +44,14 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({
44
44
< Typography
45
45
variant = 'subtitle2'
46
46
sx = { { color : "text.secondary" , display : "flex" , alignItems : "center" , cursor : "pointer" } }
47
- onClick = { ( ) => setExpandedEnabled ( ! expandedEnabled ) } >
47
+ onClick = { ( ) => {
48
+ const newExpanded = ! expandedEnabled
49
+ setExpandedEnabled ( newExpanded ) ;
50
+ localStorage . setItem ( 'expandedEnabled' , JSON . stringify ( newExpanded ) ) ;
51
+ } } >
48
52
Enabled tools
49
53
{ expandedEnabled ? < KeyboardArrowDownIcon fontSize = "small" /> : < KeyboardArrowRightIcon fontSize = "small" /> }
50
- </ Typography >
54
+ </ Typography >
51
55
52
56
< Collapse in = { expandedEnabled } >
53
57
< Grid2 container spacing = { 1 } sx = { CATALOG_LAYOUT_SX } >
@@ -68,7 +72,11 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({
68
72
< Typography
69
73
variant = 'subtitle2'
70
74
sx = { { color : "text.secondary" , display : "flex" , alignItems : "center" , cursor : "pointer" } }
71
- onClick = { ( ) => setExpandedNotEnabled ( ! expandedNotEnabled ) } >
75
+ onClick = { ( ) => {
76
+ const newExpanded = ! expandedNotEnabled
77
+ setExpandedNotEnabled ( newExpanded ) ;
78
+ localStorage . setItem ( 'expandedNotEnabled' , JSON . stringify ( newExpanded ) ) ;
79
+ } } >
72
80
All the tools
73
81
{ expandedNotEnabled ? < KeyboardArrowDownIcon fontSize = "small" /> : < KeyboardArrowRightIcon fontSize = "small" /> }
74
82
</ Typography >
0 commit comments