Skip to content

Commit 5e44fe5

Browse files
committed
feat: resource recommender using table
1 parent 61b57c2 commit 5e44fe5

11 files changed

+368
-227
lines changed

src/components/ResourceBrowser/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,5 @@ export const ResourceBrowserRouteToTabIdMap: Partial<
412412
'/resource-browser/:clusterId/overview': ResourceBrowserTabsId.cluster_overview,
413413
'/resource-browser/:clusterId/monitoring-dashboard': MONITORING_DASHBOARD_TAB_ID,
414414
'/resource-browser/:clusterId/terminal': ResourceBrowserTabsId.terminal,
415+
'/resource-browser/:clusterId/resource-recommender': RESOURCE_RECOMMENDER_TAB_ID,
415416
}

src/components/ResourceBrowser/ResourceBrowser.scss

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -86,96 +86,6 @@
8686
}
8787
}
8888
}
89-
90-
.scrollable-resource-list {
91-
&__row {
92-
width: max-content;
93-
min-width: 100%;
94-
display: grid;
95-
96-
& > :first-child {
97-
position: sticky;
98-
left: 0;
99-
z-index: 1;
100-
background-color: var(--bg-primary);
101-
border-right: 1px solid var(--border-primary);
102-
padding-left: 20px;
103-
}
104-
105-
&:hover > :first-child {
106-
background-color: var(--bg-hover-opaque);
107-
}
108-
109-
& > :last-child {
110-
padding-right: 20px;
111-
}
112-
113-
&.no-hover-bg {
114-
&:hover > :first-child {
115-
background-color: var(--bg-primary);
116-
}
117-
}
118-
}
119-
}
120-
121-
.scrollable-resource-list,
122-
.scrollable-event-list {
123-
.hover-class {
124-
&:hover {
125-
background-color: var(--bg-hover);
126-
.sticky-column {
127-
background-color: var(--bg-hover);
128-
}
129-
130-
.restart-icon path {
131-
stroke: var(--B500);
132-
}
133-
}
134-
}
135-
}
136-
137-
.pagination-wrapper {
138-
&.resource-browser-paginator {
139-
.select__button {
140-
width: fit-content;
141-
}
142-
}
143-
}
144-
145-
.sticky-column {
146-
left: 0;
147-
z-index: 1;
148-
background-color: var(--bg-primary);
149-
}
150-
151-
.event-list-row {
152-
display: grid;
153-
grid-template-columns: 80px minmax(200px, auto) 130px 200px 150px repeat(3, 70px);
154-
column-gap: 16px;
155-
156-
&__explain {
157-
display: grid;
158-
grid-template-columns: 80px minmax(200px, auto) 130px 150px 150px repeat(4, 70px);
159-
column-gap: 16px;
160-
161-
&:hover {
162-
.explain-ai-button {
163-
visibility: visible;
164-
}
165-
}
166-
167-
.explain-ai-button {
168-
visibility: hidden;
169-
}
170-
171-
}
172-
}
173-
174-
.node-actions-menu-icon {
175-
path:nth-child(2) {
176-
fill: var(--N600);
177-
}
178-
}
17989
}
18090
}
18191

src/components/ResourceBrowser/ResourceBrowser.service.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ export const getResourceData = async ({
9797

9898
const response = k8sResponse.status === 'fulfilled' ? k8sResponse.value : null
9999

100+
if (k8sResponse.status === 'rejected') {
101+
throw k8sResponse.reason
102+
}
103+
100104
if (isNamespaceList && namespaceListResponse?.status === 'fulfilled') {
101105
const { result } = namespaceListResponse.value
102106
const [{ environments }] = result

src/components/ResourceBrowser/ResourceList/ClusterUpgradeCompatibilityInfoTableWrapper.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ComponentProps, useRef, useState } from 'react'
1+
import { ComponentProps, useEffect, useRef, useState } from 'react'
22

3-
import { SearchBar } from '@devtron-labs/devtron-fe-common-lib'
3+
import { SearchBar, useRegisterShortcut } from '@devtron-labs/devtron-fe-common-lib'
44

55
import { ShortcutKeyBadge } from '@Components/common/formFields/Widgets/Widgets'
66

@@ -14,6 +14,8 @@ const ClusterUpgradeCompatibilityInfoTableWrapper = ({
1414
const [isInputFocused, setIsInputFocused] = useState(false)
1515
const searchInputRef = useRef<HTMLInputElement>(null)
1616

17+
const { registerShortcut, unregisterShortcut } = useRegisterShortcut()
18+
1719
const handleInputBlur = () => setIsInputFocused(false)
1820

1921
const handleInputFocus = () => setIsInputFocused(true)
@@ -37,6 +39,15 @@ const ClusterUpgradeCompatibilityInfoTableWrapper = ({
3739
searchInputRef.current?.focus()
3840
}
3941

42+
useEffect(() => {
43+
if (registerShortcut) {
44+
registerShortcut({ keys: ['R'], callback: handleInputShortcut })
45+
}
46+
return (): void => {
47+
unregisterShortcut(['R'])
48+
}
49+
}, [])
50+
4051
return (
4152
<div className="resource-list-container flexbox-col flex-grow-1 border__primary--left dc__overflow-hidden">
4253
<div className="resource-filter-options-container flexbox w-100 px-20 py-16 dc__content-start">

src/components/ResourceBrowser/ResourceList/K8SResourceList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const K8SResourceListViewWrapper = ({
7373
setVisibleColumns,
7474
updateSearchParams,
7575
eventType = 'warning',
76+
filteredRows,
7677
...restProps
7778
}: K8SResourceListViewWrapperProps) => (
7879
<div className="flexbox-col flex-grow-1 resource-list-container dc__overflow-hidden border__primary--left">
@@ -92,9 +93,9 @@ const K8SResourceListViewWrapper = ({
9293
setSearchText={handleSearch}
9394
isSearchInputDisabled={false}
9495
renderRefreshBar={renderRefreshBar}
95-
areFiltersHidden={false}
9696
updateSearchParams={updateSearchParams}
9797
eventType={eventType}
98+
filteredRows={filteredRows}
9899
/>
99100
)}
100101
{children}
@@ -256,7 +257,7 @@ export const K8SResourceList = ({
256257
showBulkRestartOption:
257258
window._env_.FEATURE_BULK_RESTART_WORKLOADS_FROM_RB.split(',')
258259
.map((feat: string) => feat.trim().toUpperCase())
259-
.indexOf(selectedResource.gvk.Kind.toUpperCase()) > -1,
260+
.indexOf(selectedResource?.gvk.Kind.toUpperCase()) > -1,
260261
showNodeListingOptions: isNodeListing,
261262
},
262263
},

0 commit comments

Comments
 (0)