@@ -141,9 +141,10 @@ const cdMaterialListModal = ({
141
141
}
142
142
143
143
const isConsumedNonApprovedImage =
144
- ! isExceptionUser && isApprovalConfigured &&
144
+ ! isExceptionUser &&
145
+ isApprovalConfigured &&
145
146
( ! material . userApprovalMetadata ||
146
- material . userApprovalMetadata . approvalRuntimeState !== ApprovalRuntimeStateType . approved )
147
+ material . userApprovalMetadata . approvalRuntimeState !== ApprovalRuntimeStateType . approved )
147
148
148
149
const selectImage =
149
150
! isImageMarked && markFirstSelected && filterState === FilterStates . ALLOWED && ! isConsumedNonApprovedImage
@@ -349,9 +350,7 @@ export const processCDMaterialServiceResponse = (
349
350
cdMaterialsResult ,
350
351
)
351
352
352
- const isApprovalConfigured = getIsApprovalPolicyConfigured (
353
- approvalInfo ?. deploymentApprovalInfo ?. approvalConfigData ,
354
- )
353
+ const isApprovalConfigured = getIsApprovalPolicyConfigured ( approvalInfo ?. deploymentApprovalInfo ?. approvalConfigData )
355
354
356
355
const isExceptionUser = approvalInfo ?. deploymentApprovalInfo ?. approvalConfigData ?. isExceptionUser ?? false
357
356
@@ -570,7 +569,6 @@ export const getAppsInfoForEnv = async ({ envId, appIds }: GetAppsInfoForEnvProp
570
569
}
571
570
}
572
571
573
-
574
572
export const getAppOptionsGroupedByProjects = async ( ) : Promise < AppsGroupedByProjectsType > => {
575
573
const { result } = await get < AppsGroupedByProjectsType > ( ROUTES . APP_LIST_MIN )
576
574
@@ -586,7 +584,6 @@ export const getAppOptionsGroupedByProjects = async (): Promise<AppsGroupedByPro
586
584
. sort ( ( a , b ) => stringComparatorBySortOrder ( a . projectName , b . projectName ) )
587
585
}
588
586
589
-
590
587
export const getEnvironmentOptionsGroupedByClusters = async ( ) : Promise < EnvironmentsGroupedByClustersType > => {
591
588
const { result } = ( await get ( ROUTES . ENVIRONMENT_LIST_MIN ) ) as ResponseType < EnvListMinDTO [ ] >
592
589
@@ -634,7 +631,10 @@ export const getEnvironmentOptionsGroupedByClusters = async (): Promise<Environm
634
631
return envGroupedByCluster
635
632
}
636
633
637
- export const getDetailedClusterList = async ( clusterIds ?: number [ ] , signal ?: AbortSignal ) : Promise < ClusterDetailListType [ ] > => {
634
+ export const getDetailedClusterList = async (
635
+ clusterIds ?: number [ ] ,
636
+ signal ?: AbortSignal ,
637
+ ) : Promise < ClusterDetailListType [ ] > => {
638
638
const url = getUrlWithSearchParams ( ROUTES . CLUSTER , { clusterId : clusterIds ?. join ( ) } )
639
639
const { result } = await get < ClusterDetailDTO [ ] > ( url , { signal } )
640
640
@@ -647,21 +647,47 @@ export const getDetailedClusterList = async (clusterIds?: number[], signal?: Abo
647
647
prometheus_url : prometheusUrl ,
648
648
category,
649
649
clusterStatus,
650
+ costModuleConfig,
650
651
...res
651
- } ) => ( {
652
- ...res ,
653
- clusterId : id ,
654
- serverUrl,
655
- clusterName,
656
- prometheusUrl,
657
- category : category ?. name
658
- ? {
659
- label : category . name ,
660
- value : category . id ,
661
- }
662
- : null ,
663
- status : clusterStatus ,
664
- } ) ,
652
+ } ) => {
653
+ const costModuleInstallationStatus = costModuleConfig ?. installationStatus || 'NotInstalled'
654
+ // Need to remove following keys from config if present: openCostServiceName, openCostServicePort, releaseName, namespace
655
+ const sanitizedCostConfig = costModuleConfig ?. config
656
+ ? Object . fromEntries (
657
+ Object . entries ( costModuleConfig . config ) . filter (
658
+ ( [ key ] ) =>
659
+ ! [ 'openCostServiceName' , 'openCostServicePort' , 'releaseName' , 'namespace' ] . includes (
660
+ key ,
661
+ ) ,
662
+ ) ,
663
+ )
664
+ : undefined
665
+
666
+ return {
667
+ ...res ,
668
+ clusterId : id ,
669
+ serverUrl,
670
+ clusterName,
671
+ prometheusUrl,
672
+ category : category ?. name
673
+ ? {
674
+ label : category . name ,
675
+ value : category . id ,
676
+ }
677
+ : null ,
678
+ status : clusterStatus ,
679
+ costModuleConfig : {
680
+ enabled : costModuleConfig ?. enabled || false ,
681
+ config : sanitizedCostConfig ,
682
+ installationStatus : costModuleInstallationStatus ,
683
+ ...( costModuleInstallationStatus === 'Failed'
684
+ ? {
685
+ installationError : costModuleConfig ?. installationError || 'Some error occurred' ,
686
+ }
687
+ : { } ) ,
688
+ } satisfies ClusterDetailListType [ 'costModuleConfig' ] ,
689
+ }
690
+ } ,
665
691
)
666
692
. sort ( ( a , b ) => stringComparatorBySortOrder ( a . clusterName , b . clusterName ) )
667
693
}
0 commit comments