Skip to content

Commit e160c00

Browse files
committed
feat: enable FEATURE_REDFISH_NODE in environment configuration and update NodeDetails component to include Redfish node tabs
1 parent e11c308 commit e160c00

File tree

3 files changed

+44
-57
lines changed

3 files changed

+44
-57
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ FEATURE_DEFAULT_AUTHENTICATED_VIEW_ENABLE=false
6666
GATEKEEPER_URL=https://license.devtron.ai/dashboard
6767
FEATURE_AI_INTEGRATION_ENABLE=false
6868
LOGIN_PAGE_IMAGE=
69+
FEATURE_REDFISH_NODE_ENABLE=false

src/components/ClusterNodes/NodeDetails.tsx

Lines changed: 42 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ import { AppDetailsTabs } from '../v2/appDetails/appDetails.store'
7878
import { unauthorizedInfoText } from '../ResourceBrowser/ResourceList/ClusterSelector'
7979
import './clusterNodes.scss'
8080
import ResourceBrowserActionMenu from '../ResourceBrowser/ResourceList/ResourceBrowserActionMenu'
81+
import { importComponentFromFELibrary } from '@Components/common'
82+
83+
const REDFISH_NODE_UI_TABS = importComponentFromFELibrary('REDFISH_NODE_UI_TABS', [], 'function')
8184

8285
const NodeDetails = ({ addTab, lowercaseKindToResourceGroupMap, updateTabUrl }: ClusterListType) => {
8386
const { clusterId, node } = useParams<{ clusterId: string; nodeType: string; node: string }>()
@@ -152,20 +155,36 @@ const NodeDetails = ({ addTab, lowercaseKindToResourceGroupMap, updateTabUrl }:
152155
getData(patchData)
153156
}, [node])
154157

