6
6
* - If !isLoading and filteredCIPipelines does not contain the selected pipeline, we will show error
7
7
*/
8
8
9
- import { SyntheticEvent , useEffect , useRef , useState } from 'react'
9
+ import { useEffect , useRef , useState } from 'react'
10
10
import { Prompt , useHistory , useParams } from 'react-router-dom'
11
11
12
12
import {
13
13
APIResponseHandler ,
14
14
Button ,
15
15
Checkbox ,
16
16
CIPipelineNodeType ,
17
- CommonNodeAttr ,
18
17
ComponentSizeType ,
19
18
ConsequenceAction ,
20
19
DEFAULT_ROUTE_PROMPT_MESSAGE ,
@@ -64,6 +63,7 @@ const BuildImageModal = ({
64
63
reloadWorkflows,
65
64
appId : appIdProp ,
66
65
environmentLists,
66
+ reloadWorkflowStatus,
67
67
} : BuildImageModalProps ) => {
68
68
const { push } = useHistory ( )
69
69
const { ciNodeId } = useParams < Pick < CIMaterialRouterProps , 'ciNodeId' > > ( )
@@ -89,7 +89,7 @@ const BuildImageModal = ({
89
89
const appId = appIdProp || selectedWorkflow ?. appId
90
90
const filteredCIPipelines = filteredCIPipelinesProp || filteredCIPipelineMap ?. get ( String ( appId ) ) || [ ]
91
91
92
- const selectedCIPipeline = ( filteredCIPipelines || [ ] ) . find ( ( _ci ) => _ci . id === + ciNodeId )
92
+ const selectedCIPipeline = filteredCIPipelines . find ( ( _ci ) => _ci . id === + ciNodeId )
93
93
94
94
usePrompt ( {
95
95
shouldPrompt : isBuildTriggerLoading ,
@@ -98,10 +98,11 @@ const BuildImageModal = ({
98
98
const [ areRuntimeParamsLoading , runtimeParams , runtimeParamsError , reloadRuntimeParams , setRuntimeParams ] =
99
99
useAsync < GitInfoMaterialProps [ 'runtimeParams' ] > (
100
100
( ) => getRuntimeParams ( ciNodeId , true ) ,
101
- [ ciNodeId ] ,
102
- ! ! ciNodeId && ! ! getRuntimeParams ,
101
+ [ ciNodeId , ciNode ?. isTriggerBlocked ] ,
102
+ ! ! ciNodeId && ! ciNode ?. isTriggerBlocked && ! ! getRuntimeParams ,
103
103
)
104
104
105
+ // Just added abortController for first time mount and unmount, no need to use it later since, if materials are loading then loading state will be true
105
106
const [ isMaterialListLoading , _materialList , materialListError , reloadMaterialList , setMaterialList ] = useAsync (
106
107
( ) =>
107
108
getCIMaterials ( {
@@ -110,16 +111,20 @@ const BuildImageModal = ({
110
111
isCINodePresent : ! ! ciNode ,
111
112
selectedWorkflow,
112
113
} ) ,
113
- [ ciNodeId ] ,
114
- ! ! ciNodeId ,
114
+ [ ciNodeId , ciNode ?. isTriggerBlocked ] ,
115
+ ! ! ciNodeId && ! ciNode ?. isTriggerBlocked ,
115
116
)
116
117
117
118
const materialList = _materialList || [ ]
118
119
119
- const [ isLoadingBlobStorageModule , blobStorageModuleRes , , reloadBlobStorageModule ] = useAsync ( ( ) =>
120
- getModuleConfigured ( ModuleNameMap . BLOB_STORAGE ) ,
120
+ const [ isLoadingBlobStorageModule , blobStorageModuleRes , , reloadBlobStorageModule ] = useAsync (
121
+ ( ) => getModuleConfigured ( ModuleNameMap . BLOB_STORAGE ) ,
122
+ [ ciNode ?. isTriggerBlocked ] ,
123
+ ! ciNode ?. isTriggerBlocked ,
121
124
)
122
125
126
+ const isBlobStorageConfigured = ! ! blobStorageModuleRes ?. result ?. enabled
127
+
123
128
useEffect ( ( ) => {
124
129
if ( isJobView && environmentLists ?. length > 0 ) {
125
130
const envId = selectedCIPipeline ?. environmentId || 0
@@ -130,8 +135,6 @@ const BuildImageModal = ({
130
135
return ( ) => materialListAbortControllerRef . current . abort ( )
131
136
} , [ ] )
132
137
133
- const isBlobStorageConfigured = ! ! blobStorageModuleRes ?. result ?. enabled
134
-
135
138
const handleReload = ( ) => {
136
139
reloadMaterialList ( )
137
140
reloadRuntimeParams ( )
@@ -148,6 +151,7 @@ const BuildImageModal = ({
148
151
}
149
152
150
153
const showContentLoader = areRuntimeParamsLoading || isMaterialListLoading || isLoadingBlobStorageModule
154
+ const screenErrorData = materialListError || runtimeParamsError
151
155
152
156
const getErrorScreenManagerProps = ( ) : ErrorScreenManagerProps => {
153
157
if ( materialListError ) {
@@ -194,11 +198,11 @@ const BuildImageModal = ({
194
198
195
199
const payload = getTriggerBuildPayload ( {
196
200
materialList,
197
- ciConfiguredGitMaterialId : selectedWorkflow ? .ciConfiguredGitMaterialId ,
201
+ ciConfiguredGitMaterialId : selectedWorkflow . ciConfiguredGitMaterialId ,
198
202
runtimeParams,
199
203
selectedEnv,
200
204
invalidateCache,
201
- isJobCI : ciNode ? .isJobCI ,
205
+ isJobCI : ciNode . isJobCI ,
202
206
ciNodeId : + ciNodeId ,
203
207
} )
204
208
@@ -213,6 +217,7 @@ const BuildImageModal = ({
213
217
214
218
try {
215
219
await triggerBuild ( { payload, redirectToCIPipeline } )
220
+ reloadWorkflowStatus ( )
216
221
handleClose ( )
217
222
} catch {
218
223
// Do nothing
@@ -225,7 +230,7 @@ const BuildImageModal = ({
225
230
setRuntimeParams ( updatedRuntimeParams )
226
231
}
227
232
228
- const handleStartBuildAction = async ( e : SyntheticEvent ) => {
233
+ const handleStartBuildAction = async ( ) => {
229
234
const runtimeParamsUpdatedErrorState = validateRuntimeParameters ( runtimeParams )
230
235
handleRuntimeParamError ( runtimeParamsUpdatedErrorState )
231
236
@@ -237,7 +242,6 @@ const BuildImageModal = ({
237
242
return
238
243
}
239
244
240
- e . stopPropagation ( )
241
245
await onClickTriggerCINode ( )
242
246
}
243
247
@@ -264,8 +268,6 @@ const BuildImageModal = ({
264
268
}
265
269
266
270
const renderCTAButton = ( ) => {
267
- const nodeType : CommonNodeAttr [ 'type' ] = 'CI'
268
-
269
271
if (
270
272
AllowedWithWarningTippy &&
271
273
ciNode ?. pluginBlockState ?. action === ConsequenceAction . ALLOW_UNTIL_TIME &&
@@ -274,18 +276,10 @@ const BuildImageModal = ({
274
276
return (
275
277
< AllowedWithWarningTippy
276
278
consequence = { ciNode . pluginBlockState }
277
- configurePluginURL = { getCIPipelineURL (
278
- String ( appId ) ,
279
- String ( workflowId ) ,
280
- true ,
281
- ciNodeId ,
282
- false ,
283
- ciNode . isJobCI ,
284
- false ,
285
- ) }
279
+ configurePluginURL = { getCIPipelineURLWrapper ( ) }
286
280
showTriggerButton
287
281
onTrigger = { handleStartBuildAction }
288
- nodeType = { nodeType }
282
+ nodeType = { WorkflowNodeType . CI }
289
283
isJobView = { ciNode . isJobCI }
290
284
>
291
285
{ renderCTAButtonWithIcon ( false ) }
@@ -309,21 +303,25 @@ const BuildImageModal = ({
309
303
const renderCacheInfo = ( ) => {
310
304
if ( ciNode ?. status ?. toLowerCase ( ) === BUILD_STATUS . NOT_TRIGGERED ) {
311
305
return (
312
- < div className = "flexbox dc__align-items-center dc__gap-8" >
313
- < Icon name = "ic-info-filled" color = "B500" size = { 20 } />
314
- < div >
315
- < div className = "fw-6 fs-13" > { IGNORE_CACHE_INFO . FirstTrigger . title } </ div >
316
- < div className = "fw-4 fs-12" > { IGNORE_CACHE_INFO . FirstTrigger . infoText } </ div >
306
+ < div className = "flexbox dc__gap-8" >
307
+ < div className = "m-4" >
308
+ < Icon name = "ic-info-filled" color = "B500" size = { 20 } />
309
+ </ div >
310
+ < div className = "flexbox-col" >
311
+ < span className = "fw-6 fs-13" > { IGNORE_CACHE_INFO . FirstTrigger . title } </ span >
312
+ < span className = "fw-4 fs-12" > { IGNORE_CACHE_INFO . FirstTrigger . infoText } </ span >
317
313
</ div >
318
314
</ div >
319
315
)
320
316
}
321
317
if ( ! isBlobStorageConfigured ) {
322
318
return (
323
- < div className = "flexbox dc__align-items-center dc__gap-8" >
324
- < Icon name = "ic-storage" color = { null } size = { 24 } />
325
- < div >
326
- < div className = "fw-6 fs-13" > { IGNORE_CACHE_INFO . BlobStorageNotConfigured . title } </ div >
319
+ < div className = "flexbox dc__gap-8" >
320
+ < div className = "m-4" >
321
+ < Icon name = "ic-storage" color = { null } size = { 24 } />
322
+ </ div >
323
+ < div className = "flexbox-col" >
324
+ < span className = "fw-6 fs-13" > { IGNORE_CACHE_INFO . BlobStorageNotConfigured . title } </ span >
327
325
< div className = "fw-4 fs-12 flexbox" >
328
326
< span > { IGNORE_CACHE_INFO . BlobStorageNotConfigured . infoText } </ span >
329
327
< DocLink
@@ -342,26 +340,27 @@ const BuildImageModal = ({
342
340
}
343
341
if ( ! ciNode ?. storageConfigured ) {
344
342
return (
345
- < div className = "flexbox dc__align-items-center dc__gap-8" >
346
- < Icon name = "ic-info-filled" color = "B500" size = { 20 } />
347
- < div >
348
- < div className = "fw-6 fs-13" > { IGNORE_CACHE_INFO . CacheNotAvailable . title } </ div >
349
- < div className = "fw-4 fs-12" > { IGNORE_CACHE_INFO . CacheNotAvailable . infoText } </ div >
343
+ < div className = "flexbox dc__gap-8" >
344
+ < div className = "m-4" >
345
+ < Icon name = "ic-info-filled" color = "B500" size = { 20 } />
346
+ </ div >
347
+ < div className = "flexbox-col" >
348
+ < span className = "fw-6 fs-13" > { IGNORE_CACHE_INFO . CacheNotAvailable . title } </ span >
349
+ < span className = "fw-4 fs-12" > { IGNORE_CACHE_INFO . CacheNotAvailable . infoText } </ span >
350
350
</ div >
351
351
</ div >
352
352
)
353
353
}
354
354
return (
355
355
< Checkbox
356
356
isChecked = { invalidateCache }
357
- onClick = { stopPropagation }
358
357
rootClassName = "mb-0 flex top"
359
358
value = "CHECKED"
360
359
onChange = { toggleInvalidateCache }
361
360
data-testid = "set-clone-directory"
362
361
>
363
- < div >
364
- < div className = "fs-13 fw-6 lh-20" > { IGNORE_CACHE_INFO . IgnoreCache . title } </ div >
362
+ < div className = "flexbox-col" >
363
+ < span className = "fs-13 fw-6 lh-20" > { IGNORE_CACHE_INFO . IgnoreCache . title } </ span >
365
364
366
365
< div className = "flex dc__gap-4" >
367
366
< span className = "fs-12 fw-4 lh-16" > { IGNORE_CACHE_INFO . IgnoreCache . infoText } </ span >
@@ -377,17 +376,16 @@ const BuildImageModal = ({
377
376
)
378
377
}
379
378
380
- // TODO: Make sure empty states in case of filter
381
379
const renderContent = ( ) => (
382
380
< APIResponseHandler
383
381
isLoading = { showContentLoader }
384
- error = { materialListError }
382
+ error = { screenErrorData }
385
383
errorScreenManagerProps = { getErrorScreenManagerProps ( ) }
386
384
progressingProps = { {
387
385
pageLoader : true ,
388
386
} }
389
387
>
390
- { ! showContentLoader && (
388
+ { ! showContentLoader && ! screenErrorData && (
391
389
< GitInfoMaterial
392
390
appId = { appId }
393
391
workflowId = { selectedWorkflow ?. id }
@@ -429,7 +427,7 @@ const BuildImageModal = ({
429
427
< div className = "flex-grow-1 dc__overflow-auto w-100" > { renderContent ( ) } </ div >
430
428
</ div >
431
429
432
- { ciNode ?. isTriggerBlocked || showWebhookModal || materialListError ? null : (
430
+ { ciNode ?. isTriggerBlocked || showWebhookModal || ! ! screenErrorData ? null : (
433
431
< div className = "flexbox dc__content-space dc__gap-12 py-16 px-20 border__primary--top dc__no-shrink" >
434
432
{ isJobView ? renderEnvironments ( ) : renderCacheInfo ( ) }
435
433
{ renderCTAButton ( ) }
0 commit comments