Skip to content

Commit 5434e54

Browse files
authored
Merge pull request #651 from devtron-labs/sync-rc-32-main
chore: sync rc with main
2 parents 3822516 + a918805 commit 5434e54

File tree

6 files changed

+65
-50
lines changed

6 files changed

+65
-50
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.8",
3+
"version": "1.9.9",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/CodeMirror/CodeEditorRenderer.tsx

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -177,29 +177,54 @@ export const CodeEditorRenderer = ({
177177
updateDiffMinimapValues(diffMinimapRef.current, vu.transactions, 'b')
178178
})
179179

180-
// DIFF VIEW INITIALIZATION
181180
useEffect(() => {
181+
// DIFF VIEW INITIALIZATION
182182
if (!loading && codeMirrorMergeParentRef.current) {
183-
setCodeMirrorMergeInstance(
184-
new MergeView({
183+
codeMirrorMergeInstance?.destroy()
184+
185+
const codeMirrorMergeView = new MergeView({
186+
a: {
187+
doc: lhsValue,
188+
extensions: [...originalViewExtensions, originalUpdateListener],
189+
},
190+
b: {
191+
doc: value,
192+
extensions: [...modifiedViewExtensions, modifiedUpdateListener],
193+
},
194+
...(!readOnly ? { revertControls: 'a-to-b', renderRevertControl: getRevertControlButton } : {}),
195+
diffConfig: { scanLimit: 5000 },
196+
parent: codeMirrorMergeParentRef.current,
197+
})
198+
setCodeMirrorMergeInstance(codeMirrorMergeView)
199+
200+
// MINIMAP INITIALIZATION
201+
if (codeMirrorMergeView && diffMinimapParentRef.current) {
202+
diffMinimapInstance?.destroy()
203+
diffMinimapRef.current?.destroy()
204+
205+
const diffMinimapMergeView = new MergeView({
185206
a: {
186207
doc: lhsValue,
187-
extensions: [...originalViewExtensions, originalUpdateListener],
208+
extensions: diffMinimapExtensions,
188209
},
189210
b: {
190211
doc: value,
191-
extensions: [...modifiedViewExtensions, modifiedUpdateListener],
212+
extensions: diffMinimapExtensions,
192213
},
193-
...(!readOnly ? { revertControls: 'a-to-b', renderRevertControl: getRevertControlButton } : {}),
214+
gutter: false,
194215
diffConfig: { scanLimit: 5000 },
195-
parent: codeMirrorMergeParentRef.current,
196-
}),
197-
)
216+
parent: diffMinimapParentRef.current,
217+
})
218+
219+
diffMinimapRef.current = diffMinimapMergeView
220+
setDiffMinimapInstance(diffMinimapMergeView)
221+
}
198222
}
199223

200224
return () => {
201-
codeMirrorMergeInstance?.destroy()
202225
setCodeMirrorMergeInstance(null)
226+
setDiffMinimapInstance(null)
227+
diffMinimapRef.current = null
203228
}
204229
}, [loading, codemirrorMergeKey, diffMode])
205230

@@ -216,39 +241,11 @@ export const CodeEditorRenderer = ({
216241
const modifiedDoc = codeMirrorMergeInstance.b.state.doc.toString()
217242
if (modifiedDoc !== value) {
218243
codeMirrorMergeInstance.b.dispatch({
219-
changes: { from: 0, to: originalDoc.length, insert: value || '' },
244+
changes: { from: 0, to: modifiedDoc.length, insert: value || '' },
220245
})
221246
}
222247
}
223-
}, [lhsValue, value])
224-
225-
// MINIMAP INITIALIZATION
226-
useEffect(() => {
227-
if (codeMirrorMergeInstance && diffMinimapParentRef.current) {
228-
const diffMinimapMergeView = new MergeView({
229-
a: {
230-
doc: lhsValue,
231-
extensions: diffMinimapExtensions,
232-
},
233-
b: {
234-
doc: value,
235-
extensions: diffMinimapExtensions,
236-
},
237-
gutter: false,
238-
diffConfig: { scanLimit: 5000 },
239-
parent: diffMinimapParentRef.current,
240-
})
241-
242-
diffMinimapRef.current = diffMinimapMergeView
243-
setDiffMinimapInstance(diffMinimapMergeView)
244-
}
245-
246-
return () => {
247-
diffMinimapInstance?.destroy()
248-
setDiffMinimapInstance(null)
249-
diffMinimapRef.current = null
250-
}
251-
}, [codeMirrorMergeInstance])
248+
}, [lhsValue, value, codeMirrorMergeInstance])
252249

253250
// SCALING FACTOR UPDATER
254251
useEffect(() => {

src/Common/CodeMirror/Extensions/DiffMinimap.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const DiffMinimap = ({ view, theme, diffMinimapParentRef, scalingFactor }
4040

4141
useEffect(() => {
4242
updateOverlay()
43-
}, [scalingFactor])
43+
}, [view, scalingFactor])
4444

4545
// Sync overlay scrolling with the diff view
4646
const handleDiffScroll = () => {
@@ -109,7 +109,7 @@ export const DiffMinimap = ({ view, theme, diffMinimapParentRef, scalingFactor }
109109
document.removeEventListener('mousemove', handleOverlayMouseMove)
110110
document.removeEventListener('mouseup', handleOverlayMouseUp)
111111
}
112-
}, [isDragging])
112+
}, [view, isDragging])
113113

114114
// Clicking on the minimap scrolls the diff viewer
115115
const handleMinimapClick = (event: React.MouseEvent<HTMLDivElement>) => {

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)