Skip to content
Snippets Groups Projects
Commit 14b4a58d authored by Luka's avatar Luka
Browse files

Fix advanced tab toasts

parent 4281dd90
No related branches found
No related tags found
No related merge requests found
import React, { useState } from 'react';
import React from 'react';
import _ from 'lodash';
import Editor from 'react-simple-code-editor';
// import { Menu, Transition } from '@headlessui/react';
......@@ -14,7 +14,6 @@ import { initialEditorYaml } from '../../consts';
export const AdvancedTab = () => {
const [code, setCode] = React.useState(initialEditorYaml);
const [configurationValidation, setConfigurationValidation] = useState<string | null>(null);
const { app, editApp } = useApps();
const resetCode = () => {
......@@ -32,11 +31,10 @@ export const AdvancedTab = () => {
};
const vertifyCode = () => {
try {
yaml.load(code);
setConfigurationValidation('Configuration is valid!');
} catch (e: any) {
setConfigurationValidation(`Configuration is not valid: ${e.message}`);
if (isConfigurationValid()) {
showToast('Configuration is valid.', ToastType.Success);
} else {
showToast('Configuration is not valid! Please fix configuration issues and try again.', ToastType.Error);
}
};
......@@ -45,7 +43,7 @@ export const AdvancedTab = () => {
editApp({ ...app, configuration: code });
return;
}
showToast('Configuration is not valid! Please fix configuration issues and try again.', ToastType.Error, Infinity);
showToast('Configuration is not valid! Please fix configuration issues and try again.', ToastType.Error);
};
return (
......@@ -152,14 +150,6 @@ export const AdvancedTab = () => {
</div>
</div>
</div>
{configurationValidation && (
<>
<div className="pb-5 border-b border-gray-200 sm:flex sm:items-center sm:justify-between mt-8 mb-5 cursor-pointer">
<h3 className="leading-6 font-medium text-gray-900">Configuration validation</h3>
</div>
<div className="bg-white shadow rounded-sm p-4">{configurationValidation}</div>
</>
)}
<div className="flex justify-end mt-10">
<button
type="button"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment