Skip to content

Commit 151d1d1

Browse files
authored
Merge pull request #2796 from devtron-labs/fix/rb-table
fix: rb table
2 parents 86cea83 + 0c1173b commit 151d1d1

21 files changed

+176
-203
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.16.0-pre-4",
7+
"@devtron-labs/devtron-fe-common-lib": "1.16.0-beta-6",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/components/ClusterNodes/ClusterList/ClusterListRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import {
1212
ConditionalWrap,
1313
Icon,
1414
InstallationClusterStatus,
15+
RESOURCE_BROWSER_ROUTES,
1516
Tooltip,
1617
useBulkSelection,
1718
} from '@devtron-labs/devtron-fe-common-lib'
1819

1920
import { ReactComponent as Error } from '@Icons/ic-error-exclamation.svg'
2021
import { importComponentFromFELibrary } from '@Components/common'
21-
import { RESOURCE_BROWSER_ROUTES } from '@Components/ResourceBrowser/Constants'
2222
import { getClusterChangeRedirectionUrl } from '@Components/ResourceBrowser/Utils'
2323

2424
import { ClusterMapInitialStatus } from '../ClusterMapInitialStatus'

src/components/ClusterNodes/ClusterOverview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import React, { useEffect, useRef, useState } from 'react'
1818
import { generatePath, useHistory, useParams } from 'react-router-dom'
1919

