7
7
CompareApprovalAndDraftSelectedOption ,
8
8
} from '../types'
9
9
import { DEPLOYMENT_TEMPLATE_LABELS_KEYS , NO_SCOPED_VARIABLES_MESSAGE , getApprovalPendingOption } from '../constants'
10
- import { versionComparator } from '../../common'
10
+ import { importComponentFromFELibrary , versionComparator } from '../../common'
11
11
import { SortingOrder } from '../../app/types'
12
12
import { getDefaultDeploymentTemplate , getDeploymentManisfest , getDeploymentTemplateData } from '../service'
13
13
import YAML from 'yaml'
@@ -25,6 +25,8 @@ import { useParams } from 'react-router-dom'
25
25
import { DeploymentConfigContext } from '../DeploymentConfig'
26
26
import DeploymentTemplateGUIView from './DeploymentTemplateGUIView'
27
27
import { toast } from 'react-toastify'
28
+ import * as jsonpatch from 'fast-json-patch'
29
+ const getLockFilteredTemplate = importComponentFromFELibrary ( 'getLockFilteredTemplate' , null , 'function' )
28
30
29
31
export default function DeploymentTemplateEditorView ( {
30
32
isEnvOverride,
@@ -39,6 +41,9 @@ export default function DeploymentTemplateEditorView({
39
41
convertVariables,
40
42
setConvertVariables,
41
43
groupedData,
44
+ hideLockedKeys,
45
+ lockedConfigKeysWithLockType,
46
+ hideLockKeysToggled
42
47
} : DeploymentTemplateEditorViewProps ) {
43
48
const { appId, envId } = useParams < { appId : string ; envId : string } > ( )
44
49
const { isUnSet, state, environments, dispatch } = useContext < DeploymentConfigContextType > ( DeploymentConfigContext )
@@ -47,9 +52,9 @@ export default function DeploymentTemplateEditorView({
47
52
const [ filteredEnvironments , setFilteredEnvironments ] = useState < DeploymentChartOptionType [ ] > ( [ ] )
48
53
const [ filteredCharts , setFilteredCharts ] = useState < DeploymentChartOptionType [ ] > ( [ ] )
49
54
const [ globalChartRef , setGlobalChartRef ] = useState ( null )
55
+ const removedPatches = useRef < Array < jsonpatch . Operation > > ( [ ] )
50
56
const isDeleteDraftState = state . latestDraft ?. action === 3 && state . selectedCompareOption ?. id === + envId
51
57
const baseDeploymentAbortController = useRef ( null )
52
-
53
58
const [ showDraftData , setShowDraftData ] = useState ( false )
54
59
const [ draftManifestData , setDraftManifestData ] = useState ( null )
55
60
const [ draftLoading , setDraftLoading ] = useState ( false )
@@ -301,16 +306,29 @@ export default function DeploymentTemplateEditorView({
301
306
const valueLHS = isIdMatch ? defaultValue : source [ selectedOptionId ] // fetch LHS data from respective cache store
302
307
303
308
// final value for LHS
304
- const lhs = convertVariables ? resolvedValuesLHS : valueLHS
309
+ let lhs = convertVariables ? resolvedValuesLHS : valueLHS
305
310
306
311
// choose RHS value for comparison
307
312
const shouldUseDraftData = state . selectedTabIndex !== 3 && showDraftData
308
313
const selectedData = isValues ? state . tempFormData || state . draftValues : draftManifestData
309
314
const valueRHS = shouldUseDraftData ? selectedData : value
310
315
311
316
// final value for RHS
312
- const rhs = convertVariables ? resolvedValuesRHS : valueRHS
313
-
317
+ let rhs = convertVariables ? resolvedValuesRHS : valueRHS
318
+ if ( getLockFilteredTemplate ) {
319
+ const { updatedLHS, updatedRHS } = getLockFilteredTemplate (
320
+ hideLockedKeys ,
321
+ lhs ,
322
+ rhs ,
323
+ lockedConfigKeysWithLockType ,
324
+ removedPatches ,
325
+ hideLockKeysToggled ,
326
+ state . unableToParseYaml ,
327
+ )
328
+ lhs = updatedLHS
329
+ rhs = updatedRHS
330
+ }
331
+
314
332
const renderCodeEditorHeading = ( ) => (
315
333
< CodeEditor . Header
316
334
className = { `code-editor__header flex left p-0-imp ${ getOverrideClass ( ) } ` }
0 commit comments