Skip to content

Commit

Permalink
remove revalidate, when click save o update script schema
Browse files Browse the repository at this point in the history
  • Loading branch information
fdelcampo committed Oct 16, 2023
1 parent 154d144 commit 80b2e98
Showing 1 changed file with 22 additions and 36 deletions.
58 changes: 22 additions & 36 deletions love/src/components/ScriptQueue/ConfigPanel/ConfigPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 80b2e98

Please sign in to comment.