Display error message in the bottom left corner
This commit is contained in:
@@ -13,11 +13,15 @@ class NewTeamModal extends React.Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getTeamNameValidationState() {
|
getTeamNameValidationError() {
|
||||||
if (!this.state.saveStarted) {
|
if (!this.state.saveStarted) {
|
||||||
return '';
|
return null;
|
||||||
}
|
}
|
||||||
return this.state.teamName.length > 0 ? '' : 'error';
|
return this.state.teamName.length > 0 ? null : 'Name is required.';
|
||||||
|
}
|
||||||
|
|
||||||
|
getTeamNameValidationState() {
|
||||||
|
return this.getTeamNameValidationError() === null ? null : 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTeamNameChange(e) {
|
handleTeamNameChange(e) {
|
||||||
@@ -26,17 +30,21 @@ class NewTeamModal extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getTeamUrlValidationState() {
|
getTeamUrlValidationError() {
|
||||||
if (!this.state.saveStarted) {
|
if (!this.state.saveStarted) {
|
||||||
return '';
|
return null;
|
||||||
}
|
}
|
||||||
if (this.state.teamUrl.length === 0) {
|
if (this.state.teamUrl.length === 0) {
|
||||||
return 'error';
|
return 'URL is required.';
|
||||||
}
|
}
|
||||||
if (!validUrl.isUri(this.state.teamUrl)) {
|
if (!validUrl.isUri(this.state.teamUrl)) {
|
||||||
return 'error';
|
return 'URL should start with http:// or https://.';
|
||||||
}
|
}
|
||||||
return '';
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTeamUrlValidationState() {
|
||||||
|
return this.getTeamUrlValidationError() === null ? null : 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTeamUrlChange(e) {
|
handleTeamUrlChange(e) {
|
||||||
@@ -45,9 +53,13 @@ class NewTeamModal extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getError() {
|
||||||
|
return this.getTeamNameValidationError() || this.getTeamUrlValidationError();
|
||||||
|
}
|
||||||
|
|
||||||
validateForm() {
|
validateForm() {
|
||||||
return this.getTeamNameValidationState() === '' &&
|
return this.getTeamNameValidationState() === null &&
|
||||||
this.getTeamUrlValidationState() === '';
|
this.getTeamUrlValidationState() === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
@@ -122,6 +134,12 @@ class NewTeamModal extends React.Component {
|
|||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
|
|
||||||
<Modal.Footer>
|
<Modal.Footer>
|
||||||
|
<div
|
||||||
|
className='pull-left'
|
||||||
|
>
|
||||||
|
{this.getError()}
|
||||||
|
</div>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
id='cancelNewServerModal'
|
id='cancelNewServerModal'
|
||||||
onClick={this.props.onClose}
|
onClick={this.props.onClose}
|
||||||
|
Reference in New Issue
Block a user