@@ -32,6 +32,7 @@ import {
32
32
getAppDetailsURL ,
33
33
getAppsInfoForEnv ,
34
34
getIsRequestAborted ,
35
+ handleAnalyticsEvent ,
35
36
Icon ,
36
37
MODAL_TYPE ,
37
38
noop ,
@@ -51,6 +52,7 @@ import { ReactComponent as ForwardArrow } from '@Icons/ic-arrow-forward.svg'
51
52
import { ReactComponent as Trash } from '@Icons/ic-delete-dots.svg'
52
53
import AppNotConfiguredIcon from '@Images/app-not-configured.png'
53
54
import noGroups from '@Images/[email protected] '
55
+ import { URL_PARAM_MODE_TYPE } from '@Components/common/helpers/types'
54
56
55
57
import {
56
58
DEFAULT_STATUS ,
@@ -78,6 +80,7 @@ import { TriggerUrlModal } from '../../list/TriggerUrl'
78
80
import { fetchAppDetailsInTime , fetchResourceTreeInTime } from '../../service'
79
81
import { AggregatedNodes } from '../../types'
80
82
import { renderCIListHeader } from '../cdDetails/utils'
83
+ import { MATERIAL_TYPE } from '../triggerView/types'
81
84
import AppEnvSelector from './AppDetails.components'
82
85
import { getDeploymentStatusDetail } from './appDetails.service'
83
86
import {
@@ -87,7 +90,7 @@ import {
87
90
ErrorItem ,
88
91
HibernationModalTypes ,
89
92
} from './appDetails.type'
90
- import AppDetailsCDButton from './AppDetailsCDButton '
93
+ import AppDetailsCDModal from './AppDetailsCDModal '
91
94
import { AppMetrics } from './AppMetrics'
92
95
import { AG_APP_DETAILS_GA_EVENTS , DA_APP_DETAILS_GA_EVENTS } from './constants'
93
96
import HibernateModal from './HibernateModal'
@@ -207,7 +210,7 @@ const Details: React.FC<DetailsType> = ({
207
210
} ) => {
208
211
const params = useParams < { appId : string ; envId : string } > ( )
209
212
const location = useLocation ( )
210
- const { replace } = useHistory ( )
213
+ const { replace, push } = useHistory ( )
211
214
const { path, url } = useRouteMatch ( )
212
215
213
216
const { setAIAgentContext } = useMainContext ( )
@@ -232,6 +235,7 @@ const Details: React.FC<DetailsType> = ({
232
235
const [ rotateModal , setRotateModal ] = useState < boolean > ( false )
233
236
const [ hibernating , setHibernating ] = useState < boolean > ( false )
234
237
const [ showIssuesModal , toggleIssuesModal ] = useState < boolean > ( false )
238
+ const [ CDModalMaterialType , setCDModalMaterialType ] = useState < string | null > ( null )
235
239
const [ appDetailsError , setAppDetailsError ] = useState ( undefined )
236
240
237
241
const [ hibernationPatchChartName , setHibernationPatchChartName ] = useState < string > ( '' )
@@ -541,9 +545,45 @@ const Details: React.FC<DetailsType> = ({
541
545
setShowAppStatusModal ( true )
542
546
}
543
547
544
- const renderSelectImageButton = ( ) =>
545
- appDetails && (
546
- < AppDetailsCDButton
548
+ const handleOpenCDModal = ( isForRollback ?: boolean ) => ( ) => {
549
+ push ( {
550
+ search : new URLSearchParams ( {
551
+ mode : URL_PARAM_MODE_TYPE . LIST ,
552
+ } ) . toString ( ) ,
553
+ } )
554
+ setCDModalMaterialType ( isForRollback ? MATERIAL_TYPE . rollbackMaterialList : MATERIAL_TYPE . inputMaterialList )
555
+
556
+ if ( isForRollback ) {
557
+ handleAnalyticsEvent (
558
+ isAppView
559
+ ? DA_APP_DETAILS_GA_EVENTS . RollbackButtonClicked
560
+ : AG_APP_DETAILS_GA_EVENTS . RollbackButtonClicked ,
561
+ )
562
+ return
563
+ }
564
+ handleAnalyticsEvent (
565
+ isAppView ? DA_APP_DETAILS_GA_EVENTS . DeployButtonClicked : AG_APP_DETAILS_GA_EVENTS . DeployButtonClicked ,
566
+ )
567
+ }
568
+
569
+ const handleCloseCDModal = ( ) => {
570
+ setCDModalMaterialType ( null )
571
+ push ( { search : '' } )
572
+ }
573
+
574
+ const renderSelectImageButton = ( ) => (
575
+ < Button
576
+ dataTestId = "select-image-to-deploy"
577
+ startIcon = { < Icon name = "ic-hand-pointing" color = { null } /> }
578
+ text = "Select Image to deploy"
579
+ onClick = { handleOpenCDModal ( ) }
580
+ />
581
+ )
582
+
583
+ const renderCDModal = ( ) =>
584
+ appDetails &&
585
+ CDModalMaterialType && (
586
+ < AppDetailsCDModal
547
587
appId = { appDetails . appId }
548
588
environmentId = { appDetails . environmentId }
549
589
environmentName = { appDetails . environmentName }
@@ -558,16 +598,8 @@ const Details: React.FC<DetailsType> = ({
558
598
triggerType : appDetails . triggerType ,
559
599
} }
560
600
handleSuccess = { callAppDetailsAPI }
561
- gaEvent = {
562
- isAppView
563
- ? DA_APP_DETAILS_GA_EVENTS . DeployButtonClicked
564
- : AG_APP_DETAILS_GA_EVENTS . DeployButtonClicked
565
- }
566
- buttonProps = { {
567
- dataTestId : 'select-image-to-deploy' ,
568
- startIcon : < Icon name = "ic-hand-pointing" color = { null } /> ,
569
- text : 'Select Image to deploy' ,
570
- } }
601
+ materialType = { CDModalMaterialType }
602
+ closeCDModal = { handleCloseCDModal }
571
603
/>
572
604
)
573
605
@@ -598,12 +630,15 @@ const Details: React.FC<DetailsType> = ({
598
630
showApplicationDetailedModal = { showApplicationDetailedModal }
599
631
/>
600
632
) : (
601
- < AppNotConfigured
602
- image = { noGroups }
603
- title = { ERROR_EMPTY_SCREEN . ALL_SET_GO_CONFIGURE }
604
- subtitle = { ERROR_EMPTY_SCREEN . DEPLOYEMENT_WILL_BE_HERE }
605
- renderCustomButton = { renderSelectImageButton }
606
- />
633
+ < >
634
+ < AppNotConfigured
635
+ image = { noGroups }
636
+ title = { ERROR_EMPTY_SCREEN . ALL_SET_GO_CONFIGURE }
637
+ subtitle = { ERROR_EMPTY_SCREEN . DEPLOYEMENT_WILL_BE_HERE }
638
+ renderCustomButton = { renderSelectImageButton }
639
+ />
640
+ { renderCDModal ( ) }
641
+ </ >
607
642
) }
608
643
</ >
609
644
)
@@ -705,6 +740,7 @@ const Details: React.FC<DetailsType> = ({
705
740
setHibernationPatchChartName = { setHibernationPatchChartName }
706
741
applications = { applications }
707
742
isResourceTreeReloading = { isReloadResourceTreeInProgress }
743
+ handleOpenCDModal = { handleOpenCDModal }
708
744
/>
709
745
</ div >
710
746
{ ! loadingDetails && ! loadingResourceTree && ! appDetails ?. deploymentAppDeleteRequest && (
@@ -774,6 +810,7 @@ const Details: React.FC<DetailsType> = ({
774
810
) }
775
811
{ appDetails && ! ! hibernateConfirmationModal && renderHibernateModal ( ) }
776
812
{ rotateModal && renderRestartWorkload ( ) }
813
+ { renderCDModal ( ) }
777
814
</ >
778
815
)
779
816
}
0 commit comments