@@ -93,25 +93,20 @@ export const HomePage = () => {
93
93
if ( ! pluginsSocket ) {
94
94
return
95
95
}
96
-
97
96
pluginsSocket ?. emit ( 'search' , searchParams )
98
-
99
-
100
97
pluginsSocket ! . on ( 'results:search' , ( data : {
101
98
results : PluginDef [ ]
102
99
} ) => {
103
- if ( Array . isArray ( data . results ) && data . results . length > 0 ) {
104
- setPlugins ( data . results )
105
- } else {
106
- useStore . getState ( ) . setToastState ( {
107
- open : true ,
108
- title : "Error retrieving plugins" ,
109
- success : false
110
- } )
111
- }
100
+ setPlugins ( data . results )
101
+ } )
102
+ pluginsSocket ! . on ( 'results:searcherror' , ( data : { error : string } ) => {
103
+ console . log ( data . error )
104
+ useStore . getState ( ) . setToastState ( {
105
+ open : true ,
106
+ title : "Error retrieving plugins" ,
107
+ success : false
108
+ } )
112
109
} )
113
-
114
-
115
110
} , [ searchParams , pluginsSocket ] ) ;
116
111
117
112
const uninstallPlugin = ( pluginName : string ) => {
@@ -125,7 +120,6 @@ export const HomePage = () => {
125
120
setPlugins ( plugins . filter ( plugin => plugin . name !== pluginName ) )
126
121
}
127
122
128
-
129
123
useDebounce ( ( ) => {
130
124
setSearchParams ( {
131
125
...searchParams ,
@@ -161,12 +155,12 @@ export const HomePage = () => {
161
155
</ td >
162
156
</ tr >
163
157
} ) }
164
- </ tbody >
165
- </ table >
158
+ </ tbody >
159
+ </ table >
166
160
167
161
168
- < h2 > < Trans i18nKey = "admin_plugins.available" /> </ h2 >
169
- < SearchField onChange = { v => { setSearchTerm ( v . target . value ) } } placeholder = { t ( 'admin_plugins.available_search.placeholder' ) } value = { searchTerm } />
162
+ < h2 > < Trans i18nKey = "admin_plugins.available" /> </ h2 >
163
+ < SearchField onChange = { v => { setSearchTerm ( v . target . value ) } } placeholder = { t ( 'admin_plugins.available_search.placeholder' ) } value = { searchTerm } />
170
164
171
165
< table id = "available-plugins" >
172
166
< thead >
@@ -179,17 +173,21 @@ export const HomePage = () => {
179
173
</ tr >
180
174
</ thead >
181
175
< tbody style = { { overflow : 'auto' } } >
182
- { plugins . map ( ( plugin ) => {
183
- return < tr key = { plugin . name } >
184
- < td > < a rel = "noopener noreferrer" href = { `https://npmjs.com/${ plugin . name } ` } target = "_blank" > { plugin . name } </ a > </ td >
185
- < td > { plugin . description } </ td >
186
- < td > { plugin . version } </ td >
187
- < td > { plugin . time } </ td >
188
- < td >
189
- < IconButton icon = { < Download /> } onClick = { ( ) => installPlugin ( plugin . name ) } title = { < Trans i18nKey = "admin_plugins.available_install.value" /> } />
190
- </ td >
191
- </ tr >
192
- } ) }
176
+ { ( plugins . length > 0 ) ?
177
+ plugins . map ( ( plugin ) => {
178
+ return < tr key = { plugin . name } >
179
+ < td > < a rel = "noopener noreferrer" href = { `https://npmjs.com/${ plugin . name } ` } target = "_blank" > { plugin . name } </ a > </ td >
180
+ < td > { plugin . description } </ td >
181
+ < td > { plugin . version } </ td >
182
+ < td > { plugin . time } </ td >
183
+ < td >
184
+ < IconButton icon = { < Download /> } onClick = { ( ) => installPlugin ( plugin . name ) } title = { < Trans i18nKey = "admin_plugins.available_install.value" /> } />
185
+ </ td >
186
+ </ tr >
187
+ } )
188
+ :
189
+ < tr > < td colSpan = { 5 } > { searchTerm == '' ? < Trans i18nKey = "pad.loading" /> : < Trans i18nKey = "admin_plugins.available_not-found" /> } </ td > </ tr >
190
+ }
193
191
</ tbody >
194
192
</ table >
195
193
</ div >
0 commit comments