Fix advanced tab toasts
This commit is contained in:
parent
4281dd9082
commit
14b4a58d46
1 changed files with 6 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState } from 'react';
|
import React from 'react';
|
||||||
import _ from 'lodash';
|
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';
|
||||||
|
@ -14,7 +14,6 @@ import { initialEditorYaml } from '../../consts';
|
||||||
|
|
||||||
export const AdvancedTab = () => {
|
export const AdvancedTab = () => {
|
||||||
const [code, setCode] = React.useState(initialEditorYaml);
|
const [code, setCode] = React.useState(initialEditorYaml);
|
||||||
const [configurationValidation, setConfigurationValidation] = useState<string | null>(null);
|
|
||||||
const { app, editApp } = useApps();
|
const { app, editApp } = useApps();
|
||||||
|
|
||||||
const resetCode = () => {
|
const resetCode = () => {
|
||||||
|
@ -32,11 +31,10 @@ export const AdvancedTab = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const vertifyCode = () => {
|
const vertifyCode = () => {
|
||||||
try {
|
if (isConfigurationValid()) {
|
||||||
yaml.load(code);
|
showToast('Configuration is valid.', ToastType.Success);
|
||||||
setConfigurationValidation('Configuration is valid!');
|
} else {
|
||||||
} catch (e: any) {
|
showToast('Configuration is not valid! Please fix configuration issues and try again.', ToastType.Error);
|
||||||
setConfigurationValidation(`Configuration is not valid: ${e.message}`);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,7 +43,7 @@ export const AdvancedTab = () => {
|
||||||
editApp({ ...app, configuration: code });
|
editApp({ ...app, configuration: code });
|
||||||
return;
|
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 (
|
return (
|
||||||
|
@ -152,14 +150,6 @@ export const AdvancedTab = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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">
|
<div className="flex justify-end mt-10">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
Loading…
Reference in a new issue