diff --git a/app/javascript/src/scenes/SettingsPage/scenes/team/components/UpdateTeamDescriptionModal.jsx b/app/javascript/src/scenes/SettingsPage/scenes/team/components/UpdateTeamDescriptionModal.jsx
index ab0e08d54..fc54f563b 100644
--- a/app/javascript/src/scenes/SettingsPage/scenes/team/components/UpdateTeamDescriptionModal.jsx
+++ b/app/javascript/src/scenes/SettingsPage/scenes/team/components/UpdateTeamDescriptionModal.jsx
@@ -3,55 +3,40 @@ import PropTypes, { bool, number, string, func } from "prop-types";
import {
Modal,
Button,
- FormGroup,
ControlLabel,
FormControl,
- HelpBlock
} from "react-bootstrap";
import { FormattedMessage } from "react-intl";
-import _ from "lodash";
-import styled from "styled-components";
import axios from "../../../../../config/axios";
+import {
+ ValidatedForm,
+ ValidatedFormGroup,
+ ValidatedFormControl,
+ ValidatedErrorHelpBlock,
+ ValidatedSubmitButton
+} from "../../../../../components/validation";
+import {
+ textMaxLengthValidator
+} from "../../../../../components/validation/validators/text_validators";
-import { TEXT_MAX_LENGTH } from "../../../../../config/constants/numeric";
import { TEAM_UPDATE_PATH } from "../../../../../config/api_endpoints";
-import { COLOR_APPLE_BLOSSOM } from "../../../../../config/constants/colors";
-
-const StyledHelpBlock = styled(HelpBlock)`color: ${COLOR_APPLE_BLOSSOM};`;
class UpdateTeamDescriptionModal extends Component {
constructor(props) {
super(props);
- this.state = { errorMessage: "", description: "" };
+ this.state = { description: "" };
this.onCloseModal = this.onCloseModal.bind(this);
this.updateDescription = this.updateDescription.bind(this);
this.handleDescription = this.handleDescription.bind(this);
- this.getValidationState = this.getValidationState.bind(this);
}
onCloseModal() {
- this.setState({ errorMessage: "", description: "" });
+ this.setState({ description: "" });
this.props.hideModal();
}
- getValidationState() {
- return this.state.errorMessage.length > 0 ? "error" : null;
- }
-
handleDescription(el) {
- const { value } = el.target;
- if (value.length > TEXT_MAX_LENGTH) {
- this.setState({
- errorMessage: (
-
- )
- });
- } else {
- this.setState({ errorMessage: "", description: value });
- }
+ this.setState({ description: el.target.value });
}
updateDescription() {
@@ -74,40 +59,40 @@ class UpdateTeamDescriptionModal extends Component {
render() {
return (
-
-
-
-
-
-
-
-
-
-
-
-
- {this.state.errorMessage}
-
-
-
-
-
-
+ { this.form = f; }}>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
);
}
diff --git a/app/javascript/src/scenes/SettingsPage/scenes/team/components/UpdateTeamNameModal.jsx b/app/javascript/src/scenes/SettingsPage/scenes/team/components/UpdateTeamNameModal.jsx
index eff100622..2bed07904 100644
--- a/app/javascript/src/scenes/SettingsPage/scenes/team/components/UpdateTeamNameModal.jsx
+++ b/app/javascript/src/scenes/SettingsPage/scenes/team/components/UpdateTeamNameModal.jsx
@@ -3,55 +3,40 @@ import PropTypes, { bool, number, string, func } from "prop-types";
import {
Modal,
Button,
- FormGroup,
ControlLabel,
FormControl,
- HelpBlock
} from "react-bootstrap";
import { FormattedMessage } from "react-intl";
-import _ from "lodash";
-import styled from "styled-components";
import axios from "../../../../../config/axios";
+import {
+ ValidatedForm,
+ ValidatedFormGroup,
+ ValidatedFormControl,
+ ValidatedErrorHelpBlock,
+ ValidatedSubmitButton
+} from "../../../../../components/validation";
+import {
+ nameLengthValidator
+} from "../../../../../components/validation/validators/text_validators";
-import { NAME_MAX_LENGTH } from "../../../../../config/constants/numeric";
import { TEAM_UPDATE_PATH } from "../../../../../config/api_endpoints";
-import { COLOR_APPLE_BLOSSOM } from "../../../../../config/constants/colors";
-
-const StyledHelpBlock = styled(HelpBlock)`color: ${COLOR_APPLE_BLOSSOM};`;
class UpdateTeamNameModal extends Component {
constructor(props) {
super(props);
- this.state = { errorMessage: "", name: props.team.name };
+ this.state = { name: props.team.name };
this.onCloseModal = this.onCloseModal.bind(this);
this.updateName = this.updateName.bind(this);
this.handleName = this.handleName.bind(this);
- this.getValidationState = this.getValidationState.bind(this);
}
onCloseModal() {
- this.setState({ errorMessage: "", name: "" });
+ this.setState({ name: "" });
this.props.hideModal();
}
- getValidationState() {
- return this.state.errorMessage.length > 0 ? "error" : null;
- }
-
- handleName(el) {
- const { value } = el.target;
- if (value.length > NAME_MAX_LENGTH) {
- this.setState({
- errorMessage: (
-
- )
- });
- } else {
- this.setState({ errorMessage: "", name: value });
- }
+ handleName(e) {
+ this.setState({ name: e.target.value });
}
updateName() {
@@ -68,46 +53,48 @@ class UpdateTeamNameModal extends Component {
this.props.updateTeamCallback(response.data.team);
this.onCloseModal();
})
- .catch(error => this.setState({ errorMessage: error.message }));
+ .catch(error => {
+ this.form.setErrorsForTag("name", [error.message]);
+ });
}
render() {
return (
-
-
-
-
-
-
-
-
-
-
-
-
- {this.state.errorMessage}
-
-
-
-
-
-
+ { this.form = f; }}>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
);
}