Skip to content

Commit eeec1da

Browse files
committed
feat: Enhance diff state handling for external ConfigMap/Secret
1 parent 5c1a882 commit eeec1da

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.utils.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { deepEqual, noop, YAMLStringify } from '@Common/Helper'
2020

2121
import { ManifestTemplateDTO } from '@Pages/Applications'
2222
import {
23+
CMSecretExternalType,
2324
ConfigMapSecretDataConfigDatumDTO,
2425
ConfigMapSecretDataDTO,
2526
ConfigResourceType,
@@ -326,6 +327,25 @@ const getDiffState = (compareToValue: DeploymentHistoryDetail, compareWithValue:
326327
return DeploymentConfigDiffState.NO_DIFF
327328
}
328329

330+
const getCMSecretHistoryDataForDiffState = (
331+
configMapSecretData: ConfigMapSecretDataConfigDatumDTO,
332+
historyData: DeploymentHistoryDetail,
333+
) => {
334+
// CHECKING FOR EXTERNAL CM/CS
335+
if (
336+
configMapSecretData &&
337+
configMapSecretData.external &&
338+
(configMapSecretData.externalType === '' ||
339+
configMapSecretData.externalType === CMSecretExternalType.KubernetesSecret)
340+
) {
341+
const historyDataWhenExternal = structuredClone(historyData)
342+
historyDataWhenExternal.codeEditorValue.value = 'external'
343+
return historyDataWhenExternal
344+
}
345+
346+
return historyData
347+
}
348+
329349
/**
330350
* Prepares the data for displaying the diff view between two configuration items.
331351
*
@@ -378,7 +398,10 @@ const getDiffViewData = (
378398
return {
379399
compareToDiff,
380400
compareWithDiff,
381-
diffState: getDiffState(compareToDiff, compareWithDiff),
401+
diffState: getDiffState(
402+
getCMSecretHistoryDataForDiffState(compareTo, compareToDiff),
403+
getCMSecretHistoryDataForDiffState(compareWith, compareWithDiff),
404+
),
382405
}
383406
}
384407

0 commit comments

Comments
 (0)