Skip to content

Commit 0c1173b

Browse files
committed
fix: review comments
1 parent 8cd2f52 commit 0c1173b

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

src/components/ResourceBrowser/Constants.ts

Lines changed: 7 additions & 2 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, RESOURCE_BROWSER_ROUTES } 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

@@ -113,7 +118,7 @@ export const RESOURCE_ACTION_MENU = {
113118
/**
114119
* @deprecated Use from common-lib instead
115120
*/
116-
export const K8S_EMPTY_GROUP = 'k8sEmptyGroup'
121+
export const K8S_EMPTY_GROUP = K8S_EMPTY_GROUP_FROM_COMMON
117122
export const NAMESPACE_NOT_APPLICABLE_OPTION = {
118123
label: 'Namespace: Not applicable',
119124
value: 'not-applicable',

src/components/ResourceBrowser/ResourceList/K8SResourceList.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
Table,
3232
TableColumnType,
3333
TableProps,
34+
URLS,
3435
useAsync,
3536
useUrlFilters,
3637
} from '@devtron-labs/devtron-fe-common-lib'
@@ -236,8 +237,16 @@ export const K8SResourceList = ({
236237
return columns.some(({ field }) => field === 'namespace') ? 'namespace' : 'name'
237238
}
238239

239-
if (resourceListError) {
240-
return <ErrorScreenManager code={(resourceListError as ServerErrors).code} />
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+
)
241250
}
242251

243252
return (

src/components/ResourceBrowser/ResourceList/Sidebar.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ const Sidebar = ({ apiResources, selectedResource, updateK8sResourceTab, updateT
106106
const selectNode = (
107107
e: React.MouseEvent<HTMLButtonElement> | { currentTarget: Pick<K8sObjectOptionType, 'dataset'> },
108108
groupName?: string,
109-
shouldPushUrl = true,
110109
): void => {
111110
const _selectedKind = e.currentTarget.dataset.kind.toLowerCase()
112111
const _selectedGroup = e.currentTarget.dataset.group.toLowerCase()
@@ -118,19 +117,23 @@ const Sidebar = ({ apiResources, selectedResource, updateK8sResourceTab, updateT
118117
if (_selectedKind !== Nodes.Event.toLowerCase()) {
119118
params.delete('eventType')
120119
}
121-
const _url = `${generatePath(RESOURCE_BROWSER_ROUTES.K8S_RESOURCE_LIST, {
120+
const path = generatePath(RESOURCE_BROWSER_ROUTES.K8S_RESOURCE_LIST, {
122121
clusterId,
123122
kind: _selectedKind,
124123
group: _selectedGroup || K8S_EMPTY_GROUP,
125124
version: DUMMY_RESOURCE_GVK_VERSION,
126-
})}?${params.toString()}`
125+
})
126+
127+
if (path === location.pathname) {
128+
return
129+
}
130+
131+
const _url = `${path}?${params.toString()}`
127132

128133
updateK8sResourceTab({ url: _url, dynamicTitle: e.currentTarget.dataset.kind, retainSearchParams: true })
129134
updateTabLastSyncMoment(ResourceBrowserTabsId.k8s_Resources)
130135

131-
if (shouldPushUrl) {
132-
push(_url)
133-
}
136+
push(_url)
134137

135138
/**
136139
* If groupName present then kind selection is from search dropdown,
@@ -168,8 +171,6 @@ const Sidebar = ({ apiResources, selectedResource, updateK8sResourceTab, updateT
168171
},
169172
},
170173
match.groupName,
171-
/* NOTE: if we push here the history will be lost */
172-
!selectedResource,
173174
)
174175
}, [kind, k8sObjectOptionsList])
175176

src/components/ResourceBrowser/Utils.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ export const getTabsBasedOnRole = ({
319319
generatePath(RESOURCE_BROWSER_ROUTES.MONITORING_DASHBOARD, {
320320
clusterId,
321321
}),
322-
false,
323322
MONITORING_DASHBOARD_TAB_ID,
324323
),
325324
]

0 commit comments

Comments
 (0)