@@ -21,10 +21,14 @@ import {
21
21
ACTION_STATE ,
22
22
aggregateNodes ,
23
23
AppStatusModal ,
24
+ AppStatusModalTabType ,
24
25
ArtifactInfoModal ,
25
26
Button ,
26
27
DeploymentAppTypes ,
28
+ DeploymentStatusDetailsBreakdownDataType ,
29
+ DeploymentStatusDetailsType ,
27
30
GenericEmptyState ,
31
+ getAppDetailsURL ,
28
32
getAppsInfoForEnv ,
29
33
getIsRequestAborted ,
30
34
MODAL_TYPE ,
47
51
48
52
import {
49
53
DEFAULT_STATUS ,
50
- DEFAULT_STATUS_TEXT ,
51
54
DEPLOYMENT_STATUS ,
52
55
DEPLOYMENT_STATUS_QUERY_PARAM ,
53
56
DOCUMENTATION ,
54
- getAppDetailsURL ,
55
- HELM_DEPLOYMENT_STATUS_TEXT ,
56
57
RESOURCES_NOT_FOUND ,
57
58
} from '../../../../config'
58
59
import { APP_DETAILS , ERROR_EMPTY_SCREEN } from '../../../../config/constantMessaging'
@@ -80,15 +81,12 @@ import { getDeploymentStatusDetail } from './appDetails.service'
80
81
import {
81
82
AppDetailProps ,
82
83
DeletedAppComponentType ,
83
- DeploymentStatusDetailsBreakdownDataType ,
84
- DeploymentStatusDetailsType ,
85
84
DetailsType ,
86
85
ErrorItem ,
87
86
HibernationModalTypes ,
88
87
} from './appDetails.type'
89
88
import AppDetailsCDButton from './AppDetailsCDButton'
90
89
import { AppMetrics } from './AppMetrics'
91
- import DeploymentStatusDetailModal from './DeploymentStatusDetailModal'
92
90
import HibernateModal from './HibernateModal'
93
91
import IssuesListingModal from './IssuesListingModal'
94
92
import { SourceInfo } from './SourceInfo'
@@ -208,11 +206,11 @@ const Details: React.FC<DetailsType> = ({
208
206
} ) => {
209
207
const params = useParams < { appId : string ; envId : string } > ( )
210
208
const location = useLocation ( )
209
+ const { replace } = useHistory ( )
211
210
212
211
const appDetailsFromIndexStore = IndexStore . getAppDetails ( )
213
212
214
- // fixme: the state is not being set anywhere and just being drilled down
215
- const [ detailedStatus , toggleDetailedStatus ] = useState < boolean > ( false )
213
+ const [ showAppStatusModal , setShowAppStatusModal ] = useState < boolean > ( false )
216
214
const [ resourceTreeFetchTimeOut , setResourceTreeFetchTimeOut ] = useState < boolean > ( false )
217
215
const [ urlInfo , setUrlInfo ] = useState < boolean > ( false )
218
216
const [ hibernateConfirmationModal , setHibernateConfirmationModal ] = useState < HibernationModalTypes > ( null )
@@ -235,22 +233,18 @@ const Details: React.FC<DetailsType> = ({
235
233
236
234
const [ loadingDetails , setLoadingDetails ] = useState ( true )
237
235
const [ loadingResourceTree , setLoadingResourceTree ] = useState ( true )
238
- // State to track the loading state for the timeline data when the detailed status modal opens
239
- const [ isInitialTimelineDataLoading , setIsInitialTimelineDataLoading ] = useState ( true )
240
236
const [ errorsList , setErrorsList ] = useState < ErrorItem [ ] > ( [ ] )
241
237
const appDetailsRef = useRef ( null )
242
238
const appDetailsRequestRef = useRef ( null )
243
239
const pollResourceTreeRef = useRef ( true )
244
240
const appDetailsAbortRef = useRef < AbortController > ( null )
245
- const shouldFetchTimelineRef = useRef ( false )
246
241
247
242
const [ deploymentStatusDetailsBreakdownData , setDeploymentStatusDetailsBreakdownData ] =
248
243
useState < DeploymentStatusDetailsBreakdownDataType > ( {
249
244
...( isVirtualEnvRef . current && processVirtualEnvironmentDeploymentData
250
245
? processVirtualEnvironmentDeploymentData ( )
251
246
: processDeploymentStatusDetailsData ( ) ) ,
252
247
deploymentStatus : DEFAULT_STATUS ,
253
- deploymentStatusText : DEFAULT_STATUS_TEXT ,
254
248
} )
255
249
const isConfigDriftEnabled : boolean = window . _env_ . FEATURE_CONFIG_DRIFT_ENABLE && ! ! ConfigDriftModal
256
250
const isExternalToolAvailable : boolean =
@@ -263,16 +257,6 @@ const Details: React.FC<DetailsType> = ({
263
257
[ appDetails ] ,
264
258
)
265
259
266
- useEffect ( ( ) => {
267
- const isModalOpen = location . search . includes ( DEPLOYMENT_STATUS_QUERY_PARAM )
268
- // Reset the loading state when the modal is closed
269
- if ( shouldFetchTimelineRef . current && ! isModalOpen ) {
270
- setIsInitialTimelineDataLoading ( true )
271
- }
272
- // The timeline should be fetched by default if the modal is open
273
- shouldFetchTimelineRef . current = isModalOpen
274
- } , [ location . search ] )
275
-
276
260
const clearDeploymentStatusTimer = useCallback ( ( ) : void => {
277
261
if ( deploymentStatusTimer ) {
278
262
clearTimeout ( deploymentStatusTimer )
@@ -308,30 +292,14 @@ const Details: React.FC<DetailsType> = ({
308
292
] ,
309
293
)
310
294
311
- // This is called only when timeline modal is open
312
- const getDeploymentDetailStepsData = useCallback (
313
- ( showTimeline ?: boolean ) : void => {
314
- const shouldFetchTimeline = showTimeline ?? shouldFetchTimelineRef . current
315
-
316
- // Deployments status details for Devtron apps
317
- getDeploymentStatusDetail ( params . appId , params . envId , shouldFetchTimeline )
318
- . then ( ( deploymentStatusDetailRes ) => {
319
- processDeploymentStatusData ( deploymentStatusDetailRes . result )
320
- // Update the loading status if the modal is open
321
- if ( shouldFetchTimeline ) {
322
- setIsInitialTimelineDataLoading ( false )
323
- }
324
- } )
325
- . catch ( noop )
326
- } ,
327
- [
328
- params . appId ,
329
- params . envId ,
330
- shouldFetchTimelineRef . current ,
331
- getDeploymentStatusDetail ,
332
- processDeploymentStatusData ,
333
- ] ,
334
- )
295
+ const getDeploymentDetailStepsData = useCallback ( ( ) : void => {
296
+ // Deployments status details for Devtron apps
297
+ getDeploymentStatusDetail ( params . appId , params . envId )
298
+ . then ( ( deploymentStatusDetailRes ) => {
299
+ processDeploymentStatusData ( deploymentStatusDetailRes . result )
300
+ } )
301
+ . catch ( noop )
302
+ } , [ params . appId , params . envId , getDeploymentStatusDetail , processDeploymentStatusData ] )
335
303
336
304
function clearPollingInterval ( ) {
337
305
if ( appDetailsIntervalID ) {
@@ -437,32 +405,21 @@ const Details: React.FC<DetailsType> = ({
437
405
isIsolatedEnv : boolean ,
438
406
triggerIdToFetch ?: number ,
439
407
) {
440
- const shouldFetchTimeline = shouldFetchTimelineRef . current
441
-
442
408
// triggerIdToFetch represents the wfrId to fetch for any specific deployment
443
- getDeploymentStatusDetail ( params . appId , params . envId , shouldFetchTimeline , triggerIdToFetch ?. toString ( ) )
409
+ getDeploymentStatusDetail ( params . appId , params . envId , triggerIdToFetch ?. toString ( ) )
444
410
. then ( ( deploymentStatusDetailRes ) => {
445
411
if ( deploymentStatusDetailRes . result ) {
446
412
// Timelines are not applicable for helm deployments and air gapped envs
447
413
if ( deploymentAppType === DeploymentAppTypes . HELM || isIsolatedEnv ) {
448
- setDeploymentStatusDetailsBreakdownData ( {
449
- ...deploymentStatusDetailsBreakdownData ,
450
- deploymentStatus :
451
- DEPLOYMENT_STATUS [ deploymentStatusDetailRes . result . wfrStatus ?. toUpperCase ( ) ] ,
452
- deploymentStatusText :
453
- deploymentStatusDetailRes . result . wfrStatus === HELM_DEPLOYMENT_STATUS_TEXT . PROGRESSING
454
- ? HELM_DEPLOYMENT_STATUS_TEXT . INPROGRESS
455
- : deploymentStatusDetailRes . result . wfrStatus ,
456
- deploymentTriggerTime : deploymentStatusDetailRes . result . deploymentStartedOn ,
457
- deploymentEndTime : deploymentStatusDetailRes . result . deploymentFinishedOn ,
458
- triggeredBy : deploymentStatusDetailRes . result . triggeredBy ,
459
- } )
414
+ const processedDeploymentStatusData =
415
+ isVirtualEnvRef . current && processVirtualEnvironmentDeploymentData
416
+ ? processVirtualEnvironmentDeploymentData ( deploymentStatusDetailRes . result )
417
+ : processDeploymentStatusDetailsData ( deploymentStatusDetailRes . result )
418
+
419
+ setDeploymentStatusDetailsBreakdownData ( processedDeploymentStatusData )
460
420
} else {
461
421
processDeploymentStatusData ( deploymentStatusDetailRes . result )
462
422
}
463
- if ( shouldFetchTimeline ) {
464
- setIsInitialTimelineDataLoading ( false )
465
- }
466
423
}
467
424
} )
468
425
. catch ( noop )
@@ -553,12 +510,20 @@ const Details: React.FC<DetailsType> = ({
553
510
}
554
511
}
555
512
556
- const hideAppDetailsStatus = ( ) : void => {
557
- toggleDetailedStatus ( false )
513
+ const handleCloseAppStatusModal = ( ) : void => {
514
+ if ( showAppStatusModal ) {
515
+ setShowAppStatusModal ( false )
516
+ }
517
+
518
+ if ( location . search . includes ( DEPLOYMENT_STATUS_QUERY_PARAM ) ) {
519
+ replace ( {
520
+ search : '' ,
521
+ } )
522
+ }
558
523
}
559
524
560
525
const showApplicationDetailedModal = ( ) : void => {
561
- toggleDetailedStatus ( true )
526
+ setShowAppStatusModal ( true )
562
527
}
563
528
564
529
const renderAppDetailsCDButton = ( ) =>
@@ -684,6 +649,11 @@ const Details: React.FC<DetailsType> = ({
684
649
isDeploymentBlocked = { isDeploymentBlocked }
685
650
/>
686
651
)
652
+
653
+ const updateDeploymentStatusDetailsBreakdownData = ( updatedTimelines : DeploymentStatusDetailsBreakdownDataType ) => {
654
+ setDeploymentStatusDetailsBreakdownData ( updatedTimelines )
655
+ }
656
+
687
657
const isDeploymentAppDeleting = appDetails ?. deploymentAppDeleteRequest || false
688
658
return (
689
659
< >
@@ -692,7 +662,7 @@ const Details: React.FC<DetailsType> = ({
692
662
>
693
663
< SourceInfo
694
664
appDetails = { appDetails }
695
- setDetailed = { toggleDetailedStatus }
665
+ setDetailed = { setShowAppStatusModal }
696
666
environment = { environment }
697
667
isAppView = { isAppView }
698
668
environments = { environments }
@@ -704,7 +674,6 @@ const Details: React.FC<DetailsType> = ({
704
674
setRotateModal = { setRotateModal }
705
675
loadingDetails = { loadingDetails }
706
676
loadingResourceTree = { loadingResourceTree }
707
- refetchDeploymentStatus = { getDeploymentDetailStepsData }
708
677
toggleIssuesModal = { toggleIssuesModal }
709
678
envId = { appDetails ?. environmentId }
710
679
ciArtifactId = { appDetails ?. ciArtifactId }
@@ -741,26 +710,22 @@ const Details: React.FC<DetailsType> = ({
741
710
) : (
742
711
renderAppDetails ( )
743
712
) }
744
- { detailedStatus && (
713
+ { ( showAppStatusModal || ( appDetails && location . search . includes ( DEPLOYMENT_STATUS_QUERY_PARAM ) ) ) && (
745
714
< AppStatusModal
746
715
titleSegments = { [ appDetailsFromIndexStore . appName , appDetailsFromIndexStore . environmentName ] }
747
- handleClose = { hideAppDetailsStatus }
716
+ handleClose = { handleCloseAppStatusModal }
748
717
type = "devtron-app"
749
718
appDetails = { appDetailsFromIndexStore }
750
719
isConfigDriftEnabled = { isConfigDriftEnabled }
751
720
configDriftModal = { ConfigDriftModal }
721
+ initialTab = {
722
+ showAppStatusModal ? AppStatusModalTabType . APP_STATUS : AppStatusModalTabType . DEPLOYMENT_STATUS
723
+ }
724
+ processVirtualEnvironmentDeploymentData = { processVirtualEnvironmentDeploymentData }
725
+ updateDeploymentStatusDetailsBreakdownData = { updateDeploymentStatusDetailsBreakdownData }
752
726
debugWithAIButton = { ExplainWithAIButton }
753
727
/>
754
728
) }
755
- { location . search . includes ( DEPLOYMENT_STATUS_QUERY_PARAM ) && (
756
- < DeploymentStatusDetailModal
757
- appName = { appDetails ?. appName }
758
- environmentName = { appDetails ?. environmentName }
759
- deploymentStatusDetailsBreakdownData = { deploymentStatusDetailsBreakdownData }
760
- isVirtualEnvironment = { isVirtualEnvRef . current }
761
- isLoading = { isInitialTimelineDataLoading }
762
- />
763
- ) }
764
729
{ location . search . includes ( 'deployment-window-status' ) && DeploymentWindowStatusModal && (
765
730
< DeploymentWindowStatusModal envId = { params . envId } appId = { params . appId } />
766
731
) }
@@ -910,7 +875,6 @@ const AppDetail = ({ detailsType, filteredResourceIds }: AppDetailProps) => {
910
875
appDetails = { null }
911
876
environments = { envList }
912
877
environment = { environment }
913
- refetchDeploymentStatus = { noop }
914
878
isAppView = { isAppView }
915
879
/>
916
880
</ div >
0 commit comments