Merge pull request #15115 from influxdata/fix/save-variable

fix(variables/components/VariableForm): check to see if form is valid
pull/15123/head
Michael Desa 2019-09-11 16:46:33 -04:00 committed by GitHub
commit 0a24d3bd85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 2 deletions

View File

@ -161,9 +161,24 @@ export default class VariableForm extends PureComponent<Props, State> {
}
private get isFormValid(): boolean {
const {hasValidArgs, isNameValid} = this.state
const {isNameValid} = this.state
return hasValidArgs && isNameValid
return this.validArgs && isNameValid
}
private get validArgs(): boolean {
const {args} = this.state
switch (args.type) {
case 'query':
const {query} = args.values
return !!query
case 'constant':
return args.values.length !== 0
case 'map':
return Object.keys(args.values).length !== 0
default:
return false
}
}
private handleSubmit = (): void => {