diff --git a/ui/src/features/components/TestForm/index.js b/ui/src/features/components/TestForm/index.js index bd2ee19c8..51deae859 100644 --- a/ui/src/features/components/TestForm/index.js +++ b/ui/src/features/components/TestForm/index.js @@ -50,7 +50,7 @@ export class TestForm extends React.Component { csvFileId: undefined } } - this.state.urls = { + this.state.validationErrors = { [URL_FIELDS.BASE]: { value: EMPTY_STRING, error: null @@ -63,36 +63,24 @@ export class TestForm extends React.Component { } hasValidationErrors = () => { - let urlTypes = Object.values(this.state.urls); - return !urlTypes.some((url) => isUrlValid(url.value)); + return !(this.state.baseUrl ? isUrlValid(this.state.baseUrl) : true); }; isButtonDisabled = () => { return !this.state.name || this.hasValidationErrors(); } - updatevalidationError = ({ error }) => { + updateValidationError = ({ error }) => { const newState = Object.assign({}, this.state); - newState.urls[URL_FIELDS.STEP].error = error; + newState.validationErrors[URL_FIELDS.BASE].error = error; this.setState(newState); }; - setValidationError = ({ error }) => { - this.updatevalidationError({ error }); - }; - - resetValidationError = () => { - this.updatevalidationError({ error: null }); - }; - - validateUrl = ({ name, value }) => { - const newState = Object.assign({}, this.state); - newState.urls[name].value = value; - this.setState(newState); + validateUrl = () => { if (this.hasValidationErrors()) { - this.setValidationError({ error: INVALID_URL_MESSAGE }); + this.updateValidationError({ error: INVALID_URL_MESSAGE }); } else { - this.resetValidationError(); + this.updateValidationError({ error: null }); } }; @@ -187,11 +175,12 @@ export class TestForm extends React.Component {
- -