Skip to content

Commit 4ac4e0f

Browse files
committed
feat: update cost module payload type and enhance subtitle rendering in ClusterForm
1 parent d18a61a commit 4ac4e0f

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm/ClusterForm.components.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ReactNode } from 'react'
2+
13
import { ButtonVariantType, ComponentSizeType, Icon, InfoBlock } from '@devtron-labs/devtron-fe-common-lib'
24

35
export const ClusterFormNavButton = ({
@@ -8,7 +10,7 @@ export const ClusterFormNavButton = ({
810
}: {
911
isActive: boolean
1012
title: string
11-
subtitle?: string
13+
subtitle?: ReactNode
1214
onClick: () => void
1315
}) => (
1416
<button
@@ -17,7 +19,7 @@ export const ClusterFormNavButton = ({
1719
onClick={onClick}
1820
>
1921
<span className={`fs-13 ${isActive ? 'cb-5 fw-6' : 'cn-9'}`}>{title}</span>
20-
{subtitle && <span className="fs-12 cn-7">{subtitle}</span>}
22+
{typeof subtitle === 'string' ? <span className="fs-12 cn-7">{subtitle}</span> : subtitle}
2123
</button>
2224
)
2325

src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm/ClusterForm.tsx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
Button,
2323
ButtonStyleType,
2424
ButtonVariantType,
25-
ClusterCostModuleConfigDTO,
25+
ClusterCostModuleConfigPayload,
2626
ClusterDetailListType,
2727
DEFAULT_SECRET_PLACEHOLDER,
2828
Icon,
@@ -35,6 +35,7 @@ import {
3535
showError,
3636
ToastManager,
3737
ToastVariantType,
38+
Tooltip,
3839
URLS,
3940
useAsync,
4041
} from '@devtron-labs/devtron-fe-common-lib'
@@ -182,7 +183,7 @@ const ClusterForm = ({
182183
setIsConnectedViaSSHTunnelTemp(false)
183184
}
184185

185-
const getCostModulePayload = (): ClusterCostModuleConfigDTO | null => {
186+
const getCostModulePayload = (): ClusterCostModuleConfigPayload | null => {
186187
if (!costModuleState.enabled) {
187188
return {
188189
enabled: false,
@@ -585,6 +586,31 @@ const ClusterForm = ({
585586
}
586587
}
587588

589+
const getCostNavSubtitle = () => {
590+
if (!costModuleState.enabled) {
591+
return 'Off'
592+
}
593+
594+
if (costModuleConfig.installationStatus === 'Installing') {
595+
return <span className="cy-7 fs-12">Installing...</span>
596+
}
597+
598+
if (costModuleConfig.installationStatus === 'Failed') {
599+
return (
600+
<div className="flexbox dc__gap-4 dc__align-items-center">
601+
<Icon name="ic-error" size={14} color="R500" />
602+
<Tooltip content={costModuleConfig.installationError}>
603+
<span className="dc__truncate cr-5 fs-12">
604+
Installation Error: {costModuleConfig.installationError}
605+
</span>
606+
</Tooltip>
607+
</div>
608+
)
609+
}
610+
611+
return 'Enabled'
612+
}
613+
588614
return (
589615
<>
590616
<div className="flexbox mh-0 flex-grow-1 dc__overflow-hidden">
@@ -615,7 +641,7 @@ const ClusterForm = ({
615641
<ClusterFormNavButton
616642
isActive={clusterConfigTab === ClusterConfigTabEnum.COST_VISIBILITY}
617643
title="Cost Visibility"
618-
subtitle={costModuleState.enabled ? 'Enabled' : 'Off'}
644+
subtitle={getCostNavSubtitle()}
619645
onClick={getTabSwitchHandler(ClusterConfigTabEnum.COST_VISIBILITY)}
620646
/>
621647
)}

0 commit comments

Comments
 (0)