Skip to content

Commit 29d438d

Browse files
authored
Merge pull request #561 from devtron-labs/fix/codemirror-1
fix: CodeEditor - scss + yamlLint fixes
2 parents 0269337 + d47942c commit 29d438d

File tree

5 files changed

+42
-32
lines changed

5 files changed

+42
-32
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.6.11",
3+
"version": "1.6.12",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

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/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
}

src/Shared/Components/CMCS/ConfigMapSecretReadyOnly.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const ConfigMapSecretReadyOnly = ({
5050
<div
5151
className={
5252
containerClassName ||
53-
`bg__primary flex-grow-1 flexbox-col dc__gap-12 dc__overflow-auto ${!hideCodeEditor ? 'p-16' : ''}`
53+
`bg__primary flexbox-col dc__gap-12 dc__overflow-auto ${!hideCodeEditor ? 'p-16' : ''}`
5454
}
5555
>
5656
{hasHashiOrAWS(configMapSecretData?.externalType) && renderHashiOrAwsDeprecatedInfo()}

0 commit comments

Comments
 (0)