Fixes app being able to be named empty or whitespace string in editor (#1197)

This commit is contained in:
Jayden-Chiu 2021-10-23 06:41:58 -04:00 committed by GitHub
parent 59e33a370c
commit 2106f4c5f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -309,6 +309,23 @@ class Editor extends React.Component {
});
};
saveAppName = (id, name, notify = false) => {
if (!name.trim()) {
toast.warn("App name can't be empty or whitespace", {
hideProgressBar: true,
position: 'top-center',
});
this.setState({
app: { ...this.state.app, name: this.state.oldName },
})
return;
}
this.saveApp(id, {name}, notify);
}
renderDataSource = (dataSource) => {
const sourceMeta = DataSourceTypes.find((source) => source.kind === dataSource.kind);
return (
@ -569,8 +586,9 @@ class Editor extends React.Component {
<input
type="text"
style={{ width: '200px', left: '80px', position: 'absolute' }}
onFocus={(e) => this.setState({ oldName: e.target.value })}
onChange={(e) => this.onNameChanged(e.target.value)}
onBlur={(e) => this.saveApp(this.state.app.id, { name: e.target.value })}
onBlur={(e) => this.saveAppName(this.state.app.id, e.target.value)}
className="form-control-plaintext form-control-plaintext-sm"
value={this.state.app.name}
/>