ordered branches in selectfield and added first form validation

This commit is contained in:
Florian Scholdei
2019-04-03 17:16:55 +02:00
parent 61c94de51d
commit 63137ff5c5
2 changed files with 21 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ import {
SubmitButton,
validation as validator
} from "@scm-manager/ui-components";
import { orderBranches } from "../util/orderBranches";
type Props = {
submitForm: Branch => void,
@@ -32,8 +33,17 @@ class BranchForm extends React.Component<Props, State> {
};
}
isFalsy(value) {
return !value;
}
isValid = () => {
return true; //TODO
const { source, name } = this.state;
return !(
this.state.nameValidationError ||
this.isFalsy(source) ||
this.isFalsy(name)
);
};
submit = (event: Event) => {
@@ -44,8 +54,9 @@ class BranchForm extends React.Component<Props, State> {
};
render() {
const { t, branches } = this.props;
const { loading } = this.state;
const { t, branches, loading } = this.props;
const { name } = this.state;
orderBranches(branches);
const options = branches.map(branch => ({
label: branch.name,
value: branch.name
@@ -67,6 +78,9 @@ class BranchForm extends React.Component<Props, State> {
name="name"
label={t("branches.create.name")}
onChange={this.handleNameChange}
value={name ? name : ""}
validationError={this.state.nameValidationError}
errorMessage={t("validation.branch.nameInvalid")}
/>
</div>
</div>