@@ -20,15 +20,15 @@ import { importComponentFromFELibrary } from '../../../common'
20
20
import { ReactComponent as Close } from '../../../../assets/icons/ic-cross.svg'
21
21
import { ReactComponent as PlayIcon } from '../../../../assets/icons/misc/arrow-solid-right.svg'
22
22
import { ReactComponent as Warning } from '../../../../assets/icons/ic-warning.svg'
23
- import { ReactComponent as Error } from '../../../../assets/icons/ic-alert-triangle.svg'
23
+ import { ReactComponent as ICError } from '../../../../assets/icons/ic-alert-triangle.svg'
24
24
import { ReactComponent as Storage } from '../../../../assets/icons/ic-storage.svg'
25
25
import { ReactComponent as OpenInNew } from '../../../../assets/icons/ic-open-in-new.svg'
26
26
import { ReactComponent as InfoIcon } from '../../../../assets/icons/info-filled.svg'
27
27
import externalCiImg from '../../../../assets/img/external-ci.png'
28
28
import linkedCDBuildCIImg from '../../../../assets/img/linked-cd-bulk-ci.png'
29
29
import linkedCiImg from '../../../../assets/img/linked-ci.png'
30
30
import { getModuleConfigured } from '../../../app/details/appDetails/appDetails.service'
31
- import { DOCUMENTATION , ModuleNameMap , SourceTypeMap , SOURCE_NOT_CONFIGURED , URLS } from '../../../../config'
31
+ import { DOCUMENTATION , ModuleNameMap , SourceTypeMap , SOURCE_NOT_CONFIGURED , URLS , ViewType } from '../../../../config'
32
32
import MaterialSource from '../../../app/details/triggerView/MaterialSource'
33
33
import { TriggerViewContext } from '../../../app/details/triggerView/config'
34
34
import { getCIMaterialList } from '../../../app/service'
@@ -49,7 +49,7 @@ const getCIBlockState = importComponentFromFELibrary('getCIBlockState', null, 'f
49
49
const getRuntimeParams = importComponentFromFELibrary ( 'getRuntimeParams' , null , 'function' )
50
50
const GitInfoMaterialTabs = importComponentFromFELibrary ( 'GitInfoMaterialTabs' , null , 'function' )
51
51
52
- export default function BulkCITrigger ( {
52
+ const BulkCITrigger = ( {
53
53
appList,
54
54
closePopup,
55
55
updateBulkInputMaterial,
@@ -65,7 +65,8 @@ export default function BulkCITrigger({
65
65
setLoading,
66
66
runtimeParams,
67
67
setRuntimeParams,
68
- } : BulkCITriggerType ) {
68
+ setPageViewType,
69
+ } : BulkCITriggerType ) => {
69
70
const [ showRegexModal , setShowRegexModal ] = useState ( false )
70
71
const [ isChangeBranchClicked , setChangeBranchClicked ] = useState ( false )
71
72
const [ regexValue , setRegexValue ] = useState < Record < number , RegexValueType > > ( { } )
@@ -130,6 +131,33 @@ export default function BulkCITrigger({
130
131
getMaterialData ( )
131
132
} , [ ] )
132
133
134
+
135
+ const getRunTimeParamsData = ( _materialListMap : Record < string , any [ ] > ) : void => {
136
+ const runTimeParamsPromiseList = appList . map ( ( appDetails ) => {
137
+ if ( getIsAppUnorthodox ( appDetails ) || ! _materialListMap [ appDetails . appId ] ) {
138
+ return {
139
+ [ appDetails . ciPipelineId ] : [ ] ,
140
+ }
141
+ }
142
+ return getRuntimeParams ( appDetails . ciPipelineId )
143
+ } )
144
+
145
+ if ( runTimeParamsPromiseList ?. length ) {
146
+ Promise . all ( runTimeParamsPromiseList )
147
+ . then ( ( responses ) => {
148
+ const _runtimeParams : Record < string , KeyValueListType [ ] > = { }
149
+ responses . forEach ( ( res , index ) => {
150
+ _runtimeParams [ appList [ index ] ?. ciPipelineId ] = res || [ ]
151
+ } )
152
+ setRuntimeParams ( _runtimeParams )
153
+ } )
154
+ . catch ( ( error ) => {
155
+ setPageViewType ( ViewType . ERROR )
156
+ showError ( error )
157
+ } )
158
+ }
159
+ }
160
+
133
161
const getMaterialData = ( ) : void => {
134
162
abortControllerRef . current = new AbortController ( )
135
163
const _CIMaterialPromiseList = appList . map ( ( appDetails ) =>
@@ -197,6 +225,8 @@ export default function BulkCITrigger({
197
225
case KeyValueListActionType . DELETE :
198
226
_runtimeParams = _runtimeParams . filter ( ( _ , index ) => index !== data . index )
199
227
break
228
+ default :
229
+ throw new Error ( `Invalid action ${ action } ` )
200
230
}
201
231
202
232
setRuntimeParams ( {
@@ -209,37 +239,6 @@ export default function BulkCITrigger({
209
239
setCurrentSidebarTab ( e . target . value as CIMaterialSidebarType )
210
240
}
211
241
212
- const getRunTimeParamsData = ( _materialListMap : Record < string , any [ ] > ) : void => {
213
- const runTimeParamsPromiseList = appList . map ( ( appDetails ) => {
214
- if ( getIsAppUnorthodox ( appDetails ) || ! _materialListMap [ appDetails . appId ] ) {
215
- return {
216
- [ appDetails . ciPipelineId ] : [ ] ,
217
- }
218
- }
219
- return getRuntimeParams ( appDetails . ciPipelineId )
220
- } )
221
-
222
- if ( runTimeParamsPromiseList ?. length ) {
223
- Promise . allSettled ( runTimeParamsPromiseList )
224
- . then ( ( responses ) => {
225
- const _runtimeParams : Record < string , KeyValueListType [ ] > = { }
226
- responses . forEach ( ( res , index ) => {
227
- if ( res . status === 'fulfilled' ) {
228
- _runtimeParams [ appList [ index ] ?. ciPipelineId ] = res ?. [ 'value' ] || [ ]
229
- }
230
- else {
231
- // TODO: Add null
232
- _runtimeParams [ appList [ index ] ?. ciPipelineId ] = [ ]
233
- }
234
- } )
235
- setRuntimeParams ( _runtimeParams )
236
- } )
237
- . catch ( ( error ) => {
238
- showError ( error )
239
- } )
240
- }
241
- }
242
-
243
242
const getPolicyEnforcementData = ( _materialListMap : Record < string , any [ ] > ) : void => {
244
243
const policyPromiseList = appList . map ( ( appDetails ) => {
245
244
if ( getIsAppUnorthodox ( appDetails ) || ! _materialListMap [ appDetails . appId ] ) {
@@ -284,6 +283,7 @@ export default function BulkCITrigger({
284
283
className = "dc__transparent flex icon-dim-24"
285
284
disabled = { isLoading }
286
285
onClick = { closeBulkCIModal }
286
+ aria-label = "Close modal"
287
287
>
288
288
< Close className = "icon-dim-24" />
289
289
</ button >
@@ -411,10 +411,10 @@ export default function BulkCITrigger({
411
411
savingRegexValue = { isLoading }
412
412
/>
413
413
< div className = "flex right pr-20 pb-20" >
414
- < button className = "cta cancel h-28 lh-28-imp mr-16" onClick = { hideBranchEditModal } >
414
+ < button className = "cta cancel h-28 lh-28-imp mr-16" onClick = { hideBranchEditModal } type = "button" >
415
415
Cancel
416
416
</ button >
417
- < button className = "cta h-28 lh-28-imp" onClick = { saveBranchName } >
417
+ < button className = "cta h-28 lh-28-imp" onClick = { saveBranchName } type = "button" >
418
418
Save
419
419
</ button >
420
420
</ div >
@@ -588,7 +588,7 @@ export default function BulkCITrigger({
588
588
) }
589
589
{ app . appId !== selectedApp . appId && app . errorMessage && (
590
590
< span className = "flex left cr-5 fw-4 fs-12" >
591
- < Error className = "icon-dim-12 mr-4 mw-14" />
591
+ < ICError className = "icon-dim-12 mr-4 mw-14" />
592
592
< span className = "dc__block dc__ellipsis-right" > { app . errorMessage } </ span >
593
593
</ span >
594
594
) }
@@ -604,7 +604,7 @@ export default function BulkCITrigger({
604
604
return < Progressing pageLoader />
605
605
}
606
606
const selectedMaterialList = appList . find ( ( app ) => app . appId === selectedApp . appId ) ?. material || [ ]
607
- const sidebarTabs = Object . values ( CIMaterialSidebarType ) . map ( ( tabValue ) => ( {
607
+ const sidebarTabs = Object . values ( CIMaterialSidebarType ) . map ( ( tabValue ) => ( {
608
608
value : tabValue ,
609
609
label : tabValue ,
610
610
} ) )
@@ -702,6 +702,7 @@ export default function BulkCITrigger({
702
702
data-testid = "start-build"
703
703
onClick = { onClickStartBuild }
704
704
disabled = { isStartBuildDisabled ( ) }
705
+ type = "button"
705
706
>
706
707
{ isLoading ? (
707
708
< Progressing />
@@ -737,3 +738,5 @@ export default function BulkCITrigger({
737
738
</ Drawer >
738
739
)
739
740
}
741
+
742
+ export default BulkCITrigger
0 commit comments