2020
import {
21+
DUMMY_RESOURCE_GVK_VERSION,
2122
EditableTextArea,
2223
ErrorScreenManager,
2324
getRandomColor,
@@ -26,6 +27,7 @@ import {
2627
InfoIconTippy,
2728
InstallationClusterConfigType,
2829
noop,
30+
RESOURCE_BROWSER_ROUTES,
2931
ResourceKindType,
3032
showError,
3133
StatusComponent,
@@ -43,9 +45,7 @@ import { MAX_LENGTH_350 } from '../../config/constantMessaging'
4345
import { importComponentFromFELibrary } from '../common'
4446
import GenericDescription from '../common/Description/GenericDescription'
4547
import {
46-
DUMMY_RESOURCE_GVK_VERSION,
4748
K8S_EMPTY_GROUP,
48-
RESOURCE_BROWSER_ROUTES,
4949
SIDEBAR_KEYS,
5050
TARGET_K8S_VERSION_SEARCH_KEY,
5151
UPGRADE_CLUSTER_CONSTANTS,

src/components/ResourceBrowser/Constants.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { NO_MATCHING_RESULT, Nodes, URLS } from '@devtron-labs/devtron-fe-common-lib'
17+
import {
18+
K8S_EMPTY_GROUP as K8S_EMPTY_GROUP_FROM_COMMON,
19+
NO_MATCHING_RESULT,
20+
Nodes,
21+
RESOURCE_BROWSER_ROUTES,
22+
} from '@devtron-labs/devtron-fe-common-lib'
1823

1924
import ICArrowUpCircle from '@Icons/ic-arrow-up-circle.svg'
2025

@@ -110,7 +115,10 @@ export const RESOURCE_ACTION_MENU = {
110115
delete: 'delete',
111116
}
112117

113-
export const K8S_EMPTY_GROUP = 'k8sEmptyGroup'
118+
/**
119+
* @deprecated Use from common-lib instead
120+
*/
121+
export const K8S_EMPTY_GROUP = K8S_EMPTY_GROUP_FROM_COMMON
114122
export const NAMESPACE_NOT_APPLICABLE_OPTION = {
115123
label: 'Namespace: Not applicable',
116124
value: 'not-applicable',
@@ -386,19 +394,6 @@ export const AI_BUTTON_CONFIG_MAP: Record<string, ShowAIButtonConfig> = Object.f
386394
},
387395
})
388396

389-
export const RESOURCE_BROWSER_ROUTES = {
390-
OVERVIEW: `${URLS.RESOURCE_BROWSER}/:clusterId/overview`,
391-
MONITORING_DASHBOARD: `${URLS.RESOURCE_BROWSER}/:clusterId/monitoring-dashboard`,
392-
TERMINAL: `${URLS.RESOURCE_BROWSER}/:clusterId/terminal`,
393-
CLUSTER_UPGRADE: `${URLS.RESOURCE_BROWSER}/:clusterId/cluster-upgrade`,
394-
NODE_DETAIL: `${URLS.RESOURCE_BROWSER}/:clusterId/node/:name`,
395-
K8S_RESOURCE_DETAIL: `${URLS.RESOURCE_BROWSER}/:clusterId/:namespace/:kind/:group/:version/:name`,
396-
K8S_RESOURCE_LIST: `${URLS.RESOURCE_BROWSER}/:clusterId/:kind/:group/:version`,
397-
RESOURCE_RECOMMENDER: `${URLS.RESOURCE_BROWSER}/:clusterId/resource-recommender`,
398-
} as const
399-
400-
export const DUMMY_RESOURCE_GVK_VERSION = 'v1'
401-
402397
export const ResourceBrowserRouteToTabIdMap: Partial<
403398
Record<(typeof RESOURCE_BROWSER_ROUTES)[keyof typeof RESOURCE_BROWSER_ROUTES], ResourceBrowserTabsId | string>
404399
> = {

src/components/ResourceBrowser/ResourceList/ClusterUpgradeCompatibilityInfoTableCellComponent.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@ import DOMPurify from 'dompurify'
55
import {
66
ALL_NAMESPACE_OPTION,
77
ClipboardButton,
8+
DUMMY_RESOURCE_GVK_VERSION,
89
GVKType,
910
highlightSearchText,
1011
K8sResourceDetailDataType,
1112
Nodes,
1213
noop,
14+
RESOURCE_BROWSER_ROUTES,
1315
TableSignalEnum,
1416
Tooltip,
1517
} from '@devtron-labs/devtron-fe-common-lib'
1618

17-
import {
18-
DUMMY_RESOURCE_GVK_VERSION,
19-
K8S_EMPTY_GROUP,
20-
RESOURCE_ACTION_MENU,
21-
RESOURCE_BROWSER_ROUTES,
22-
} from '../Constants'
19+
import { K8S_EMPTY_GROUP, RESOURCE_ACTION_MENU } from '../Constants'
2320
import { ClusterDetailBaseParams } from '../Types'
2421
import { renderResourceValue } from '../Utils'
2522
import ResourceBrowserActionMenu from './ResourceBrowserActionMenu'

src/components/ResourceBrowser/ResourceList/DynamicTabComponentWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { cloneElement, ReactElement, useEffect } from 'react'
22
import { useLocation, useParams, useRouteMatch } from 'react-router-dom'
33

4-
import { logExceptionToSentry, noop } from '@devtron-labs/devtron-fe-common-lib'
4+
import { logExceptionToSentry, noop, RESOURCE_BROWSER_ROUTES } from '@devtron-labs/devtron-fe-common-lib'
55

6-
import { RESOURCE_BROWSER_ROUTES, UPGRADE_CLUSTER_CONSTANTS } from '../Constants'
6+
import { UPGRADE_CLUSTER_CONSTANTS } from '../Constants'
77
import { DynamicTabComponentWrapperProps } from './types'
88
import { getTabIdForTab, getTabIdParamsForPath, getUpgradeCompatibilityTippyConfig } from './utils'
99

src/components/ResourceBrowser/ResourceList/K8SResourceList.tsx

Lines changed: 90 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@ import { useLocation, useParams } from 'react-router-dom'
1919

2020
import {
2121
abortPreviousRequests,
22+
ErrorScreenManager,
2223
FiltersTypeEnum,
24+
getAIAnalyticsEvents,
25+
getIsRequestAborted,
2326
LARGE_PAGE_SIZE_OPTIONS,
2427
Nodes,
2528
PaginationEnum,
2629
SelectAllDialogStatus,
30+
ServerErrors,
2731
Table,
2832
TableColumnType,
2933
TableProps,
34+
URLS,
3035
useAsync,
3136
useUrlFilters,
3237
} from '@devtron-labs/devtron-fe-common-lib'
@@ -35,6 +40,7 @@ import emptyCustomChart from '@Images/[email protected]'
3540
import { importComponentFromFELibrary } from '@Components/common'
3641
import {
3742
getManifestResource,
43+
getPodRestartRBACPayload,
3844
updateManifestResourceHelmApps,
3945
} from '@Components/v2/appDetails/k8Resource/nodeDetail/nodeDetail.api'
4046

@@ -59,6 +65,7 @@ const RESOURCE_FILTER_KEYS: Record<string, unknown> = importComponentFromFELibra
5965
)
6066
const RBBulkSelectionActions = importComponentFromFELibrary('RBBulkSelectionActions', null, 'function')
6167
const RBBulkOperations = importComponentFromFELibrary('RBBulkOperations', null, 'function')
68+
const PodRestart = importComponentFromFELibrary('PodRestart')
6269

6370
const K8SResourceListViewWrapper = ({
6471
children,
@@ -136,7 +143,7 @@ export const K8SResourceList = ({
136143
}, {})
137144
: null
138145

139-
const [resourceListLoader, resourceList, , reloadResourceList] = useAsync(
146+
const [resourceListLoader, resourceList, resourceListError, reloadResourceList] = useAsync(
140147
() =>
141148
abortPreviousRequests(async () => {
142149
if (selectedResource) {
@@ -152,10 +159,10 @@ export const K8SResourceList = ({
152159
return null
153160
}, abortControllerRef),
154161
[selectedResource, clusterId, selectedNamespace, JSON.stringify(resourceFilters)],
155-
true,
156-
{ resetOnChange: false },
157162
)
158163

164+
const isResourceListLoading = !resourceList || resourceListLoader || getIsRequestAborted(resourceListError)
165+
159166
useEffect(
160167
() => () => {
161168
abortControllerRef.current?.abort()
@@ -197,10 +204,6 @@ export const K8SResourceList = ({
197204
[resourceList?.data],
198205
)
199206

200-
const handleClearCacheAndReload = () => {
201-
reloadResourceList()
202-
}
203-
204207
const tableFilter: TableProps['filter'] = (row, filterData) => {
205208
if (isNodeListing) {
206209
return isItemASearchMatchForNodeListing(row.data, filterData)
@@ -234,66 +237,87 @@ export const K8SResourceList = ({
234237
return columns.some(({ field }) => field === 'namespace') ? 'namespace' : 'name'
235238
}
236239

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+
237252
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+
},
263280
},
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+
</>
298322
)
299323
}

0 commit comments

Comments
 (0)