Skip to content

Commit 757976c

Browse files
committed
Merge branch 'develop' into feat/onboard-argo-apps
2 parents b312dc6 + 29d438d commit 757976c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+868
-575
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ src/Common/CustomTagSelector/ValidationRules.ts
2020
src/Common/DebouncedSearch/DebouncedSearch.tsx
2121
src/Common/DebouncedSearch/Utils.ts
2222
src/Common/DebouncedSearch/__tests__/DebouncedSearch.test.tsx
23-
src/Common/DeleteComponentModal/DeleteComponent.tsx
2423
src/Common/DevtronProgressing/DevtronProgressing.tsx
2524
src/Common/Dialogs/ConfirmationDialog.tsx
2625
src/Common/Dialogs/DialogForm.tsx
27-
src/Common/Dialogs/ForceDeleteDialog.tsx
2826
src/Common/DraggableWrapper/DraggableButton.tsx
2927
src/Common/DraggableWrapper/DraggableWrapper.tsx
3028
src/Common/Drawer/Drawer.tsx

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* vivek@devtron.ai @vikramdevtron
1+
* @vivek-devtron @vikramdevtron

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.6.2",
3+
"version": "1.6.12",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -70,7 +70,7 @@
7070
"sharp": "^0.33.5",
7171
"svgo": "^3.3.2",
7272
"typescript": "5.5.4",
73-
"vite": "5.4.11",
73+
"vite": "5.4.14",
7474
"vite-plugin-dts": "4.0.3",
7575
"vite-plugin-image-optimizer": "^1.1.8",
7676
"vite-plugin-lib-inject-css": "2.1.1",
@@ -127,7 +127,7 @@
127127
"react-dom": "^17.0.2"
128128
},
129129
"vite-plugin-svgr": {
130-
"vite": "5.4.11"
130+
"vite": "5.4.14"
131131
},
132132
"react-virtualized-sticky-tree": {
133133
"react": "^17.0.2",

src/Common/CodeEditor/CodeEditor.components.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const Header = ({ children, className, hideDefaultSplitHeader }: CodeEdit
4343

4444
export const Warning = ({ className, text, children }: CodeEditorStatusBarProps) => (
4545
<div
46-
className={`code-editor__warning fs-12 fw-4 lh-16 cn-9 py-8 px-16 bcy-1 bw-1 ey-2 dc__height-auto ${className || ''}`}
46+
className={`code-editor__warning fs-12 fw-4 lh-16 cn-9 py-8 px-16 bcy-1 dc__border-bottom-y2 dc__height-auto ${className || ''}`}
4747
>
4848
<ICWarningY5 className="code-editor__status-info-icon" />
4949
{text}
@@ -52,7 +52,7 @@ export const Warning = ({ className, text, children }: CodeEditorStatusBarProps)
5252
)
5353

5454
export const ErrorBar = ({ className, text, children }: CodeEditorStatusBarProps) => (
55-
<div className={`code-editor__error fs-12 fw-4 lh-16 py-8 px-16 dc__border-bottom bco-1 co-5 ${className || ''}`}>
55+
<div className={`code-editor__error fs-12 fw-4 lh-16 py-8 px-16 bco-1 co-5 dc__border-bottom ${className || ''}`}>
5656
<ErrorIcon className="code-editor__status-info-icon" />
5757
{text}
5858
{children}
@@ -61,7 +61,7 @@ export const ErrorBar = ({ className, text, children }: CodeEditorStatusBarProps
6161

6262
export const Information = ({ className, children, text }: CodeEditorStatusBarProps) => (
6363
<div
64-
className={`code-editor__information fs-12 fw-4 lh-16 cn-9 dc__height-auto py-8 px-16 dc__border-bottom bcb-1 ${className || ''}`}
64+
className={`code-editor__information fs-12 fw-4 lh-16 cn-9 py-8 px-16 bcb-1 dc__border-bottom dc__height-auto ${className || ''}`}
6565
>
6666
<Info className="code-editor__status-info-icon" />
6767
{text}

src/Common/CodeEditor/CodeEditor.theme.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export const getCodeEditorTheme = (isDark: boolean) => {
99
fontSize: '14px',
1010
fontFamily: 'Inconsolata, monospace',
1111
background: 'var(--bg-code-editor-base)',
12-
foreground: isDark ? 'var(--white)' : 'var(--black)',
13-
caret: isDark ? 'var(--white)' : 'var(--black)',
12+
foreground: 'var(--N900)',
13+
caret: 'var(--N900)',
1414
gutterBackground: 'var(--bg-code-editor-base-gutter)',
15-
gutterForeground: isDark ? 'var(--white)' : 'var(--black)',
15+
gutterForeground: 'var(--N900)',
1616
gutterBorder: 'transparent',
1717
lineHighlight: 'var(--active-line)',
1818
},

src/Common/CodeEditor/CodeEditor.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ const CodeEditor = <DiffView extends boolean = false>({
175175
defaultKeymap: false,
176176
searchKeymap: false,
177177
foldGutter: false,
178-
// TODO: need to remove this after getting proper colors from design
179178
drawSelection: false,
180179
highlightActiveLineGutter: false,
181180
tabSize,

src/Common/CodeEditor/CodeEditorRenderer.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,19 @@ export const CodeEditorRenderer = ({
3131
}: CodeEditorRendererProps) => {
3232
// STATES
3333
const [isFocused, setIsFocused] = useState(false)
34+
const [gutterWidth, setGutterWidth] = useState(0)
3435

3536
// REFS
3637
const codeMirrorRef = useRef<ReactCodeMirrorRef>()
3738

39+
// This handling will be removed once shebang is shown inside the codeEditor rather than extra div
40+
const updateGutterWith = () => {
41+
const gutters = document.querySelector('.cm-gutters')
42+
if (gutters) {
43+
setGutterWidth(gutters.getBoundingClientRect().width)
44+
}
45+
}
46+
3847
useEffect(() => {
3948
// Added timeout to ensure the autofocus code is executed post the re-renders
4049
setTimeout(() => {
@@ -46,17 +55,23 @@ export const CodeEditorRenderer = ({
4655

4756
// STOPPING OVERSCROLL BROWSER BACK/FORWARD BEHAVIOR WHEN CODE EDITOR IS FOCUSED
4857
useEffect(() => {
49-
const html = document.querySelector('html')
50-
if (html) {
58+
const body = document.querySelector('body')
59+
if (body) {
5160
const { scrollWidth, clientWidth } = codeMirrorRef.current?.view?.scrollDOM ?? {}
5261
if (isFocused && scrollWidth > clientWidth) {
53-
html.classList.add('dc__overscroll-none')
62+
body.classList.add('dc__overscroll-none')
5463
} else {
55-
html.classList.remove('dc__overscroll-none')
64+
body.classList.remove('dc__overscroll-none')
5665
}
5766
}
67+
68+
updateGutterWith()
5869
}, [state.lhsCode, state.code, isFocused])
5970

71+
const onCreateEditor = () => {
72+
updateGutterWith()
73+
}
74+
6075
const handleOnFocus: FocusEventHandler<HTMLDivElement> = (e) => {
6176
setIsFocused(true)
6277
onFocus?.(e)
@@ -105,12 +120,15 @@ export const CodeEditorRenderer = ({
105120
) : (
106121
<div ref={codeMirrorParentDivRef} className={`w-100 ${codeEditorParentClassName}`}>
107122
{shebang && (
108-
<div
109-
className={`flexbox text__white code-editor__shebang ${isDarkTheme ? 'code-editor__shebang__dark' : 'code-editor__shebang__light'}`}
123+
<p
124+
className={`m-0 flexbox cn-9 code-editor__shebang ${isDarkTheme ? 'code-editor__shebang__dark' : 'code-editor__shebang__light'}`}
110125
>
111-
<div className="code-editor__shebang__gutter dc__align-self-stretch" />
126+
<span
127+
className="code-editor__shebang__gutter dc__align-self-stretch"
128+
style={{ flex: `0 0 ${gutterWidth}px` }}
129+
/>
112130
{shebang}
113-
</div>
131+
</p>
114132
)}
115133
<CodeMirror
116134
ref={codeMirrorRef}
@@ -122,6 +140,7 @@ export const CodeEditorRenderer = ({
122140
readOnly={readOnly}
123141
height={codeEditorHeight}
124142
minHeight="250px"
143+
onCreateEditor={onCreateEditor}
125144
onFocus={handleOnFocus}
126145
onBlur={handleOnBlur}
127146
onChange={handleOnChange}

src/Common/CodeEditor/Extensions/findAndReplace.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ export const codeEditorFindReplace = (view: EditorView): Panel => {
432432
findField?.select()
433433
}
434434

435-
const update = ({ transactions, changes }: ViewUpdate) => {
435+
const update = ({ transactions, docChanged, state, startState }: ViewUpdate) => {
436436
transactions.forEach((tr) => {
437437
tr.effects.forEach((effect) => {
438438
if (effect.is(setSearchQuery)) {
@@ -441,7 +441,7 @@ export const codeEditorFindReplace = (view: EditorView): Panel => {
441441
})
442442
})
443443

444-
if (changes) {
444+
if (docChanged || state.readOnly !== startState.readOnly) {
445445
renderFindReplace()
446446
}
447447
}

src/Common/CodeEditor/Extensions/yamlParseLinter.ts

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,44 @@ export const yamlParseLinter =
88
const diagnostics: Diagnostic[] = []
99
const text = view.state.doc.toString()
1010

11-
// Parse YAML
12-
const documents = YAML.parseAllDocuments(text)
11+
try {
12+
// Parse YAML
13+
const documents = YAML.parseAllDocuments(text)
1314

14-
// Handle YAML parse errors
15-
documents.forEach(({ errors }) => {
16-
errors.forEach((err) => {
17-
if (err instanceof YAMLParseError) {
18-
const { linePos = [], message } = err
19-
const { from } = view.state.doc.line(linePos[0]?.line || 0)
15+
// Handle YAML parse errors
16+
documents.forEach(({ errors }) => {
17+
errors.forEach((err) => {
18+
if (err instanceof YAMLParseError) {
19+
const { linePos = [], message } = err
20+
const { from } = view.state.doc.line(linePos[0]?.line || 0)
2021

21-
diagnostics.push({
22-
from,
23-
to: from + (linePos[0]?.col || 0),
24-
message: message.replace(/\n+/g, '\n'),
25-
severity: 'error',
26-
source: err.name,
27-
})
28-
} else {
29-
diagnostics.push({
30-
from: 0,
31-
to: text.length,
32-
message: err instanceof Error ? err.message : 'Unknown error',
33-
severity: 'error',
34-
source: err.name,
35-
})
36-
}
22+
diagnostics.push({
23+
from,
24+
to: Math.min(from + (linePos[0]?.col || 0), text.length),
25+
message: message.replace(/\n+/g, '\n'),
26+
severity: 'error',
27+
source: err.name,
28+
})
29+
} else {
30+
diagnostics.push({
31+
from: 0,
32+
to: text.length,
33+
message: err instanceof Error ? err.message : 'Unknown error',
34+
severity: 'error',
35+
source: err.name,
36+
})
37+
}
38+
})
3739
})
38-
})
40+
} catch (err) {
41+
diagnostics.push({
42+
from: 0,
43+
to: text.length,
44+
message: err instanceof Error ? err.message : 'Yaml lint failed',
45+
severity: 'error',
46+
source: err.name,
47+
})
48+
}
3949

4050
return diagnostics
4151
}

0 commit comments

Comments
 (0)