RED-8692 - Automatic code validation in the rule editor
This commit is contained in:
parent
71259f6708
commit
8bd22fc906
@ -17,7 +17,7 @@ interface SyntaxError {
|
||||
line: number;
|
||||
column: number;
|
||||
message: string;
|
||||
warning: boolean;
|
||||
warning?: boolean;
|
||||
}
|
||||
|
||||
interface UploadResponse {
|
||||
@ -43,6 +43,7 @@ export class RulesScreenComponent implements OnInit, ComponentCanDeactivate {
|
||||
automaticLayout: true,
|
||||
readOnly: !this.permissionsService.canEditRules(),
|
||||
glyphMargin: true,
|
||||
fixedOverflowWidgets: true,
|
||||
};
|
||||
initialLines: string[] = [];
|
||||
currentLines: string[] = [];
|
||||
@ -151,10 +152,18 @@ export class RulesScreenComponent implements OnInit, ComponentCanDeactivate {
|
||||
}
|
||||
},
|
||||
error => {
|
||||
const errors = this.#mapErrors(error.error);
|
||||
let errors: SyntaxError[];
|
||||
if (error.error?.syntaxErrorMessages) {
|
||||
errors = this.#mapErrors(error.error);
|
||||
} else {
|
||||
const syntaxError: SyntaxError = { message: error.error.message, line: 1, column: 0 };
|
||||
errors = this.#mapErrors({ blacklistErrorMessages: [], syntaxErrorMessages: [syntaxError], deprecatedWarnings: [] });
|
||||
}
|
||||
this.#drawErrorMarkers(errors);
|
||||
this._loadingService.stop();
|
||||
this._toaster.error(rulesScreenTranslations[this.type]['error.generic']);
|
||||
if (!dryRun) {
|
||||
this._toaster.error(rulesScreenTranslations[this.type]['error.generic']);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -252,6 +261,7 @@ export class RulesScreenComponent implements OnInit, ComponentCanDeactivate {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
this.#errors.set(errors);
|
||||
this.#errorGlyphs.set(this.#codeEditor.deltaDecorations(this.#errorGlyphs(), glyphs));
|
||||
(window as any).monaco.editor.setModelMarkers(model, model.id, markers);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user