@@ -141,9 +141,10 @@ const cdMaterialListModal = ({
141141 }
142142
143143 const isConsumedNonApprovedImage =
144- ! isExceptionUser && isApprovalConfigured &&
144+ ! isExceptionUser &&
145+ isApprovalConfigured &&
145146 ( ! material . userApprovalMetadata ||
146- material . userApprovalMetadata . approvalRuntimeState !== ApprovalRuntimeStateType . approved )
147+ material . userApprovalMetadata . approvalRuntimeState !== ApprovalRuntimeStateType . approved )
147148
148149 const selectImage =
149150 ! isImageMarked && markFirstSelected && filterState === FilterStates . ALLOWED && ! isConsumedNonApprovedImage
@@ -349,9 +350,7 @@ export const processCDMaterialServiceResponse = (
349350 cdMaterialsResult ,
350351 )
351352
352- const isApprovalConfigured = getIsApprovalPolicyConfigured (
353- approvalInfo ?. deploymentApprovalInfo ?. approvalConfigData ,
354- )
353+ const isApprovalConfigured = getIsApprovalPolicyConfigured ( approvalInfo ?. deploymentApprovalInfo ?. approvalConfigData )
355354
356355 const isExceptionUser = approvalInfo ?. deploymentApprovalInfo ?. approvalConfigData ?. isExceptionUser ?? false
357356
@@ -570,7 +569,6 @@ export const getAppsInfoForEnv = async ({ envId, appIds }: GetAppsInfoForEnvProp
570569 }
571570}
572571
573-
574572export const getAppOptionsGroupedByProjects = async ( ) : Promise < AppsGroupedByProjectsType > => {
575573 const { result } = await get < AppsGroupedByProjectsType > ( ROUTES . APP_LIST_MIN )
576574
@@ -586,7 +584,6 @@ export const getAppOptionsGroupedByProjects = async (): Promise<AppsGroupedByPro
586584 . sort ( ( a , b ) => stringComparatorBySortOrder ( a . projectName , b . projectName ) )
587585}
588586
589-
590587export const getEnvironmentOptionsGroupedByClusters = async ( ) : Promise < EnvironmentsGroupedByClustersType > => {
591588 const { result } = ( await get ( ROUTES . ENVIRONMENT_LIST_MIN ) ) as ResponseType < EnvListMinDTO [ ] >
592589
@@ -634,7 +631,10 @@ export const getEnvironmentOptionsGroupedByClusters = async (): Promise<Environm
634631 return envGroupedByCluster
635632}
636633
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 [ ] > => {
638638 const url = getUrlWithSearchParams ( ROUTES . CLUSTER , { clusterId : clusterIds ?. join ( ) } )
639639 const { result } = await get < ClusterDetailDTO [ ] > ( url , { signal } )
640640
@@ -647,21 +647,47 @@ export const getDetailedClusterList = async (clusterIds?: number[], signal?: Abo
647647 prometheus_url : prometheusUrl ,
648648 category,
649649 clusterStatus,
650+ costModuleConfig,
650651 ...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+ } ,
665691 )
666692 . sort ( ( a , b ) => stringComparatorBySortOrder ( a . clusterName , b . clusterName ) )
667693}
0 commit comments