diff --git a/package.json b/package.json index b304273..5739c7e 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/jest": "^26.0.15", + "@types/js-yaml": "^4.0.5", "@types/node": "^12.0.0", "@types/react-dom": "^17.0.0", "axios": "^0.21.1", @@ -28,8 +29,8 @@ "react-hot-toast": "^2.0.0", "react-markdown": "^7.0.1", "react-redux": "^7.2.4", - "react-router-dom": "6.2.1", "react-router": "6.2.1", + "react-router-dom": "6.2.1", "react-scripts": "4.0.3", "react-simple-code-editor": "^0.11.0", "react-table": "^7.7.0", diff --git a/src/modules/apps/components/AdvancedTab/AdvancedTab.tsx b/src/modules/apps/components/AdvancedTab/AdvancedTab.tsx index 384392e..7700170 100644 --- a/src/modules/apps/components/AdvancedTab/AdvancedTab.tsx +++ b/src/modules/apps/components/AdvancedTab/AdvancedTab.tsx @@ -3,11 +3,12 @@ import _ from 'lodash'; import Editor from 'react-simple-code-editor'; // import { Menu, Transition } from '@headlessui/react'; // import { ChevronDownIcon } from '@heroicons/react/solid'; +import yaml from 'js-yaml'; import { highlight, languages } from 'prismjs'; import 'prismjs/components/prism-clike'; import 'prismjs/components/prism-yaml'; 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 { initialEditorYaml } from '../../consts'; @@ -21,8 +22,13 @@ export const AdvancedTab = () => { }; const vertifyCode = () => { - // call yaml verification (only format) - // const result = validateSchema(code, {}); + try { + 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 = () => {