Skip to content

Commit ef6e9d8

Browse files
shivani170Elessar1802
authored andcommitted
code refactoring
1 parent f6044b4 commit ef6e9d8

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

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

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ import { abortEarlierRequests, getInitialState } from './cdMaterials.utils'
9090
import { getLastExecutionByArtifactAppEnv } from '../../../../services/service'
9191
import AnnouncementBanner from '../../../common/AnnouncementBanner'
9292
import { useRouteMatch } from 'react-router-dom'
93-
import { get } from 'http'
9493

9594
const ApprovalInfoTippy = importComponentFromFELibrary('ApprovalInfoTippy')
9695
const ExpireApproval = importComponentFromFELibrary('ExpireApproval')
@@ -132,7 +131,6 @@ export default function CDMaterial({
132131
const { searchParams } = useSearchString()
133132
// Add dep here
134133
const { isSuperAdmin } = useSuperAdmin()
135-
const match = useRouteMatch()
136134

137135
const searchImageTag = searchParams.search
138136

@@ -271,18 +269,6 @@ export default function CDMaterial({
271269
})
272270
}
273271

274-
const setInitialModeParams = (modeParamValue: string) => {
275-
const newParams = {
276-
...searchParams,
277-
mode: modeParamValue,
278-
config: DEPLOYMENT_CONFIGURATION_NAV_MAP.DEPLOYMENT_TEMPLATE.key,
279-
deploy: searchParams.deploy ? searchParams.deploy : DeploymentWithConfigType.LAST_SAVED_CONFIG
280-
}
281-
history.push({
282-
search: new URLSearchParams(newParams).toString(),
283-
})
284-
}
285-
286272
/* ------------ UseEffects ------------*/
287273
useEffect(() => {
288274
if (!loadingMaterials && materialsResult) {
@@ -768,9 +754,22 @@ const getInitialSelectedConfigToDeploy = () => {
768754
isConfigPresent())) ||
769755
!state.recentDeploymentConfig
770756

771-
const reviewConfig = (modeParamValue: string) => {
757+
const onClickSetInitialParams = (modeParamValue: string) => {
772758
if (canReviewConfig()) {
773-
setInitialModeParams(modeParamValue)
759+
const newParams = {
760+
...searchParams,
761+
mode: modeParamValue,
762+
config: DEPLOYMENT_CONFIGURATION_NAV_MAP.DEPLOYMENT_TEMPLATE.key,
763+
deploy: searchParams.deploy
764+
? searchParams.deploy
765+
: materialType === MATERIAL_TYPE.rollbackMaterialList
766+
? DeploymentWithConfigType.SPECIFIC_TRIGGER_CONFIG
767+
: DeploymentWithConfigType.LAST_SAVED_CONFIG,
768+
}
769+
770+
history.push({
771+
search: new URLSearchParams(newParams).toString(),
772+
})
774773
}
775774
}
776775

@@ -1955,7 +1954,7 @@ const getInitialSelectedConfigToDeploy = () => {
19551954
} ${isLastDeployedOption ? 'pt-10 pb-10' : 'pt-7 pb-7'}`}
19561955
disabled={state.checkingDiff}
19571956
type="button"
1958-
onClick={() => reviewConfig('review-config')}
1957+
onClick={() => onClickSetInitialParams('review-config')}
19591958
>
19601959
{!isLastDeployedOption && (state.recentDeploymentConfig !== null || state.checkingDiff) && (
19611960
<div
@@ -2148,7 +2147,7 @@ const getInitialSelectedConfigToDeploy = () => {
21482147
<div className="trigger-modal__header">
21492148
{showConfigDiffView ? (
21502149
<div className="flex left">
2151-
<button type="button" className="dc__transparent icon-dim-24" onClick={() => reviewConfig('list')}>
2150+
<button type="button" className="dc__transparent icon-dim-24" onClick={() => onClickSetInitialParams('list')}>
21522151
<BackIcon />
21532152
</button>
21542153
<div className="flex column left ml-16">

0 commit comments

Comments
 (0)