added simple YAML validation on FE
This commit is contained in:
parent
94bd90486c
commit
af4189e3b9
2 changed files with 11 additions and 4 deletions
|
@ -13,6 +13,7 @@
|
||||||
"@testing-library/react": "^11.1.0",
|
"@testing-library/react": "^11.1.0",
|
||||||
"@testing-library/user-event": "^12.1.10",
|
"@testing-library/user-event": "^12.1.10",
|
||||||
"@types/jest": "^26.0.15",
|
"@types/jest": "^26.0.15",
|
||||||
|
"@types/js-yaml": "^4.0.5",
|
||||||
"@types/node": "^12.0.0",
|
"@types/node": "^12.0.0",
|
||||||
"@types/react-dom": "^17.0.0",
|
"@types/react-dom": "^17.0.0",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
|
@ -28,8 +29,8 @@
|
||||||
"react-hot-toast": "^2.0.0",
|
"react-hot-toast": "^2.0.0",
|
||||||
"react-markdown": "^7.0.1",
|
"react-markdown": "^7.0.1",
|
||||||
"react-redux": "^7.2.4",
|
"react-redux": "^7.2.4",
|
||||||
"react-router-dom": "6.2.1",
|
|
||||||
"react-router": "6.2.1",
|
"react-router": "6.2.1",
|
||||||
|
"react-router-dom": "6.2.1",
|
||||||
"react-scripts": "4.0.3",
|
"react-scripts": "4.0.3",
|
||||||
"react-simple-code-editor": "^0.11.0",
|
"react-simple-code-editor": "^0.11.0",
|
||||||
"react-table": "^7.7.0",
|
"react-table": "^7.7.0",
|
||||||
|
|
|
@ -3,11 +3,12 @@ import _ from 'lodash';
|
||||||
import Editor from 'react-simple-code-editor';
|
import Editor from 'react-simple-code-editor';
|
||||||
// import { Menu, Transition } from '@headlessui/react';
|
// import { Menu, Transition } from '@headlessui/react';
|
||||||
// import { ChevronDownIcon } from '@heroicons/react/solid';
|
// import { ChevronDownIcon } from '@heroicons/react/solid';
|
||||||
|
import yaml from 'js-yaml';
|
||||||
import { highlight, languages } from 'prismjs';
|
import { highlight, languages } from 'prismjs';
|
||||||
import 'prismjs/components/prism-clike';
|
import 'prismjs/components/prism-clike';
|
||||||
import 'prismjs/components/prism-yaml';
|
import 'prismjs/components/prism-yaml';
|
||||||
import 'prismjs/themes/prism.css';
|
import 'prismjs/themes/prism.css';
|
||||||
import { showToast } from 'src/common/util/show-toast';
|
import { showToast, ToastType } from 'src/common/util/show-toast';
|
||||||
import { useApps } from 'src/services/apps';
|
import { useApps } from 'src/services/apps';
|
||||||
import { initialEditorYaml } from '../../consts';
|
import { initialEditorYaml } from '../../consts';
|
||||||
|
|
||||||
|
@ -21,8 +22,13 @@ export const AdvancedTab = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const vertifyCode = () => {
|
const vertifyCode = () => {
|
||||||
// call yaml verification (only format)
|
try {
|
||||||
// const result = validateSchema(code, {});
|
yaml.load(code);
|
||||||
|
showToast('Configuration is valid!', ToastType.Success);
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log('e', e);
|
||||||
|
showToast(`Configuration is not valid: ${e.message}`, ToastType.Error, Infinity);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveChanges = () => {
|
const saveChanges = () => {
|
||||||
|
|
Loading…
Reference in a new issue