Skip to content

Commit e69abeb

Browse files
shivani170Elessar1802
authored andcommitted
fic for mounting data
1 parent 59051ee commit e69abeb

File tree

4 files changed

+16
-31
lines changed

4 files changed

+16
-31
lines changed

src/components/app/details/triggerView/TriggerView.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,6 @@ class TriggerView extends Component<TriggerViewProps, TriggerViewState> {
729729
if (!isApprovalNode) {
730730
newParams.set('node-type', nodeType)
731731
}
732-
newParams.set('mode', 'list')
733732
this.props.history.push({
734733
search: newParams.toString(),
735734
})

src/components/app/details/triggerView/cdMaterial.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,7 @@ export default function CDMaterial({
20952095
isRollbackTriggerSelected={state.isRollbackTrigger}
20962096
isRecentConfigAvailable={state.recentDeploymentConfig !== null}
20972097
history={history}
2098+
canReviewConfig={canReviewConfig}
20982099
/>
20992100
) : (
21002101
renderMaterialList(isApprovalConfigured)

src/components/app/details/triggerView/triggerViewConfigDiff/TriggerViewConfigDiff.tsx

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ export default function TriggerViewConfigDiff({
2525
diffOptions,
2626
isRollbackTriggerSelected,
2727
isRecentConfigAvailable,
28-
history
28+
history,
29+
canReviewConfig
2930
}: TriggerViewConfigDiffProps) {
31+
const { searchParams } = useSearchString()
32+
3033
const [activeSideNavOption, setActiveSideNavOption] = useState(
31-
DEPLOYMENT_CONFIGURATION_NAV_MAP.DEPLOYMENT_TEMPLATE.key,
34+
searchParams.config,
3235
)
3336
const [convertVariables, setConvertVariables] = useState<boolean>(false) // toggle to show/hide variable values
3437
const [isVariableAvailable, setIsVariableAvailable] = useState<boolean>(false) // check if variable snapshot is {} or not
@@ -50,36 +53,17 @@ export default function TriggerViewConfigDiff({
5053
const [configMapOptionCollapsed, setConfigMapOptionCollapsed] = useState<boolean>(false)
5154
const [secretOptionCollapsed, setSecretOptionCollapsed] = useState<boolean>(false)
5255
const [currentData, setCurrentData] = useState<any>({}) // store codeEditorValue of current(lhs) and base(rhs) config
53-
const { searchParams } = useSearchString()
54-
55-
useEffect(() => {
56-
const dataValue = searchParams.config?.replace('-', '/')
57-
setParamsValue(dataValue.replace('/', '-'))
58-
if (dataValue) {
59-
setConvertVariables(false)
60-
setActiveSideNavOption(dataValue)
61-
62-
const { rhsData, lhsData } = getCurrentConfiguration(dataValue)
63-
setCurrentData({
64-
rhsData,
65-
lhsData,
66-
})
6756

68-
const _isVariableAvailable =
69-
Object.keys(rhsData?.variableSnapshot || {}).length !== 0 ||
70-
Object.keys(lhsData?.variableSnapshot || {}).length !== 0
71-
setIsVariableAvailable(_isVariableAvailable)
7257

73-
const editorValuesRHS = convertVariables ? rhsData?.resolvedValue : rhsData?.value
74-
const editorValuesLHS = convertVariables ? lhsData?.resolvedValue : lhsData?.value
75-
setEditorValues({
76-
displayName: rhsData?.displayName || lhsData?.displayName,
77-
value: editorValuesRHS ? YAML.stringify(JSON.parse(editorValuesRHS)) : '',
78-
defaultValue: editorValuesLHS ? YAML.stringify(JSON.parse(editorValuesLHS)) : '',
79-
})
58+
useEffect(() => {
59+
if(canReviewConfig() && baseTemplateConfiguration && currentConfiguration){
60+
const dataValue = searchParams.config?.replace('-', '/')
61+
setParamsValue(dataValue.replace('/', '-'))
62+
handleNavOptionSelection(null, dataValue)
8063
}
64+
8165

82-
}, [])
66+
}, [canReviewConfig(), baseTemplateConfiguration , currentConfiguration])
8367

8468
useEffect(() => {
8569
handleConfigToDeploySelection()
@@ -105,8 +89,8 @@ export default function TriggerViewConfigDiff({
10589

10690
if (!getNavOptions(navParentChildKeys[0]).includes(navParentChildKeys[1])) {
10791
setConvertVariables(false)
108-
setActiveSideNavOption(DEPLOYMENT_CONFIGURATION_NAV_MAP.DEPLOYMENT_TEMPLATE.key)
109-
handleNavOptionSelection(null, DEPLOYMENT_CONFIGURATION_NAV_MAP.DEPLOYMENT_TEMPLATE.key)
92+
setActiveSideNavOption(searchParams.config)
93+
handleNavOptionSelection(null, searchParams.config)
11094
return
11195
}
11296
}

src/components/app/details/triggerView/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ export interface TriggerViewConfigDiffProps {
670670
isRollbackTriggerSelected: boolean
671671
isRecentConfigAvailable: boolean
672672
history: ReactRouterHistory
673+
canReviewConfig
673674
}
674675

675676
export const MATERIAL_TYPE = {

0 commit comments

Comments
 (0)