Skip to content

Commit 71a643f

Browse files
authored
Merge pull request #646 from devtron-labs/fix/source-node-error-state
fix: add error handling and loading state to webhook event fetching
2 parents c292ac3 + 5a13035 commit 71a643f

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.9.0-patch-3",
3+
"version": "1.9.0-patch-4",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/CodeMirror/codeEditor.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
}
126126

127127
.cm-panels {
128-
background-color: var(--bg-code-editor-base);
128+
background-color: transparent;
129129
z-index: 1;
130130
}
131131

src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { getBranchIcon, getWebhookEventsForEventId, SourceTypeMap, Tooltip } fro
2020
import { GIT_BRANCH_NOT_CONFIGURED, DEFAULT_GIT_BRANCH_VALUE } from './constants'
2121
import { buildHoverHtmlForWebhook } from './utils'
2222
import { CIPipelineSourceConfigInterface } from './types'
23+
import { Icon } from '../Icon'
2324

2425
export const CiPipelineSourceConfig = ({
2526
sourceType,
@@ -38,9 +39,12 @@ export const CiPipelineSourceConfig = ({
3839
const [sourceValueBase, setSourceValueBase] = useState('')
3940
const [sourceValueAdv, setSourceValueAdv] = useState<ReactNode>('')
4041
const [loading, setLoading] = useState(!!_isWebhook)
42+
const [hasError, setHasError] = useState(false)
4143

4244
const updateSourceValue = () => {
4345
if (_isWebhook) {
46+
setLoading(true)
47+
setHasError(false)
4448
const _sourceValueObj = JSON.parse(sourceValue)
4549
getWebhookEventsForEventId(_sourceValueObj.eventId)
4650
.then((_res) => {
@@ -55,8 +59,9 @@ export const CiPipelineSourceConfig = ({
5559
)
5660
setLoading(false)
5761
})
58-
.catch((error) => {
59-
throw error
62+
.catch(() => {
63+
setLoading(false)
64+
setHasError(true)
6065
})
6166
} else {
6267
setSourceValueBase(sourceValue)
@@ -89,6 +94,9 @@ export const CiPipelineSourceConfig = ({
8994
if (!_isWebhook) {
9095
return
9196
}
97+
98+
setLoading(true)
99+
setHasError(false)
92100
const _sourceValueObj = JSON.parse(sourceValue)
93101
const _eventId = _sourceValueObj.eventId
94102
const _condition = _sourceValueObj.condition
@@ -100,8 +108,9 @@ export const CiPipelineSourceConfig = ({
100108
setSourceValueAdv(buildHoverHtmlForWebhook(_webhookEvent.name, _condition, _webhookEvent.selectors))
101109
setLoading(false)
102110
})
103-
.catch((error) => {
104-
throw error
111+
.catch(() => {
112+
setLoading(false)
113+
setHasError(true)
105114
})
106115
}
107116

@@ -117,6 +126,15 @@ export const CiPipelineSourceConfig = ({
117126
regexTippyContent()
118127
}, [])
119128

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+
120138
return (
121139
<div className={`flex left ${showTooltip ? 'fw-5' : ''} ${rootClassName}`}>
122140
{loading && showIcons && <span className="dc__loading-dots">loading</span>}

0 commit comments

Comments
 (0)