From 80b2e987d7f1ecd59daaa57a890b3f261f775c97 Mon Sep 17 00:00:00 2001 From: Fernando del Campo Date: Mon, 16 Oct 2023 11:23:32 -0300 Subject: [PATCH] remove revalidate, when click save o update script schema --- .../ScriptQueue/ConfigPanel/ConfigPanel.jsx | 58 +++++++------------ 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/love/src/components/ScriptQueue/ConfigPanel/ConfigPanel.jsx b/love/src/components/ScriptQueue/ConfigPanel/ConfigPanel.jsx index e8e45cb70..10e1c7dfa 100644 --- a/love/src/components/ScriptQueue/ConfigPanel/ConfigPanel.jsx +++ b/love/src/components/ScriptQueue/ConfigPanel/ConfigPanel.jsx @@ -246,7 +246,7 @@ export default class ConfigPanel extends Component { * @param {string} newValue, the new value to validate * @param {boolean} noRevalidation, if true, do not revalidate if already validating */ - validateConfig = (newValue, noRevalidation, postValidate=()=>{}, failValidate=()=>{}) => { + validateConfig = (newValue, noRevalidation) => { this.setState({ value: newValue }); /** Do nothing if schema is not available * stay in EMPTY state @@ -295,15 +295,12 @@ export default class ConfigPanel extends Component { }, ], }); - failValidate(); return false; } - postValidate(); return r.json(); }) .then((r) => { /** Handle SERVER_ERROR */ - failValidate(); this.setState({ validationStatus: SERVER_ERROR, configErrorTitle: 'Validation Failed', @@ -595,50 +592,39 @@ export default class ConfigPanel extends Component { saveNewScriptSchema = (scriptPath, scriptType, configName, configSchema) => { const { configurationList, value } = this.state; this.setState({ updatingScriptSchema: true }); - const postValidate = () => { - ManagerInterface.postScriptConfiguration(scriptPath, scriptType, configName, configSchema).then((res) => { - const newConfigurationList = [res, ...configurationList]; - const options = newConfigurationList.map((conf) => ({ label: conf.config_name, value: conf.id })); - const newSelectedConfiguration = { label: res.config_name, value: res.id }; - this.setState({ - updatingScriptSchema: false, - configurationList: newConfigurationList, - configurationOptions: options, - selectedConfiguration: newSelectedConfiguration, - value: res?.config_schema ?? '', - inputConfigurationName: res?.config_name ?? '', - formData: yaml.load(res?.config_schema), - }); - }); - }; - const failValidate = () => { + + ManagerInterface.postScriptConfiguration(scriptPath, scriptType, configName, configSchema).then((res) => { + const newConfigurationList = [res, ...configurationList]; + const options = newConfigurationList.map((conf) => ({ label: conf.config_name, value: conf.id })); + const newSelectedConfiguration = { label: res.config_name, value: res.id }; this.setState({ updatingScriptSchema: false, + configurationList: newConfigurationList, + configurationOptions: options, + selectedConfiguration: newSelectedConfiguration, + value: res?.config_schema ?? '', + inputConfigurationName: res?.config_name ?? '', + formData: yaml.load(res?.config_schema), }); - }; - this.validateConfig(value, configSchema, postValidate, failValidate); + }); + + this.validateConfig(value, configSchema); }; updateScriptSchema = (id, configSchema) => { const { configurationList, value } = this.state; this.setState({ updatingScriptSchema: true }); - const postValidate = () => { - ManagerInterface.updateScriptSchema(id, configSchema).then((res) => { - const newSelectedConfiguration = { label: res.config_name, value: res.id }; - this.setState({ - updatingScriptSchema: false, - selectedConfiguration: newSelectedConfiguration, - configurationList: configurationList.map((conf) => (conf.id === id ? res : conf)), - }); - }); - } - const failValidate = () => { + ManagerInterface.updateScriptSchema(id, configSchema).then((res) => { + const newSelectedConfiguration = { label: res.config_name, value: res.id }; this.setState({ updatingScriptSchema: false, + selectedConfiguration: newSelectedConfiguration, + configurationList: configurationList.map((conf) => (conf.id === id ? res : conf)), }); - }; - this.validateConfig(value, configSchema, postValidate, failValidate); + }); + + this.validateConfig(value, configSchema); }; componentDidUpdate = (prevProps, prevState) => {