From 14b4a58d464a7fd6ce0a0407a1b2ba994a2d09f8 Mon Sep 17 00:00:00 2001 From: Luka Radenovic Date: Thu, 11 Aug 2022 10:43:48 +0200 Subject: [PATCH] Fix advanced tab toasts --- .../components/AdvancedTab/AdvancedTab.tsx | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/modules/apps/components/AdvancedTab/AdvancedTab.tsx b/src/modules/apps/components/AdvancedTab/AdvancedTab.tsx index 20ae4ab..4eda859 100644 --- a/src/modules/apps/components/AdvancedTab/AdvancedTab.tsx +++ b/src/modules/apps/components/AdvancedTab/AdvancedTab.tsx @@ -1,4 +1,4 @@ -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(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 = () => { - {configurationValidation && ( - <> -
-

Configuration validation

-
-
{configurationValidation}
- - )}