mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
added create branch redirect
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
|||||||
isFetchBranchPending
|
isFetchBranchPending
|
||||||
} from "../modules/branches";
|
} from "../modules/branches";
|
||||||
import { ErrorPage, Loading } from "@scm-manager/ui-components";
|
import { ErrorPage, Loading } from "@scm-manager/ui-components";
|
||||||
import CreateBranch from "./CreateBranch";
|
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -26,6 +25,7 @@ type Props = {
|
|||||||
t: string => string,
|
t: string => string,
|
||||||
history: History,
|
history: History,
|
||||||
match: any,
|
match: any,
|
||||||
|
location: any,
|
||||||
|
|
||||||
// dispatch functions
|
// dispatch functions
|
||||||
fetchBranch: (repository: Repository, branchName: string) => void
|
fetchBranch: (repository: Repository, branchName: string) => void
|
||||||
@@ -50,9 +50,23 @@ class BranchRoot extends React.Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { repository, branch, loading, error, t } = this.props;
|
const {
|
||||||
|
repository,
|
||||||
|
branch,
|
||||||
|
loading,
|
||||||
|
error,
|
||||||
|
t,
|
||||||
|
match,
|
||||||
|
location
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
const url = this.matchedUrl();
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
if(location.search.indexOf("?create=true") > -1) {
|
||||||
|
return <Redirect to={`/repo/${repository.namespace}/${repository.name}/branches/create?name=${match.params.branch}`} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorPage
|
<ErrorPage
|
||||||
title={t("branches.errorTitle")}
|
title={t("branches.errorTitle")}
|
||||||
@@ -66,20 +80,14 @@ class BranchRoot extends React.Component<Props> {
|
|||||||
return <Loading />;
|
return <Loading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = this.matchedUrl();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Redirect exact from={url} to={`${url}/info`} />
|
<Redirect exact from={url} to={`${url}/info`} />
|
||||||
<Route
|
|
||||||
path={`${url}?create=true`}
|
|
||||||
render={() => (
|
|
||||||
<CreateBranch repository={repository} branch={branch} />
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<Route
|
<Route
|
||||||
path={`${url}/info`}
|
path={`${url}/info`}
|
||||||
render={() => <BranchView repository={repository} branch={branch} />}
|
component={() => (
|
||||||
|
<BranchView repository={repository} branch={branch} />
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user