@@ -53,7 +53,7 @@ import { ReactComponent as HibernateIcon } from '../../../../assets/icons/ic-hib
53
53
import { ReactComponent as UnhibernateIcon } from '../../../../assets/icons/ic-unhibernate.svg'
54
54
import { ReactComponent as RotateIcon } from '../../../../assets/icons/ic-arrows_clockwise.svg'
55
55
import { renderCIListHeader } from '../../../app/details/cdDetails/utils'
56
- import { EnvironmentOverviewTable , EnvironmentOverviewTableProps } from '@Pages/Shared/EnvironmentOverviewTable'
56
+ import { EnvironmentOverviewTable , EnvironmentOverviewTableRow } from '@Pages/Shared/EnvironmentOverviewTable'
57
57
import './envOverview.scss'
58
58
59
59
const processDeploymentWindowAppGroupOverviewMap = importComponentFromFELibrary (
@@ -62,6 +62,8 @@ const processDeploymentWindowAppGroupOverviewMap = importComponentFromFELibrary(
62
62
'function' ,
63
63
)
64
64
const ClonePipelineButton = importComponentFromFELibrary ( 'ClonePipelineButton' , null , 'function' )
65
+ const ClonePipelineMenuButton = importComponentFromFELibrary ( 'ClonePipelineMenuButton' , null , 'function' )
66
+ const ClonePipelineModal = importComponentFromFELibrary ( 'ClonePipelineModal' , null , 'function' )
65
67
66
68
export default function EnvironmentOverview ( {
67
69
appGroupListData,
@@ -82,8 +84,10 @@ export default function EnvironmentOverview({
82
84
const [ appStatusResponseList , setAppStatusResponseList ] = useState < ManageAppsResponse [ ] > ( [ ] )
83
85
const timerId = useRef ( null )
84
86
const [ selectedAppDetailsList , setSelectedAppDetailsList ] = useState < AppInfoListType [ ] > ( [ ] )
87
+ const [ selectedAppDetails , setSelectedAppDetails ] = useState < AppInfoListType > ( null )
85
88
const [ openedHibernateModalType , setOpenedHibernateModalType ] =
86
89
useState < HibernateModalProps [ 'openedHibernateModalType' ] > ( null )
90
+ const [ openClonePipelineConfig , setOpenClonePipelineConfig ] = useState ( false )
87
91
const [ commitInfoModalConfig , setCommitInfoModalConfig ] = useState < Pick <
88
92
ArtifactInfoModalProps ,
89
93
'ciArtifactId' | 'envId'
@@ -121,6 +125,8 @@ export default function EnvironmentOverview({
121
125
122
126
const { searchParams } = useSearchString ( )
123
127
const history = useHistory ( )
128
+ const isAppSelected = selectedAppDetails ?? ! ! selectedAppDetailsList . length
129
+ const selectedApps = selectedAppDetails ?? selectedAppDetailsList
124
130
125
131
useEffect ( ( ) => {
126
132
return ( ) => {
@@ -131,7 +137,7 @@ export default function EnvironmentOverview({
131
137
} , [ ] )
132
138
133
139
async function getDeploymentWindowEnvOverrideMetaData ( ) {
134
- const appEnvTuples = selectedAppDetailsList . map ( ( appDetail ) => ( {
140
+ const appEnvTuples = ( selectedAppDetails ? [ selectedAppDetails ] : selectedAppDetailsList ) . map ( ( appDetail ) => ( {
135
141
appId : + appDetail . appId ,
136
142
envId : + appDetail . envId ,
137
143
} ) )
@@ -144,13 +150,14 @@ export default function EnvironmentOverview({
144
150
useEffect ( ( ) => {
145
151
if (
146
152
processDeploymentWindowAppGroupOverviewMap &&
153
+ isAppSelected &&
147
154
( openedHibernateModalType ||
148
155
showHibernateStatusDrawer . showStatus ||
149
156
location . search . includes ( URL_SEARCH_PARAMS . BULK_RESTART_WORKLOAD ) )
150
157
) {
151
158
getDeploymentWindowEnvOverrideMetaData ( )
152
159
}
153
- } , [ openedHibernateModalType , showHibernateStatusDrawer . showStatus , location . search ] )
160
+ } , [ openedHibernateModalType , showHibernateStatusDrawer . showStatus , location . search , isAppSelected ] )
154
161
155
162
useEffect ( ( ) => {
156
163
setLoading ( true )
@@ -247,10 +254,12 @@ export default function EnvironmentOverview({
247
254
}
248
255
249
256
const openHibernateModalPopup = ( ) => {
257
+ setIsDeploymentLoading ( true )
250
258
setOpenedHibernateModalType ( MODAL_TYPE . HIBERNATE )
251
259
}
252
260
253
261
const openUnHibernateModalPopup = ( ) => {
262
+ setIsDeploymentLoading ( true )
254
263
setOpenedHibernateModalType ( MODAL_TYPE . UNHIBERNATE )
255
264
}
256
265
@@ -282,25 +291,66 @@ export default function EnvironmentOverview({
282
291
} )
283
292
}
284
293
285
- const environmentOverviewTableRows : EnvironmentOverviewTableProps [ 'rows' ] = appListData ?. appInfoList ?. map (
286
- ( appInfo ) => ( {
287
- environment : {
288
- id : appInfo . appId ,
289
- name : appInfo . application ,
290
- commits : appInfo . commits ,
291
- deployedAt : appInfo . lastDeployed ,
292
- status : appInfo . appStatus ,
293
- deploymentStatus : appInfo . deploymentStatus ,
294
- deployedBy : appInfo . lastDeployedBy ,
295
- lastDeployedImage : appInfo . lastDeployedImage ,
294
+ const environmentOverviewTableRows : EnvironmentOverviewTableRow [ ] = appListData ?. appInfoList ?. map ( ( appInfo ) => ( {
295
+ environment : {
296
+ id : appInfo . appId ,
297
+ name : appInfo . application ,
298
+ commits : appInfo . commits ,
299
+ deployedAt : appInfo . lastDeployed ,
300
+ status : appInfo . appStatus ,
301
+ deploymentStatus : appInfo . deploymentStatus ,
302
+ deployedBy : appInfo . lastDeployedBy ,
303
+ lastDeployedImage : appInfo . lastDeployedImage ,
304
+ } ,
305
+ popUpMenuItems : [
306
+ ...( ( ClonePipelineMenuButton && appListData . environment
307
+ ? [
308
+ < ClonePipelineMenuButton
309
+ sourceEnvironmentName = { appListData . environment }
310
+ onClick = { ( ) => {
311
+ setSelectedAppDetails ( appInfo )
312
+ setOpenClonePipelineConfig ( true )
313
+ } }
314
+ /> ,
315
+ ]
316
+ : [ ] ) as EnvironmentOverviewTableRow [ 'popUpMenuItems' ] ) ,
317
+ {
318
+ label : 'Hibernate' ,
319
+ Icon : HibernateIcon ,
320
+ iconType : null ,
321
+ disabled : ! appInfo . lastDeployed ,
322
+ onClick : ( ) => {
323
+ setSelectedAppDetails ( appInfo )
324
+ openHibernateModalPopup ( )
325
+ } ,
296
326
} ,
297
- isChecked : selectedAppDetailsList . some ( ( { appId } ) => appId === appInfo . appId ) ,
298
- onLastDeployedImageClick : openCommitInfoModal ( appInfo . ciArtifactId ) ,
299
- onCommitClick : openCommitInfoModal ( appInfo . ciArtifactId ) ,
300
- deployedAtLink : getDeploymentHistoryLink ( appInfo . appId , appInfo . pipelineId ) ,
301
- redirectLink : getAppRedirectLink ( appInfo . appId , + envId ) ,
302
- } ) ,
303
- )
327
+ {
328
+ label : 'Unhibernate' ,
329
+ Icon : UnhibernateIcon ,
330
+ iconType : null ,
331
+ disabled : ! appInfo . lastDeployed ,
332
+ onClick : ( ) => {
333
+ setSelectedAppDetails ( appInfo )
334
+ openUnHibernateModalPopup ( )
335
+ } ,
336
+ } ,
337
+ {
338
+ label : 'Restart Workload' ,
339
+ Icon : RotateIcon ,
340
+ iconType : 'stroke' ,
341
+ disabled : ! appInfo . lastDeployed ,
342
+ onClick : ( ) => {
343
+ setSelectedAppDetails ( appInfo )
344
+ onClickShowBulkRestartModal ( )
345
+ } ,
346
+ } ,
347
+ ] ,
348
+ isChecked : selectedAppDetailsList . some ( ( { appId } ) => appId === appInfo . appId ) ,
349
+ onLastDeployedImageClick : openCommitInfoModal ( appInfo . ciArtifactId ) ,
350
+ onCommitClick : openCommitInfoModal ( appInfo . ciArtifactId ) ,
351
+ deployedAtLink : getDeploymentHistoryLink ( appInfo . appId , appInfo . pipelineId ) ,
352
+ redirectLink : getAppRedirectLink ( appInfo . appId , + envId ) ,
353
+ } ) )
304
354
305
355
const renderSideInfoColumn = ( ) => {
306
356
return (
@@ -378,10 +428,10 @@ export default function EnvironmentOverview({
378
428
}
379
429
380
430
const renderOverviewModal = ( ) => {
381
- if ( location . search ?. includes ( URL_SEARCH_PARAMS . BULK_RESTART_WORKLOAD ) ) {
431
+ if ( isAppSelected && location . search ?. includes ( URL_SEARCH_PARAMS . BULK_RESTART_WORKLOAD ) ) {
382
432
return (
383
433
< RestartWorkloadModal
384
- selectedAppDetailsList = { selectedAppDetailsList }
434
+ selectedAppDetailsList = { selectedApps }
385
435
envName = { appListData . environment }
386
436
envId = { envId }
387
437
setRestartLoader = { setRestartLoader }
@@ -393,10 +443,10 @@ export default function EnvironmentOverview({
393
443
)
394
444
}
395
445
396
- if ( openedHibernateModalType ) {
446
+ if ( isAppSelected && openedHibernateModalType ) {
397
447
return (
398
448
< HibernateModal
399
- selectedAppDetailsList = { selectedAppDetailsList }
449
+ selectedAppDetailsList = { selectedApps }
400
450
appDetailsList = { appGroupListData . apps }
401
451
envId = { envId }
402
452
envName = { appListData . environment }
@@ -426,6 +476,17 @@ export default function EnvironmentOverview({
426
476
)
427
477
}
428
478
479
+ if ( ClonePipelineModal && isAppSelected && openClonePipelineConfig ) {
480
+ return (
481
+ < ClonePipelineModal
482
+ sourceEnvironmentName = { appListData . environment }
483
+ selectedAppDetailsList = { selectedApps }
484
+ handleCloseClonePipelineModal = { ( ) => setOpenClonePipelineConfig ( null ) }
485
+ httpProtocol = { httpProtocol }
486
+ />
487
+ )
488
+ }
489
+
429
490
if ( commitInfoModalConfig ) {
430
491
return (
431
492
< ArtifactInfoModal
@@ -457,7 +518,6 @@ export default function EnvironmentOverview({
457
518
httpProtocol = { httpProtocol . current }
458
519
/>
459
520
) }
460
-
461
521
< button
462
522
onClick = { openHibernateModalPopup }
463
523
className = "bcn-0 fs-12 dc__border dc__border-radius-4-imp flex h-28"
0 commit comments