mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
ordered branches in selectfield and added first form validation
This commit is contained in:
@@ -11,7 +11,10 @@
|
|||||||
"validation": {
|
"validation": {
|
||||||
"namespace-invalid": "The repository namespace is invalid",
|
"namespace-invalid": "The repository namespace is invalid",
|
||||||
"name-invalid": "The repository name is invalid",
|
"name-invalid": "The repository name is invalid",
|
||||||
"contact-invalid": "Contact must be a valid mail address"
|
"contact-invalid": "Contact must be a valid mail address",
|
||||||
|
"branch": {
|
||||||
|
"nameInvalid": "The branch name is invalid"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"help": {
|
"help": {
|
||||||
"namespaceHelpText": "The namespace of the repository. This name will be part of the repository url.",
|
"namespaceHelpText": "The namespace of the repository. This name will be part of the repository url.",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
SubmitButton,
|
SubmitButton,
|
||||||
validation as validator
|
validation as validator
|
||||||
} from "@scm-manager/ui-components";
|
} from "@scm-manager/ui-components";
|
||||||
|
import { orderBranches } from "../util/orderBranches";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
submitForm: Branch => void,
|
submitForm: Branch => void,
|
||||||
@@ -32,8 +33,17 @@ class BranchForm extends React.Component<Props, State> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFalsy(value) {
|
||||||
|
return !value;
|
||||||
|
}
|
||||||
|
|
||||||
isValid = () => {
|
isValid = () => {
|
||||||
return true; //TODO
|
const { source, name } = this.state;
|
||||||
|
return !(
|
||||||
|
this.state.nameValidationError ||
|
||||||
|
this.isFalsy(source) ||
|
||||||
|
this.isFalsy(name)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
submit = (event: Event) => {
|
submit = (event: Event) => {
|
||||||
@@ -44,8 +54,9 @@ class BranchForm extends React.Component<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { t, branches } = this.props;
|
const { t, branches, loading } = this.props;
|
||||||
const { loading } = this.state;
|
const { name } = this.state;
|
||||||
|
orderBranches(branches);
|
||||||
const options = branches.map(branch => ({
|
const options = branches.map(branch => ({
|
||||||
label: branch.name,
|
label: branch.name,
|
||||||
value: branch.name
|
value: branch.name
|
||||||
@@ -67,6 +78,9 @@ class BranchForm extends React.Component<Props, State> {
|
|||||||
name="name"
|
name="name"
|
||||||
label={t("branches.create.name")}
|
label={t("branches.create.name")}
|
||||||
onChange={this.handleNameChange}
|
onChange={this.handleNameChange}
|
||||||
|
value={name ? name : ""}
|
||||||
|
validationError={this.state.nameValidationError}
|
||||||
|
errorMessage={t("validation.branch.nameInvalid")}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user