Skip to content

Commit 4be2c97

Browse files
committed
fix: uat changes
1 parent 2a4ca3d commit 4be2c97

14 files changed

+66
-81
lines changed

src/components/ClusterNodes/NodeActions/DeleteNodeModal.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
deleteNodeCapacity,
2323
} from '@devtron-labs/devtron-fe-common-lib'
2424

25-
import Cache from '@Components/ResourceBrowser/ResourceList/Cache'
2625
import { DeleteComponentsName } from '@Config/constantMessaging'
2726

2827
import { DeleteNodeModalProps } from '../types'
@@ -42,7 +41,6 @@ const DeleteNodeModal = ({ name, version, kind, closePopup, handleClearBulkSelec
4241
kind,
4342
}
4443
await deleteNodeCapacity(payload)
45-
Cache.clear()
4644
handleClearBulkSelection()
4745
closePopup(true)
4846
}

src/components/ResourceBrowser/Constants.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ export const KIND_SEARCH_COMMON_STYLES = {
103103
}
104104

105105
export const RESOURCE_ACTION_MENU = {
106-
manifest: 'Manifest',
107-
Events: 'Events',
108-
logs: 'Logs',
109-
terminal: 'Terminal',
110-
delete: 'Delete',
106+
manifest: 'manifest',
107+
Events: 'events',
108+
logs: 'logs',
109+
terminal: 'terminal',
110+
delete: 'delete',
111111
}
112112

