Bootstrapped BranchRoot

This commit is contained in:
Philipp Czora
2018-10-11 17:29:50 +02:00
parent 306388af7b
commit 2de0287bf9
7 changed files with 163 additions and 85 deletions

View File

@@ -27,6 +27,7 @@ import type { History } from "history";
import EditNavLink from "../components/EditNavLink";
import BranchChooser from "./BranchChooser";
import Changesets from "./Changesets";
import BranchRoot from "./BranchRoot";
type Props = {
namespace: string,
@@ -73,21 +74,12 @@ class RepositoryRoot extends React.Component<Props> {
matches = (route: any) => {
const url = this.matchedUrl();
const regex = new RegExp(`${url}/?[a-zA-Z0-9_%]*/changesets?.*`);
const regex = new RegExp(
`${url}(/branches)?/?[a-zA-Z0-9_%]*/changesets?.*`
);
return route.location.pathname.match(regex);
};
branchSelected = (branchName: string) => {
const url = this.matchedUrl();
if (branchName === "") {
this.props.history.push(`${url}/changesets/`);
} else {
this.props.history.push(
`${url}/branches/${encodeURIComponent(branchName)}/changesets/`
);
}
};
render() {
const { loading, error, repository, t } = this.props;
@@ -120,31 +112,21 @@ class RepositoryRoot extends React.Component<Props> {
path={`${url}/edit`}
component={() => <Edit repository={repository} />}
/>
{/*<Route*/}
{/*path={`${url}/changesets/:page?`}*/}
{/*component={() => (*/}
{/*<BranchChooser*/}
{/*repository={repository}*/}
{/*label={"Branches"}*/}
{/*branchSelected={this.branchSelected}*/}
{/*>*/}
{/*<Changesets repository={repository} />*/}
{/*</BranchChooser>*/}
{/*)}*/}
{/*/>*/}
<Route
path={`${url}/changesets/:page?`}
component={() => (
<BranchChooser
repository={repository}
label={"Branches"}
branchSelected={this.branchSelected}
>
<Changesets repository={repository} />
</BranchChooser>
)}
/>
<Route
path={`${url}/branches/:branch/changesets/:page?`}
component={() => (
<BranchChooser
repository={repository}
label={"Branches"}
branchSelected={this.branchSelected}
>
<Changesets repository={repository} />
</BranchChooser>
)}
path={`${url}/branches`}
render={() => <BranchRoot repository={repository} />}
/>
</div>
<div className="column">