158+
const getSanitizedNodeTabId = (id: string) => id.toLowerCase().replace(' ', '-')
159+
160+
// id will be populated into url
161+
const NODE_TABS_INFO: (Pick<TabProps, 'label' | 'icon'> & { id: string })[] = [
162+
{
163+
id: getSanitizedNodeTabId(NODE_DETAILS_TABS.summary),
164+
label: NODE_DETAILS_TABS.summary,
165+
},
166+
{
167+
id: getSanitizedNodeTabId(NODE_DETAILS_TABS.yaml),
168+
label: NODE_DETAILS_TABS.yaml,
169+
icon: Edit,
170+
},
171+
{
172+
id: getSanitizedNodeTabId(NODE_DETAILS_TABS.nodeConditions),
173+
label: NODE_DETAILS_TABS.nodeConditions,
174+
},
175+
...REDFISH_NODE_UI_TABS,
176+
]
177+
155178
useEffect(() => {
156-
if (queryParams.has('tab')) {
157-
const tab = queryParams.get('tab').replace('-', ' ')
158-
if (tab === NODE_DETAILS_TABS.summary.toLowerCase()) {
159-
setSelectedTabIndex(0)
160-
} else if (tab === NODE_DETAILS_TABS.yaml.toLowerCase()) {
161-
setSelectedTabIndex(1)
162-
} else if (tab === NODE_DETAILS_TABS.nodeConditions.toLowerCase()) {
163-
setSelectedTabIndex(2)
164-
}
179+
const tab = queryParams.get('tab')
180+
const tabIndex = NODE_TABS_INFO.findIndex((tabDetails) => tabDetails.id === tab)
181+
182+
if (tabIndex !== -1) {
183+
setSelectedTabIndex(tabIndex)
165184
} else {
166185
replace({
167186
pathname: location.pathname,
168-
search: `?tab=${NODE_DETAILS_TABS.summary.toLowerCase()}`,
187+
search: `?tab=${getSanitizedNodeTabId(NODE_DETAILS_TABS.summary)}`,
169188
})
170189
}
171190
}, [location.search])
@@ -182,58 +201,26 @@ const NodeDetails = ({ addTab, lowercaseKindToResourceGroupMap, updateTabUrl }:
182201
const changeNodeTab = (e): void => {
183202
const _tabIndex = Number(e.currentTarget.dataset.tabIndex)
184203
if (node !== AUTO_SELECT.value) {
185-
let _searchParam = '?tab='
186-
if (_tabIndex === 0) {
187-
_searchParam += NODE_DETAILS_TABS.summary.toLowerCase()
188-
} else if (_tabIndex === 1) {
189-
_searchParam += NODE_DETAILS_TABS.yaml.toLowerCase()
190-
} else if (_tabIndex === 2) {
191-
_searchParam += NODE_DETAILS_TABS.nodeConditions.toLowerCase().replace(' ', '-')
192-
}
204+
const selectedTab = NODE_TABS_INFO[_tabIndex]?.id || ''
205+
const _searchParam = `?tab=${selectedTab}`
206+
193207
updateTabUrl({
194208
url: `${location.pathname}${_searchParam}`,
195209
})
196210
}
197211
}
198212

199213
const renderNodeDetailsTabs = (): JSX.Element => {
200-
const tabs: TabProps[] = [
201-
{
202-
id: NODE_DETAILS_TABS.summary,
203-
label: NODE_DETAILS_TABS.summary,
204-
tabType: 'navLink',
205-
props: {
206-
to: `?tab=${NODE_DETAILS_TABS.summary.toLowerCase()}`,
207-
onClick: changeNodeTab,
208-
isActive: (_, { search }) => search === `?tab=${NODE_DETAILS_TABS.summary.toLowerCase()}`,
209-
['data-tab-index']: 0,
210-
},
214+
const tabs: TabProps[] = NODE_TABS_INFO.map((tabDetails, index) => ({
215+
...tabDetails,
216+
tabType: 'navLink',
217+
props: {
218+
to: `?tab=${tabDetails.id}`,
219+
onClick: changeNodeTab,
220+
isActive: (_, { search }) => search === `?tab=${tabDetails.id}`,
221+
['data-tab-index']: index,
211222
},
212-
{
213-
id: NODE_DETAILS_TABS.yaml,
214-
label: NODE_DETAILS_TABS.yaml,
215-
tabType: 'navLink',
216-
icon: Edit,
217-
props: {
218-
to: `?tab=${NODE_DETAILS_TABS.yaml.toLowerCase()}`,
219-
onClick: changeNodeTab,
220-
isActive: (_, { search }) => search === `?tab=${NODE_DETAILS_TABS.yaml.toLowerCase()}`,
221-
['data-tab-index']: 1,
222-
},
223-
},
224-
{
225-
id: NODE_DETAILS_TABS.nodeConditions,
226-
label: NODE_DETAILS_TABS.nodeConditions,
227-
tabType: 'navLink',
228-
props: {
229-
to: `?tab=${NODE_DETAILS_TABS.nodeConditions.toLowerCase().replace(' ', '-')}`,
230-
onClick: changeNodeTab,
231-
isActive: (_, { search }) =>
232-
search === `?tab=${NODE_DETAILS_TABS.nodeConditions.toLowerCase().replace(' ', '-')}`,
233-
['data-tab-index']: 2,
234-
},
235-
},
236-
]
223+
}))
237224

238225
return (
239226
<div className="pl-20 dc__border-bottom flex dc__gap-16">
@@ -799,8 +786,7 @@ const NodeDetails = ({ addTab, lowercaseKindToResourceGroupMap, updateTabUrl }:
799786
}
800787
}
801788

802-
const nodeControls = () => {
803-
return (
789+
const nodeControls = () => (
804790
<div className="fw-6 flex dc__content-space flex-grow-1 mr-12">
805791
<div className="flex left">
806792
<span className="flex left fw-6 cb-5 fs-12 cursor" onClick={openDebugTerminal}>
@@ -816,7 +802,6 @@ const NodeDetails = ({ addTab, lowercaseKindToResourceGroupMap, updateTabUrl }:
816802
</span>
817803
</div>
818804
)
819-
}
820805

821806
const renderSummary = (): JSX.Element | null => {
822807
if (!nodeDetail) {

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ if (!window || !window._env_) {
169169
GATEKEEPER_URL: 'https://license.devtron.ai/dashboard',
170170
FEATURE_AI_INTEGRATION_ENABLE: false,
171171
LOGIN_PAGE_IMAGE: '',
172+
FEATURE_REDFISH_NODE_ENABLE: true,
172173
}
173174
}
174175

0 commit comments

Comments
 (0)