@@ -19,14 +19,19 @@ import { useLocation, useParams } from 'react-router-dom'
19
19
20
20
import {
21
21
abortPreviousRequests ,
22
+ ErrorScreenManager ,
22
23
FiltersTypeEnum ,
24
+ getAIAnalyticsEvents ,
25
+ getIsRequestAborted ,
23
26
LARGE_PAGE_SIZE_OPTIONS ,
24
27
Nodes ,
25
28
PaginationEnum ,
26
29
SelectAllDialogStatus ,
30
+ ServerErrors ,
27
31
Table ,
28
32
TableColumnType ,
29
33
TableProps ,
34
+ URLS ,
30
35
useAsync ,
31
36
useUrlFilters ,
32
37
} from '@devtron-labs/devtron-fe-common-lib'
35
40
import { importComponentFromFELibrary } from '@Components/common'
36
41
import {
37
42
getManifestResource ,
43
+ getPodRestartRBACPayload ,
38
44
updateManifestResourceHelmApps ,
39
45
} from '@Components/v2/appDetails/k8Resource/nodeDetail/nodeDetail.api'
40
46
@@ -59,6 +65,7 @@ const RESOURCE_FILTER_KEYS: Record<string, unknown> = importComponentFromFELibra
59
65
)
60
66
const RBBulkSelectionActions = importComponentFromFELibrary ( 'RBBulkSelectionActions' , null , 'function' )
61
67
const RBBulkOperations = importComponentFromFELibrary ( 'RBBulkOperations' , null , 'function' )
68
+ const PodRestart = importComponentFromFELibrary ( 'PodRestart' )
62
69
63
70
const K8SResourceListViewWrapper = ( {
64
71
children,
@@ -136,7 +143,7 @@ export const K8SResourceList = ({
136
143
} , { } )
137
144
: null
138
145
139
- const [ resourceListLoader , resourceList , , reloadResourceList ] = useAsync (
146
+ const [ resourceListLoader , resourceList , resourceListError , reloadResourceList ] = useAsync (
140
147
( ) =>
141
148
abortPreviousRequests ( async ( ) => {
142
149
if ( selectedResource ) {
@@ -152,10 +159,10 @@ export const K8SResourceList = ({
152
159
return null
153
160
} , abortControllerRef ) ,
154
161
[ selectedResource , clusterId , selectedNamespace , JSON . stringify ( resourceFilters ) ] ,
155
- true ,
156
- { resetOnChange : false } ,
157
162
)
158
163
164
+ const isResourceListLoading = ! resourceList || resourceListLoader || getIsRequestAborted ( resourceListError )
165
+
159
166
useEffect (
160
167
( ) => ( ) => {
161
168
abortControllerRef . current ?. abort ( )
@@ -197,10 +204,6 @@ export const K8SResourceList = ({
197
204
[ resourceList ?. data ] ,
198
205
)
199
206
200
- const handleClearCacheAndReload = ( ) => {
201
- reloadResourceList ( )
202
- }
203
-
204
207
const tableFilter : TableProps [ 'filter' ] = ( row , filterData ) => {
205
208
if ( isNodeListing ) {
206
209
return isItemASearchMatchForNodeListing ( row . data , filterData )
@@ -234,66 +237,87 @@ export const K8SResourceList = ({
234
237
return columns . some ( ( { field } ) => field === 'namespace' ) ? 'namespace' : 'name'
235
238
}
236
239
240
+ if ( resourceListError && ! isResourceListLoading ) {
241
+ return (
242
+ < div className = "flexbox-col flex-grow-1 border__primary--left" >
243
+ < ErrorScreenManager
244
+ code = { ( resourceListError as ServerErrors ) . code }
245
+ reload = { reloadResourceList }
246
+ redirectURL = { URLS . RESOURCE_BROWSER }
247
+ />
248
+ </ div >
249
+ )
250
+ }
251
+
237
252
return (
238
- < Table
239
- loading = { resourceListLoader || ! resourceList }
240
- columns = { columns }
241
- rows = { rows }
242
- { ...( RBBulkSelectionActions && ! isEventListing
243
- ? {
244
- bulkSelectionConfig : {
245
- BulkActionsComponent : RBBulkSelectionActions ,
246
- getSelectAllDialogStatus : ( ) => SelectAllDialogStatus . CLOSED ,
247
- BulkOperationModal : RBBulkOperations ,
248
- bulkOperationModalData : {
249
- selectedResource,
250
- isNodeListing,
251
- getManifestResource,
252
- updateManifestResourceHelmApps,
253
- clusterId : + clusterId ,
254
- clusterName : selectedCluster ?. label ?? '' ,
255
- handleReloadDataAfterBulkOperation : handleClearCacheAndReload ,
256
- } ,
257
- bulkActionsData : {
258
- showBulkRestartOption :
259
- window . _env_ . FEATURE_BULK_RESTART_WORKLOADS_FROM_RB . split ( ',' )
260
- . map ( ( feat : string ) => feat . trim ( ) . toUpperCase ( ) )
261
- . indexOf ( selectedResource ?. gvk . Kind . toUpperCase ( ) ) > - 1 ,
262
- showNodeListingOptions : isNodeListing ,
253
+ < >
254
+ < Table
255
+ loading = { isResourceListLoading }
256
+ columns = { columns }
257
+ rows = { rows }
258
+ { ...( RBBulkSelectionActions && ! isEventListing
259
+ ? {
260
+ bulkSelectionConfig : {
261
+ BulkActionsComponent : RBBulkSelectionActions ,
262
+ getSelectAllDialogStatus : ( ) => SelectAllDialogStatus . CLOSED ,
263
+ BulkOperationModal : RBBulkOperations ,
264
+ bulkOperationModalData : {
265
+ selectedResource,
266
+ isNodeListing,
267
+ getManifestResource,
268
+ updateManifestResourceHelmApps,
269
+ clusterId : + clusterId ,
270
+ clusterName : selectedCluster ?. label ?? '' ,
271
+ handleReloadDataAfterBulkOperation : reloadResourceList ,
272
+ } ,
273
+ bulkActionsData : {
274
+ showBulkRestartOption :
275
+ window . _env_ . FEATURE_BULK_RESTART_WORKLOADS_FROM_RB . split ( ',' )
276
+ . map ( ( feat : string ) => feat . trim ( ) . toUpperCase ( ) )
277
+ . indexOf ( selectedResource ?. gvk . Kind . toUpperCase ( ) ) > - 1 ,
278
+ showNodeListingOptions : isNodeListing ,
279
+ } ,
263
280
} ,
264
- } ,
265
- }
266
- : { } ) }
267
- emptyStateConfig = { {
268
- noRowsConfig : {
269
- image : emptyCustomChart ,
270
- title : `No ${ selectedResource ?. gvk . Kind ?? 'Resource' } found` ,
271
- subTitle : `We could not find any ${ selectedResource ?. gvk . Kind ?? 'Resource' } . Try selecting a different cluster or namespace.` ,
272
- } ,
273
- } }
274
- filtersVariant = { FiltersTypeEnum . URL }
275
- paginationVariant = { PaginationEnum . PAGINATED }
276
- areColumnsConfigurable = { isNodeListing }
277
- id = "table__gvk-resource-list"
278
- additionalFilterProps = { {
279
- parseSearchParams : parseK8sResourceListSearchParams ,
280
- defaultPageSize : LARGE_PAGE_SIZE_OPTIONS [ 0 ] . value ,
281
- initialSortKey : getDefaultSortKey ( ) ,
282
- } }
283
- ViewWrapper = { K8SResourceListViewWrapper }
284
- filter = { tableFilter }
285
- additionalProps = { {
286
- renderRefreshBar,
287
- selectedResource,
288
- selectedCluster,
289
- addTab,
290
- isNodeListing,
291
- isEventListing,
292
- lowercaseKindToResourceGroupMap,
293
- reloadResourceListData : handleClearCacheAndReload ,
294
- clusterName : selectedCluster ?. label ?? '' ,
295
- } }
296
- pageSizeOptions = { ! isNodeListing ? LARGE_PAGE_SIZE_OPTIONS : undefined }
297
- />
281
+ }
282
+ : { } ) }
283
+ emptyStateConfig = { {
284
+ noRowsConfig : {
285
+ image : emptyCustomChart ,
286
+ title : `No ${ selectedResource ?. gvk . Kind ?? 'Resource' } found` ,
287
+ subTitle : `We could not find any ${ selectedResource ?. gvk . Kind ?? 'Resource' } . Try selecting a different cluster or namespace.` ,
288
+ } ,
289
+ } }
290
+ filtersVariant = { FiltersTypeEnum . URL }
291
+ paginationVariant = { PaginationEnum . PAGINATED }
292
+ areColumnsConfigurable = { isNodeListing }
293
+ id = "table__gvk-resource-list"
294
+ additionalFilterProps = { {
295
+ parseSearchParams : parseK8sResourceListSearchParams ,
296
+ defaultPageSize : LARGE_PAGE_SIZE_OPTIONS [ 0 ] . value ,
297
+ initialSortKey : getDefaultSortKey ( ) ,
298
+ } }
299
+ ViewWrapper = { K8SResourceListViewWrapper }
300
+ filter = { tableFilter }
301
+ additionalProps = { {
302
+ renderRefreshBar,
303
+ selectedResource,
304
+ selectedCluster,
305
+ addTab,
306
+ isNodeListing,
307
+ isEventListing,
308
+ lowercaseKindToResourceGroupMap,
309
+ reloadResourceListData : reloadResourceList ,
310
+ clusterName : selectedCluster ?. label ?? '' ,
311
+ } }
312
+ pageSizeOptions = { ! isNodeListing ? LARGE_PAGE_SIZE_OPTIONS : undefined }
313
+ />
314
+
315
+ { PodRestart && (
316
+ < PodRestart
317
+ aiWidgetAnalyticsEvent = { getAIAnalyticsEvents ( 'RB_POD_RESTART' ) }
318
+ rbacPayload = { getPodRestartRBACPayload ( ) }
319
+ />
320
+ ) }
321
+ </ >
298
322
)
299
323
}
0 commit comments