113113
export const K8S_EMPTY_GROUP = 'k8sEmptyGroup'
@@ -312,7 +312,7 @@ export const NODE_LIST_HEADERS_TO_KEY_MAP: Record<(typeof NODE_LIST_HEADERS)[num
312312
'cpu usage (absolute)': 'cpu.usage',
313313
'cpu allocatable': 'cpu.allocatable',
314314
'mem usage (%)': 'memory.usagePercentage',
315-
'mem usage (absolute)': 'memory.usageInBytes',
315+
'mem usage (absolute)': 'memory.usage',
316316
'mem allocatable': 'memory.allocatable',
317317
age: 'age',
318318
unschedulable: 'unschedulable',

src/components/ResourceBrowser/ResourceList/Cache.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/components/ResourceBrowser/ResourceList/ColumnSelector.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ import {
2323
SelectPicker,
2424
SelectPickerOptionType,
2525
TableColumnType,
26+
useTriggerAutoClickTimestamp,
2627
} from '@devtron-labs/devtron-fe-common-lib'
2728

2829
import { OPTIONAL_NODE_LIST_HEADERS } from '../Constants'
2930
import { ColumnSelectorType } from '../Types'
3031

3132
const ColumnSelector = ({ setVisibleColumns, visibleColumns, allColumns }: ColumnSelectorType) => {
33+
const { triggerAutoClickTimestamp, setTriggerAutoClickTimestampToNow, resetTriggerAutoClickTimestamp } =
34+
useTriggerAutoClickTimestamp()
35+
3236
const columnOptions = useMemo(() => {
3337
const headerToColumnMap = allColumns.reduce((acc, column) => {
3438
acc[column.label] = column
@@ -42,8 +46,8 @@ const ColumnSelector = ({ setVisibleColumns, visibleColumns, allColumns }: Colum
4246
}, [])
4347

4448
const [isMenuOpen, setIsMenuOpen] = useState(false)
45-
const [selectedColumns, setSelectedColumns] = useState<MultiValue<SelectPickerOptionType<TableColumnType>>>(
46-
visibleColumns.map((column) => ({ value: column, label: column.label })),
49+
const [selectedColumns, setSelectedColumns] = useState<MultiValue<SelectPickerOptionType<TableColumnType>>>(() =>
50+
columnOptions.filter((option) => visibleColumns.find(({ label }) => label === option.label)),
4751
)
4852

4953
const selectRef = useRef<SelectInstance<SelectPickerOptionType<TableColumnType>, true>>(null)
@@ -56,10 +60,16 @@ const ColumnSelector = ({ setVisibleColumns, visibleColumns, allColumns }: Colum
5660

5761
const handleMenuClose = () => {
5862
setIsMenuOpen(false)
63+
resetTriggerAutoClickTimestamp()
5964

6065
selectRef.current?.blur()
6166
}
6267

68+
const onChange = (newValue: MultiValue<SelectPickerOptionType<TableColumnType>>) => {
69+
setTriggerAutoClickTimestampToNow()
70+
setSelectedColumns(newValue)
71+
}
72+
6373
const handleApplySelectedColumns = (): void => {
6474
setIsMenuOpen(false)
6575

@@ -91,7 +101,7 @@ const ColumnSelector = ({ setVisibleColumns, visibleColumns, allColumns }: Colum
91101
onMenuOpen={handleMenuOpen}
92102
onMenuClose={handleMenuClose}
93103
isMulti
94-
onChange={setSelectedColumns}
104+
onChange={onChange}
95105
placeholder="Column"
96106
options={columnOptions}
97107
value={selectedColumns}
@@ -102,6 +112,7 @@ const ColumnSelector = ({ setVisibleColumns, visibleColumns, allColumns }: Colum
102112
onClick: handleApplySelectedColumns,
103113
variant: ButtonVariantType.primary,
104114
dataTestId: 'apply-column-selector',
115+
triggerAutoClickTimestamp,
105116
},
106117
}}
107118
isClearable={false}

src/components/ResourceBrowser/ResourceList/DeleteResourcePopup.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
} from '@devtron-labs/devtron-fe-common-lib'
2727

2828
import { DeleteResourcePopupType } from '../Types'
29-
import Cache from './Cache'
3029

3130
const DeleteResourcePopup: React.FC<DeleteResourcePopupType> = ({
3231
clusterId,
@@ -55,7 +54,6 @@ const DeleteResourcePopup: React.FC<DeleteResourcePopupType> = ({
5554

5655
await deleteResource(resourceDeletePayload)
5756
await getResourceListData()
58-
Cache.clear()
5957
handleClearBulkSelection()
6058
if (removeTabByIdentifier) {
6159
removeTabByIdentifier(

src/components/ResourceBrowser/ResourceList/K8SResourceList.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040
import { NODE_LIST_HEADERS_TO_KEY_MAP, RESOURCE_PAGE_SIZE_OPTIONS } from '../Constants'
4141
import { getResourceData } from '../ResourceBrowser.service'
4242
import { K8SResourceListType } from '../Types'
43-
import Cache from './Cache'
4443
import K8sResourceListTableCellComponent from './K8sResourceListTableCellComponent'
4544
import NodeListSearchFilter from './NodeListSearchFilter'
4645
import ResourceFilterOptions from './ResourceFilterOptions'
@@ -73,7 +72,7 @@ const K8SResourceListViewWrapper = ({
7372
allColumns,
7473
setVisibleColumns,
7574
updateSearchParams,
76-
eventType,
75+
eventType = 'warning',
7776
...restProps
7877
}: K8SResourceListViewWrapperProps) => (
7978
<div className="flexbox-col flex-grow-1 resource-list-container dc__overflow-hidden border__primary--left">
@@ -138,15 +137,13 @@ export const K8SResourceList = ({
138137
() =>
139138
abortPreviousRequests(async () => {
140139
if (selectedResource) {
141-
return Cache.get(`${location.pathname}${location.search}`, () =>
142-
getResourceData({
143-
selectedResource,
144-
selectedNamespace,
145-
clusterId,
146-
filters: resourceFilters,
147-
abortControllerRef,
148-
}),
149-
)
140+
return getResourceData({
141+
selectedResource,
142+
selectedNamespace,
143+
clusterId,
144+
filters: resourceFilters,
145+
abortControllerRef,
146+
})
150147
}
151148

152149
return null
@@ -198,7 +195,6 @@ export const K8SResourceList = ({
198195
)
199196

200197
const handleClearCacheAndReload = () => {
201-
Cache.clear()
202198
reloadResourceList()
203199
}
204200

@@ -217,7 +213,7 @@ export const K8SResourceList = ({
217213
if (isEventListing) {
218214
return (
219215
(row.data.type as string)?.toLowerCase() ===
220-
(filterData as unknown as K8sResourceListFilterType).eventType && isSearchMatch
216+
((filterData as unknown as K8sResourceListFilterType).eventType ?? 'warning') && isSearchMatch
221217
)
222218
}
223219

@@ -266,7 +262,7 @@ export const K8SResourceList = ({
266262
emptyStateConfig={{
267263
noRowsConfig: {
268264
image: emptyCustomChart,
269-
title: 'No resources found',
265+
title: `No ${selectedResource?.gvk.Kind ?? 'Resource'} found`,
270266
subTitle: `We could not find any ${selectedResource?.gvk.Kind ?? 'Resource'}. Try selecting a different cluster or namespace.`,
271267
},
272268
}}

src/components/ResourceBrowser/ResourceList/K8SResourceTabComponent.tsx

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

17-
import { useMemo, useRef } from 'react'
17+
import { useEffect, useMemo, useRef } from 'react'
1818
import { useParams } from 'react-router-dom'
1919

2020
import { abortPreviousRequests, ErrorScreenManager, useAsync } from '@devtron-labs/devtron-fe-common-lib'
2121

22-
import { K8S_EMPTY_GROUP } from '../Constants'
22+
import { K8S_EMPTY_GROUP, ResourceBrowserTabsId } from '../Constants'
2323
import { getResourceGroupList } from '../ResourceBrowser.service'
2424
import { K8SResourceTabComponentProps } from '../Types'
25-
import Cache from './Cache'
2625
import ConnectingToClusterState from './ConnectingToClusterState'
2726
import { K8SResourceList } from './K8SResourceList'
2827
import Sidebar from './Sidebar'
@@ -35,11 +34,17 @@ const K8SResourceTabComponent = ({
3534
updateK8sResourceTab,
3635
clusterName,
3736
lowercaseKindToResourceGroupMap,
37+
updateTabLastSyncMoment,
3838
}: K8SResourceTabComponentProps) => {
3939
const { clusterId, kind, group } = useParams<K8sResourceListURLParams>()
4040

4141
const abortControllerRef = useRef(new AbortController())
4242

43+
useEffect(() => {
44+
// TODO: once we get tab retention logic, we can remove this
45+
updateTabLastSyncMoment(ResourceBrowserTabsId.k8s_Resources)
46+
}, [])
47+
4348
const selectedResource = useMemo(
4449
() => lowercaseKindToResourceGroupMap?.[`${group === K8S_EMPTY_GROUP ? '' : group}-${kind}`.toLowerCase()],
4550
[lowercaseKindToResourceGroupMap, kind, group],
@@ -48,10 +53,7 @@ const K8SResourceTabComponent = ({
4853
const [loading, k8SObjectMap, error, reload] = useAsync(
4954
() =>
5055
abortPreviousRequests(
51-
() =>
52-
Cache.get(`${clusterId}/k8s-object-map`, () =>
53-
getResourceGroupList(clusterId, abortControllerRef.current?.signal),
54-
),
56+
() => getResourceGroupList(clusterId, abortControllerRef.current?.signal),
5557
abortControllerRef,
5658
),
5759
[clusterId],
@@ -81,6 +83,7 @@ const K8SResourceTabComponent = ({
8183
apiResources={k8SObjectMap?.result.apiResources || null}
8284
selectedResource={selectedResource}
8385
updateK8sResourceTab={updateK8sResourceTab}
86+
updateTabLastSyncMoment={updateTabLastSyncMoment}
8487
/>
8588
<K8SResourceList
8689
clusterName={clusterName}

src/components/ResourceBrowser/ResourceList/NodeListSearchFilter.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,17 @@ const NodeListSearchFilter = ({
312312

313313
<div className="dc__border-left h-20 mt-6" />
314314

315-
<ColumnSelector
316-
{...{
317-
setVisibleColumns,
318-
visibleColumns,
319-
allColumns,
320-
}}
321-
/>
315+
{allColumns.length ? (
316+
<ColumnSelector
317+
{...{
318+
setVisibleColumns,
319+
visibleColumns,
320+
allColumns,
321+
}}
322+
/>
323+
) : (
324+
<div className="shimmer h-32" />
325+
)}
322326
</div>
323327
)
324328
}

src/components/ResourceBrowser/ResourceList/ResourceBrowserActionMenu.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,24 @@ const ResourceBrowserActionMenu = forwardRef(
151151
items: [
152152
{
153153
id: RESOURCE_ACTION_MENU.manifest,
154-
label: RESOURCE_ACTION_MENU.manifest,
154+
label: 'Manifest',
155155
startIcon: { name: 'ic-file-code' },
156156
},
157157
{
158158
id: RESOURCE_ACTION_MENU.Events,
159-
label: RESOURCE_ACTION_MENU.Events,
159+
label: 'Events',
160160
startIcon: { name: 'ic-calendar' },
161161
},
162162
...(selectedResource?.gvk?.Kind === Nodes.Pod
163163
? [
164164
{
165165
id: RESOURCE_ACTION_MENU.logs,
166-
label: RESOURCE_ACTION_MENU.logs,
166+
label: 'Logs',
167167
startIcon: { name: 'ic-logs' },
168168
} as ActionMenuItemType,
169169
{
170170
id: RESOURCE_ACTION_MENU.terminal,
171-
label: RESOURCE_ACTION_MENU.terminal,
171+
label: 'Terminal',
172172
startIcon: { name: 'ic-terminal-fill' },
173173
} as ActionMenuItemType,
174174
]
@@ -186,7 +186,7 @@ const ResourceBrowserActionMenu = forwardRef(
186186
? [
187187
{
188188
id: RESOURCE_ACTION_MENU.delete,
189-
label: RESOURCE_ACTION_MENU.delete,
189+
label: 'Delete',
190190
type: 'negative',
191191
startIcon: { name: 'ic-delete' },
192192
} as ActionMenuItemType,

src/components/ResourceBrowser/ResourceList/ResourceFilterOptions.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import { ShortcutKeyBadge } from '../../common/formFields/Widgets/Widgets'
4040
import { NAMESPACE_NOT_APPLICABLE_OPTION, NAMESPACE_NOT_APPLICABLE_TEXT } from '../Constants'
4141
import { namespaceListByClusterId } from '../ResourceBrowser.service'
4242
import { ResourceFilterOptionsProps } from '../Types'
43-
import Cache from './Cache'
4443
import { K8sResourceListURLParams } from './types'
4544

4645
const FilterButton = importComponentFromFELibrary('FilterButton', null, 'function')
@@ -71,10 +70,7 @@ const ResourceFilterOptions = ({
7170

7271
const showShortcutKey = !isInputFocused && !searchText
7372

74-
const [, namespaceByClusterIdList] = useAsync(
75-
() => Cache.get(`${clusterId}/namespaces`, () => namespaceListByClusterId(clusterId)),
76-
[clusterId],
77-
)
73+
const [, namespaceByClusterIdList] = useAsync(() => namespaceListByClusterId(clusterId), [clusterId])
7874

7975
const namespaceOptions = useMemo(
8076
() => [ALL_NAMESPACE_OPTION, ...convertToOptionsList(namespaceByClusterIdList?.result?.sort() || [])],

0 commit comments

Comments
 (0)