Skip to content

Commit c8efa53

Browse files
committed
feat: Refactor EnvTriggerView and AppDetailsCDModal to remove unnecessary loading states and props
1 parent 67f6b66 commit c8efa53

File tree

3 files changed

+19
-38
lines changed

3 files changed

+19
-38
lines changed

src/components/ApplicationGroup/Details/TriggerView/EnvTriggerView.tsx

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ const processDeploymentWindowStateAppGroup = importComponentFromFELibrary(
9191
const ChangeImageSource = importComponentFromFELibrary('ChangeImageSource', null, 'function')
9292
const WebhookAddImageModal = importComponentFromFELibrary('WebhookAddImageModal', null, 'function')
9393

94-
// FIXME: IN CIMaterials we are sending isCDLoading while in CD materials we are sending isCILoading
9594
let inprogressStatusTimer
9695
const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultType) => {
9796
const { envId } = useParams<{ envId: string }>()
@@ -100,11 +99,7 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
10099
const match = useRouteMatch<CIMaterialRouterProps>()
101100
const { url } = useRouteMatch()
102101

103-
const abortControllerRef = useRef(new AbortController())
104-
105102
const [pageViewType, setPageViewType] = useState<string>(ViewType.LOADING)
106-
const [isCILoading, setCILoading] = useState(false)
107-
const [isCDLoading, setCDLoading] = useState(false)
108103
const [isBranchChangeLoading, setIsBranchChangeLoading] = useState(false)
109104
const [showPreDeployment, setShowPreDeployment] = useState(false)
110105
const [showPostDeployment, setShowPostDeployment] = useState(false)
@@ -417,8 +412,6 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
417412
if (!appIds.length) {
418413
updateResponseListData(skippedResources)
419414
setIsBranchChangeLoading(false)
420-
setCDLoading(false)
421-
setCILoading(false)
422415
return
423416
}
424417

@@ -436,8 +429,6 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
436429
})
437430
})
438431
updateResponseListData([..._responseList, ...skippedResources])
439-
setCDLoading(false)
440-
setCILoading(false)
441432
})
442433
.catch((error) => {
443434
showError(error)
@@ -448,8 +439,6 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
448439
}
449440

450441
const closeCDModal = (): void => {
451-
abortControllerRef.current.abort()
452-
setCDLoading(false)
453442
history.push({
454443
search: '',
455444
})
@@ -464,7 +453,6 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
464453
}
465454

466455
const hideBulkCDModal = () => {
467-
setCDLoading(false)
468456
setShowBulkCDModal(false)
469457
setResponseList([])
470458

@@ -479,16 +467,12 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
479467
}
480468

481469
const hideBulkCIModal = () => {
482-
setCILoading(false)
483470
setShowBulkCIModal(false)
484471
setResponseList([])
485472
}
486473

487474
const onShowBulkCIModal = () => {
488-
setCILoading(true)
489-
setTimeout(() => {
490-
setShowBulkCIModal(true)
491-
}, 100)
475+
setShowBulkCIModal(true)
492476
}
493477

494478
const hideChangeSourceModal = () => {
@@ -666,7 +650,7 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
666650

667651
return (
668652
<ApprovalMaterialModal
669-
isLoading={isCDLoading}
653+
isLoading={false}
670654
node={node ?? ({} as CommonNodeAttr)}
671655
materialType={MATERIAL_TYPE.inputMaterialList}
672656
stageType={DeploymentNodeType.CD}
@@ -751,23 +735,16 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
751735
text="Build image"
752736
onClick={onShowBulkCIModal}
753737
size={ComponentSizeType.medium}
754-
isLoading={isCILoading}
755738
/>
756739
<div className="flex">
757740
<button
758-
className={`cta flex h-32 ${_showPopupMenu ? 'dc__no-right-radius' : ''}`}
741+
className={`cta flex h-32 dc__gap-8 ${_showPopupMenu ? 'dc__no-right-radius' : ''}`}
759742
data-trigger-type="CD"
760743
data-testid="bulk-deploy-button"
761744
onClick={onShowBulkCDModal}
762745
>
763-
{isCDLoading ? (
764-
<Progressing />
765-
) : (
766-
<>
767-
<DeployIcon className="icon-dim-16 dc__no-svg-fill mr-8" />
768-
Deploy
769-
</>
770-
)}
746+
<DeployIcon className="icon-dim-16 dc__no-svg-fill" />
747+
Deploy
771748
</button>
772749
{_showPopupMenu && renderDeployPopupMenu()}
773750
</div>

src/components/app/details/appDetails/AppDetailsCDModal.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ const AppDetailsCDModal = ({
8585
isRedirectedFromAppDetails
8686
handleSuccess={handleSuccess}
8787
appName={appName}
88-
// TODO: Not needed since not pre-post cd here
89-
showPluginWarningBeforeTrigger={null}
90-
consequence={null}
91-
configurePluginURL={null}
92-
isTriggerBlockedDueToPlugin={null}
9388
/>
9489
)
9590

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ export type DeployImageModalProps = {
2929
materialType: (typeof MATERIAL_TYPE)[keyof typeof MATERIAL_TYPE]
3030
handleClose: () => void
3131
envName: string
32-
showPluginWarningBeforeTrigger: boolean
33-
consequence: ConsequenceType
34-
configurePluginURL: string
3532
/**
3633
* In case of appDetails trigger re-fetch of app details
3734
*/
@@ -40,9 +37,21 @@ export type DeployImageModalProps = {
4037
isVirtualEnvironment: boolean
4138
isRedirectedFromAppDetails: boolean
4239
parentEnvironmentName: string
43-
isTriggerBlockedDueToPlugin: boolean
4440
triggerType: CommonNodeAttr['triggerType']
45-
}
41+
} & (
42+
| {
43+
showPluginWarningBeforeTrigger: boolean
44+
consequence: ConsequenceType
45+
configurePluginURL: string
46+
isTriggerBlockedDueToPlugin: boolean
47+
}
48+
| {
49+
showPluginWarningBeforeTrigger?: never
50+
consequence?: never
51+
configurePluginURL?: never
52+
isTriggerBlockedDueToPlugin?: never
53+
}
54+
)
4655

4756
export type DeployImageHeaderProps = Pick<
4857
DeployImageModalProps,

0 commit comments

Comments
 (0)