@@ -20,6 +20,7 @@ import { getBranchIcon, getWebhookEventsForEventId, SourceTypeMap, Tooltip } fro
20
20
import { GIT_BRANCH_NOT_CONFIGURED , DEFAULT_GIT_BRANCH_VALUE } from './constants'
21
21
import { buildHoverHtmlForWebhook } from './utils'
22
22
import { CIPipelineSourceConfigInterface } from './types'
23
+ import { Icon } from '../Icon'
23
24
24
25
export const CiPipelineSourceConfig = ( {
25
26
sourceType,
@@ -38,9 +39,12 @@ export const CiPipelineSourceConfig = ({
38
39
const [ sourceValueBase , setSourceValueBase ] = useState ( '' )
39
40
const [ sourceValueAdv , setSourceValueAdv ] = useState < ReactNode > ( '' )
40
41
const [ loading , setLoading ] = useState ( ! ! _isWebhook )
42
+ const [ hasError , setHasError ] = useState ( false )
41
43
42
44
const updateSourceValue = ( ) => {
43
45
if ( _isWebhook ) {
46
+ setLoading ( true )
47
+ setHasError ( false )
44
48
const _sourceValueObj = JSON . parse ( sourceValue )
45
49
getWebhookEventsForEventId ( _sourceValueObj . eventId )
46
50
. then ( ( _res ) => {
@@ -55,8 +59,9 @@ export const CiPipelineSourceConfig = ({
55
59
)
56
60
setLoading ( false )
57
61
} )
58
- . catch ( ( error ) => {
59
- throw error
62
+ . catch ( ( ) => {
63
+ setLoading ( false )
64
+ setHasError ( true )
60
65
} )
61
66
} else {
62
67
setSourceValueBase ( sourceValue )
@@ -89,6 +94,9 @@ export const CiPipelineSourceConfig = ({
89
94
if ( ! _isWebhook ) {
90
95
return
91
96
}
97
+
98
+ setLoading ( true )
99
+ setHasError ( false )
92
100
const _sourceValueObj = JSON . parse ( sourceValue )
93
101
const _eventId = _sourceValueObj . eventId
94
102
const _condition = _sourceValueObj . condition
@@ -100,8 +108,9 @@ export const CiPipelineSourceConfig = ({
100
108
setSourceValueAdv ( buildHoverHtmlForWebhook ( _webhookEvent . name , _condition , _webhookEvent . selectors ) )
101
109
setLoading ( false )
102
110
} )
103
- . catch ( ( error ) => {
104
- throw error
111
+ . catch ( ( ) => {
112
+ setLoading ( false )
113
+ setHasError ( true )
105
114
} )
106
115
}
107
116
@@ -117,6 +126,15 @@ export const CiPipelineSourceConfig = ({
117
126
regexTippyContent ( )
118
127
} , [ ] )
119
128
129
+ if ( ! loading && hasError ) {
130
+ return (
131
+ < div className = "flex left dc__gap-4" >
132
+ < Icon name = "ic-error" size = { 16 } color = { null } />
133
+ < span className = "dc__truncate fw-5 cr-5" > Failed to fetch</ span >
134
+ </ div >
135
+ )
136
+ }
137
+
120
138
return (
121
139
< div className = { `flex left ${ showTooltip ? 'fw-5' : '' } ${ rootClassName } ` } >
122
140
{ loading && showIcons && < span className = "dc__loading-dots" > loading</ span > }
0 commit comments