diff --git a/scm-ui-components/packages/ui-components/package.json b/scm-ui-components/packages/ui-components/package.json index c1a179315c..991142e338 100644 --- a/scm-ui-components/packages/ui-components/package.json +++ b/scm-ui-components/packages/ui-components/package.json @@ -30,9 +30,9 @@ "@scm-manager/ui-types": "2.0.0-SNAPSHOT", "classnames": "^2.2.6", "moment": "^2.22.2", - "react": "^16.5.2", + "react": "^16.8.6", + "react-dom": "^16.8.6", "react-diff-view": "^1.8.1", - "react-dom": "^16.5.2", "react-i18next": "^7.11.0", "react-jss": "^8.6.1", "react-router-dom": "^4.3.1", @@ -63,4 +63,4 @@ ] ] } -} \ No newline at end of file +} diff --git a/scm-ui-components/packages/ui-components/src/forms/Select.js b/scm-ui-components/packages/ui-components/src/forms/Select.js index 38e1cdab33..5d37e3d631 100644 --- a/scm-ui-components/packages/ui-components/src/forms/Select.js +++ b/scm-ui-components/packages/ui-components/src/forms/Select.js @@ -15,7 +15,8 @@ type Props = { value?: string, onChange: (value: string, name?: string) => void, loading?: boolean, - helpText?: string + helpText?: string, + disabled?: boolean }; class Select extends React.Component { @@ -34,7 +35,7 @@ class Select extends React.Component { }; render() { - const { options, value, label, helpText, loading } = this.props; + const { options, value, label, helpText, loading, disabled } = this.props; const loadingClass = loading ? "is-loading" : ""; @@ -51,6 +52,7 @@ class Select extends React.Component { }} value={value} onChange={this.handleInput} + disabled={disabled} > {options.map(opt => { return ( diff --git a/scm-ui-components/packages/ui-components/yarn.lock b/scm-ui-components/packages/ui-components/yarn.lock index cc21af6b2e..bce98a17e4 100644 --- a/scm-ui-components/packages/ui-components/yarn.lock +++ b/scm-ui-components/packages/ui-components/yarn.lock @@ -6623,14 +6623,14 @@ react-dom@^16.4.2: prop-types "^15.6.2" scheduler "^0.10.0" -react-dom@^16.5.2: - version "16.5.2" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.5.2.tgz#b69ee47aa20bab5327b2b9d7c1fe2a30f2cfa9d7" +react-dom@^16.8.6: + version "16.8.6" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.6.tgz#71d6303f631e8b0097f56165ef608f051ff6e10f" dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - schedule "^0.5.0" + scheduler "^0.13.6" react-i18next@^7.11.0: version "7.13.0" @@ -6755,14 +6755,14 @@ react@^16.4.2: prop-types "^15.6.2" scheduler "^0.10.0" -react@^16.5.2: - version "16.5.2" - resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42" +react@^16.8.6: + version "16.8.6" + resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe" dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - schedule "^0.5.0" + scheduler "^0.13.6" read-only-stream@^2.0.0: version "2.0.0" @@ -7229,6 +7229,13 @@ scheduler@^0.10.0: loose-envify "^1.1.0" object-assign "^4.1.1" +scheduler@^0.13.6: + version "0.13.6" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889" + dependencies: + loose-envify "^1.1.0" + object-assign "^4.1.1" + select@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/select/-/select-1.1.2.tgz#0e7350acdec80b1108528786ec1d4418d11b396d" diff --git a/scm-ui-components/packages/ui-types/src/Branches.js b/scm-ui-components/packages/ui-types/src/Branches.js index 2dee365424..6d501af593 100644 --- a/scm-ui-components/packages/ui-types/src/Branches.js +++ b/scm-ui-components/packages/ui-types/src/Branches.js @@ -7,3 +7,8 @@ export type Branch = { defaultBranch?: boolean, _links: Links } + +export type BranchRequest = { + name: string, + parent: string +} diff --git a/scm-ui-components/packages/ui-types/src/index.js b/scm-ui-components/packages/ui-types/src/index.js index 02e88f12e1..c57a3c6792 100644 --- a/scm-ui-components/packages/ui-types/src/index.js +++ b/scm-ui-components/packages/ui-types/src/index.js @@ -9,7 +9,7 @@ export type { Group, Member } from "./Group"; export type { Repository, RepositoryCollection, RepositoryGroup } from "./Repositories"; export type { RepositoryType, RepositoryTypeCollection } from "./RepositoryTypes"; -export type { Branch } from "./Branches"; +export type { Branch, BranchRequest } from "./Branches"; export type { Changeset } from "./Changesets"; diff --git a/scm-ui/package.json b/scm-ui/package.json index 78c7b0e684..3c730540ae 100644 --- a/scm-ui/package.json +++ b/scm-ui/package.json @@ -17,12 +17,14 @@ "i18next-browser-languagedetector": "^2.2.2", "i18next-fetch-backend": "^0.1.0", "jss-nested": "^6.0.1", + "memoize-one": "^5.0.4", "moment": "^2.22.2", "node-sass": "^4.9.3", "postcss-easy-import": "^3.0.0", - "react": "^16.4.2", + "query-string": "5", + "react": "^16.8.6", "react-diff-view": "^1.8.1", - "react-dom": "^16.4.2", + "react-dom": "^16.8.6", "react-i18next": "^7.9.0", "react-jss": "^8.6.0", "react-redux": "^5.0.7", diff --git a/scm-ui/public/locales/en/repos.json b/scm-ui/public/locales/en/repos.json index 714b7d4c14..7344547d49 100644 --- a/scm-ui/public/locales/en/repos.json +++ b/scm-ui/public/locales/en/repos.json @@ -11,7 +11,10 @@ "validation": { "namespace-invalid": "The repository namespace 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": { "namespaceHelpText": "The namespace of the repository. This name will be part of the repository url.", diff --git a/scm-ui/src/repos/branches/components/BranchForm.js b/scm-ui/src/repos/branches/components/BranchForm.js index 614a719338..1219511345 100644 --- a/scm-ui/src/repos/branches/components/BranchForm.js +++ b/scm-ui/src/repos/branches/components/BranchForm.js @@ -1,16 +1,125 @@ -//@flow +// @flow import React from "react"; +import { translate } from "react-i18next"; +import type { Repository, Branch, BranchRequest } from "@scm-manager/ui-types"; +import { + Select, + InputField, + SubmitButton, + validation as validator +} from "@scm-manager/ui-components"; +import { orderBranches } from "../util/orderBranches"; -type Props = {}; +type Props = { + submitForm: BranchRequest => void, + repository: Repository, + branches: Branch[], + loading?: boolean, + transmittedName?: string, + disabled?: boolean, + t: string => string +}; + +type State = { + source?: string, + name?: string, + nameValidationError: boolean +}; + +class BranchForm extends React.Component { + constructor(props: Props) { + super(props); + + this.state = { + nameValidationError: false, + name: props.transmittedName + }; + } + + isFalsy(value) { + return !value; + } + + isValid = () => { + const { source, name } = this.state; + return !( + this.state.nameValidationError || + this.isFalsy(source) || + this.isFalsy(name) + ); + }; + + submit = (event: Event) => { + event.preventDefault(); + if (this.isValid()) { + this.props.submitForm({ + name: this.state.name, + parent: this.state.source + }); + } + }; -class CreateBranch extends React.Component { render() { + const { t, branches, loading, transmittedName, disabled } = this.props; + const { name } = this.state; + orderBranches(branches); + const options = branches.map(branch => ({ + label: branch.name, + value: branch.name + })); + return ( <> -

Form placeholder

+
+
+
+