mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-21 15:02:17 +01:00
merge repository heads
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
"node-sass": "^4.9.3",
|
||||
"postcss-easy-import": "^3.0.0",
|
||||
"react": "^16.8.6",
|
||||
"query-string": "5",
|
||||
"react-diff-view": "^1.8.1",
|
||||
"react-dom": "^16.8.6",
|
||||
"react-i18next": "^7.9.0",
|
||||
|
||||
@@ -30,7 +30,8 @@ class BranchForm extends React.Component<Props, State> {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
nameValidationError: false
|
||||
nameValidationError: false,
|
||||
name: props.transmittedName
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ class BranchForm extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { t, branches, loading } = this.props;
|
||||
const { t, branches, loading, transmittedName } = this.props;
|
||||
const { name } = this.state;
|
||||
orderBranches(branches);
|
||||
const options = branches.map(branch => ({
|
||||
@@ -82,6 +83,7 @@ class BranchForm extends React.Component<Props, State> {
|
||||
value={name ? name : ""}
|
||||
validationError={this.state.nameValidationError}
|
||||
errorMessage={t("validation.branch.nameInvalid")}
|
||||
disabled={!!transmittedName}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
|
||||
import type { History } from "history";
|
||||
import { NotFoundError } from "@scm-manager/ui-components";
|
||||
import queryString from "query-string";
|
||||
|
||||
type Props = {
|
||||
repository: Repository,
|
||||
@@ -49,25 +50,25 @@ class BranchRoot extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
repository,
|
||||
branch,
|
||||
loading,
|
||||
error,
|
||||
match,
|
||||
location
|
||||
} = this.props;
|
||||
const { repository, branch, loading, error, match, location } = this.props;
|
||||
|
||||
const url = this.matchedUrl();
|
||||
|
||||
if (error) {
|
||||
if(error instanceof NotFoundError && location.search.indexOf("?create=true") > -1) {
|
||||
return <Redirect to={`/repo/${repository.namespace}/${repository.name}/branches/create?name=${match.params.branch}`} />;
|
||||
if (
|
||||
error instanceof NotFoundError &&
|
||||
queryString.parse(location.search).create === "true"
|
||||
) {
|
||||
return (
|
||||
<Redirect
|
||||
to={`/repo/${repository.namespace}/${
|
||||
repository.name
|
||||
}/branches/create?name=${match.params.branch}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ErrorNotification error={error} />
|
||||
);
|
||||
return <ErrorNotification error={error} />;
|
||||
}
|
||||
|
||||
if (loading || !branch) {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { ErrorNotification, Loading, Subtitle } from "@scm-manager/ui-components";
|
||||
import {
|
||||
ErrorNotification,
|
||||
Loading,
|
||||
Subtitle
|
||||
} from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
import BranchForm from "../components/BranchForm";
|
||||
import type { Repository, Branch } from "@scm-manager/ui-types";
|
||||
@@ -10,11 +14,14 @@ import {
|
||||
createBranch,
|
||||
createBranchReset,
|
||||
isCreateBranchPending,
|
||||
getCreateBranchFailure, isFetchBranchesPending, getFetchBranchesFailure
|
||||
getCreateBranchFailure,
|
||||
isFetchBranchesPending,
|
||||
getFetchBranchesFailure
|
||||
} from "../modules/branches";
|
||||
import type { History } from "history";
|
||||
import { connect } from "react-redux";
|
||||
import {withRouter} from "react-router-dom";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import queryString from "query-string";
|
||||
|
||||
type Props = {
|
||||
loading?: boolean,
|
||||
@@ -49,10 +56,9 @@ class CreateBranch extends React.Component<Props> {
|
||||
this.props.createBranch(branch, () => this.branchCreated(branch));
|
||||
};
|
||||
|
||||
matchesTransmittedName = (search: string) => {
|
||||
const regex = new RegExp("\\?name=.+");
|
||||
const match = search.match(regex);
|
||||
return match ? match[0].substring(6, 0): null;
|
||||
transmittedName = (url: string) => {
|
||||
const params = queryString.parse(url);
|
||||
return params.name;
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -62,8 +68,8 @@ class CreateBranch extends React.Component<Props> {
|
||||
return <ErrorNotification error={error} />;
|
||||
}
|
||||
|
||||
if(!branches) {
|
||||
return <Loading/>;
|
||||
if (loading || !branches) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -74,7 +80,7 @@ class CreateBranch extends React.Component<Props> {
|
||||
loading={loading}
|
||||
repository={repository}
|
||||
branches={branches}
|
||||
transmittedName={this.matchesTransmittedName(location.search)}
|
||||
transmittedName={this.transmittedName(location.search)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
@@ -101,8 +107,9 @@ const mapDispatchToProps = dispatch => {
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { repository } = ownProps;
|
||||
const loading = isFetchBranchesPending(state, repository) || isCreateBranchPending(state);
|
||||
const error = getFetchBranchesFailure(state, repository) || getCreateBranchFailure(state);
|
||||
const loading = isFetchBranchesPending(state, repository); //|| isCreateBranchPending(state);
|
||||
const error =
|
||||
getFetchBranchesFailure(state, repository) || getCreateBranchFailure(state);
|
||||
const branches = getBranches(state, repository);
|
||||
return {
|
||||
repository,
|
||||
@@ -112,7 +119,9 @@ const mapStateToProps = (state, ownProps) => {
|
||||
};
|
||||
};
|
||||
|
||||
export default withRouter(connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("repos")(CreateBranch)));
|
||||
export default withRouter(
|
||||
connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("repos")(CreateBranch))
|
||||
);
|
||||
|
||||
@@ -6831,6 +6831,14 @@ qs@~6.5.1, qs@~6.5.2:
|
||||
version "6.5.2"
|
||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
||||
|
||||
query-string@5:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb"
|
||||
dependencies:
|
||||
decode-uri-component "^0.2.0"
|
||||
object-assign "^4.1.0"
|
||||
strict-uri-encode "^1.0.0"
|
||||
|
||||
querystring-es3@~0.2.0:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
|
||||
@@ -8015,6 +8023,10 @@ stream-throttle@^0.1.3:
|
||||
commander "^2.2.0"
|
||||
limiter "^1.0.5"
|
||||
|
||||
strict-uri-encode@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
|
||||
|
||||
string-length@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed"
|
||||
|
||||
Reference in New Issue
Block a user