@@ -6,28 +6,21 @@ 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' ;
9
- import ConfigurationModal from '../tile/Modal' ;
10
- import { CatalogItemRichened } from '../../types' ;
11
9
12
10
interface ToolCatalogProps {
13
11
search : string ;
14
12
client : v1 . DockerDesktopClient ;
15
13
sort : 'name-asc' | 'name-desc' ;
16
14
}
17
15
18
- const ToolCatalog : React . FC < ToolCatalogProps > = ( { search, client, sort } ) => {
16
+ const ToolCatalog : React . FC < ToolCatalogProps > = ( {
17
+ search,
18
+ client,
19
+ sort,
20
+ } ) => {
19
21
const { catalogItems, registryLoading } = useCatalogAll ( client ) ;
20
- const [ expandedEnabled , setExpandedEnabled ] = useState (
21
- localStorage . getItem ( 'expandedEnabled' ) !== 'false' ,
22
- ) ;
23
- const [ expandedNotEnabled , setExpandedNotEnabled ] = useState (
24
- localStorage . getItem ( 'expandedNotEnabled' ) !== 'false' ,
25
- ) ;
26
-
27
- const [ showConfigModal , setShowConfigModal ] = useState ( false ) ;
28
- const [ selectedItem , setSelectedItem ] = useState < CatalogItemRichened | null > (
29
- null ,
30
- ) ;
22
+ const [ expandedEnabled , setExpandedEnabled ] = useState ( localStorage . getItem ( 'expandedEnabled' ) !== 'false' ) ;
23
+ const [ expandedNotEnabled , setExpandedNotEnabled ] = useState ( localStorage . getItem ( 'expandedNotEnabled' ) !== 'false' ) ;
31
24
32
25
// Memoize the filtered catalog items to prevent unnecessary recalculations
33
26
const all = useMemo ( ( ) => {
@@ -37,54 +30,31 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({ search, client, sort }) => {
37
30
38
31
return sort === 'name-asc'
39
32
? filteredItems . sort ( ( a , b ) => {
40
- return a . name . localeCompare ( b . name ) ;
41
- } )
33
+ return a . name . localeCompare ( b . name ) ;
34
+ } )
42
35
: sort === 'name-desc'
43
36
? filteredItems . sort ( ( a , b ) => {
44
- return b . name . localeCompare ( a . name ) ;
45
- } )
37
+ return b . name . localeCompare ( a . name ) ;
38
+ } )
46
39
: filteredItems ;
47
40
} , [ catalogItems , search , sort ] ) ;
48
41
const enabled = all . filter ( ( item ) => item . registered ) ;
49
42
50
43
return (
51
44
< >
52
- { selectedItem !== null && (
53
- < ConfigurationModal
54
- open = { showConfigModal }
55
- onClose = { ( ) => setShowConfigModal ( false ) }
56
- catalogItem = { selectedItem }
57
- client = { client }
58
- registryLoading = { registryLoading }
59
- />
60
- ) }
61
- { enabled . length > 0 && (
45
+ { ( enabled . length > 0 ) && (
62
46
< >
63
47
< Typography
64
- variant = "subtitle2"
65
- sx = { {
66
- color : 'text.secondary' ,
67
- display : 'flex' ,
68
- alignItems : 'center' ,
69
- cursor : 'pointer' ,
70
- width : 'fit-content' ,
71
- } }
48
+ variant = 'subtitle2'
49
+ sx = { { color : "text.secondary" , display : "flex" , alignItems : "center" , cursor : "pointer" , width : 'fit-content' } }
72
50
onClick = { ( ) => {
73
- const newExpanded = ! expandedEnabled ;
51
+ const newExpanded = ! expandedEnabled
74
52
setExpandedEnabled ( newExpanded ) ;
75
- localStorage . setItem (
76
- 'expandedEnabled' ,
77
- JSON . stringify ( newExpanded ) ,
78
- ) ;
79
- } }
80
- >
53
+ localStorage . setItem ( 'expandedEnabled' , JSON . stringify ( newExpanded ) ) ;
54
+ } } >
81
55
{ `Enabled (${ enabled . length } )` }
82
- { expandedEnabled ? (
83
- < KeyboardArrowDownIcon fontSize = "small" />
84
- ) : (
85
- < KeyboardArrowRightIcon fontSize = "small" />
86
- ) }
87
- </ Typography >
56
+ { expandedEnabled ? < KeyboardArrowDownIcon fontSize = "small" /> : < KeyboardArrowRightIcon fontSize = "small" /> }
57
+ </ Typography >
88
58
89
59
< Collapse in = { expandedEnabled } >
90
60
< Grid2 container spacing = { 1 } sx = { CATALOG_LAYOUT_SX } >
@@ -95,8 +65,6 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({ search, client, sort }) => {
95
65
item = { catalogItem }
96
66
client = { client }
97
67
registryLoading = { registryLoading }
98
- setSelectedItem = { setSelectedItem }
99
- setShowConfigModal = { setShowConfigModal }
100
68
/>
101
69
</ Grid2 >
102
70
) ;
@@ -107,29 +75,15 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({ search, client, sort }) => {
107
75
) }
108
76
109
77
< Typography
110
- variant = "subtitle2"
111
- sx = { {
112
- color : 'text.secondary' ,
113
- display : 'flex' ,
114
- alignItems : 'center' ,
115
- cursor : 'pointer' ,
116
- width : 'fit-content' ,
117
- } }
78
+ variant = 'subtitle2'
79
+ sx = { { color : "text.secondary" , display : "flex" , alignItems : "center" , cursor : "pointer" , width : 'fit-content' } }
118
80
onClick = { ( ) => {
119
- const newExpanded = ! expandedNotEnabled ;
81
+ const newExpanded = ! expandedNotEnabled
120
82
setExpandedNotEnabled ( newExpanded ) ;
121
- localStorage . setItem (
122
- 'expandedNotEnabled' ,
123
- JSON . stringify ( newExpanded ) ,
124
- ) ;
125
- } }
126
- >
83
+ localStorage . setItem ( 'expandedNotEnabled' , JSON . stringify ( newExpanded ) ) ;
84
+ } } >
127
85
{ `All (${ all . length } )` }
128
- { expandedNotEnabled ? (
129
- < KeyboardArrowDownIcon fontSize = "small" />
130
- ) : (
131
- < KeyboardArrowRightIcon fontSize = "small" />
132
- ) }
86
+ { expandedNotEnabled ? < KeyboardArrowDownIcon fontSize = "small" /> : < KeyboardArrowRightIcon fontSize = "small" /> }
133
87
</ Typography >
134
88
135
89
< Collapse in = { expandedNotEnabled } >
@@ -141,8 +95,6 @@ const ToolCatalog: React.FC<ToolCatalogProps> = ({ search, client, sort }) => {
141
95
item = { catalogItem }
142
96
client = { client }
143
97
registryLoading = { registryLoading }
144
- setSelectedItem = { setSelectedItem }
145
- setShowConfigModal = { setShowConfigModal }
146
98
/>
147
99
</ Grid2 >
148
100
) ;
0 commit comments