add redirects for old routes

This commit is contained in:
Eduard Heimbuch
2020-01-08 15:17:07 +01:00
parent a43ffacf03
commit b8d4bb6904
4 changed files with 13 additions and 7 deletions

View File

@@ -136,8 +136,8 @@ const mapStateToProps = (state: any, ownProps: Props) => {
const loading = isFetchBranchesPending(state, repository);
const branches = getBranches(state, repository);
const selectedView = decodeURIComponent(location.pathname.split("/")[5]);
const selectedBranch = decodeURIComponent(location.pathname.split("/")[6]);
const branchFromURL = decodeURIComponent(location.pathname.split("/")[6]);
const selectedBranch = branchFromURL && branchFromURL !== "undefined" ? branchFromURL : "";
return {
error,
loading,

View File

@@ -3,6 +3,7 @@ import { Route, withRouter } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next";
import { Repository } from "@scm-manager/ui-types";
import Changesets from "./Changesets";
import { compose } from "redux";
type Props = WithTranslation & {
repository: Repository;
@@ -42,4 +43,4 @@ class ChangesetsRoot extends React.Component<Props> {
}
}
export default withRouter(withTranslation("repos")(ChangesetsRoot));
export default compose(withRouter, withTranslation("repos"))(ChangesetsRoot);

View File

@@ -122,6 +122,11 @@ class RepositoryRoot extends React.Component<Props> {
<div className="column is-three-quarters">
<Switch>
<Redirect exact from={this.props.match.url} to={redirectedUrl} />
<Redirect from={`${url}/changeset/:id`} to={`${url}/code/changeset/:id`} />
<Redirect exact from={`${url}/sources`} to={`${url}/code/sources`} />
<Redirect from={`${url}/sources/:revision/:path*`} to={`${url}/code/sources/:revision/:path*`} />
<Redirect exact from={`${url}/changesets`} to={`${url}/code/changesets`} />
<Redirect from={`${url}/branch/:branch/changesets`} to={`${url}/code/changesets/:branch`} />
<Route path={`${url}/info`} exact component={() => <RepositoryDetails repository={repository} />} />
<Route path={`${url}/settings/general`} component={() => <EditRepo repository={repository} />} />
<Route

View File

@@ -1,11 +1,11 @@
import React from "react";
import { Repository, File } from "@scm-manager/ui-types";
import { withRouter, RouteComponentProps } from "react-router-dom";
import { File, Repository } from "@scm-manager/ui-types";
import { RouteComponentProps, withRouter } from "react-router-dom";
import { ExtensionPoint, binder } from "@scm-manager/ui-extensions";
import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
import { fetchSources, getFetchSourcesFailure, getSources, isFetchSourcesPending } from "../modules/sources";
import { connect } from "react-redux";
import { Loading, ErrorNotification } from "@scm-manager/ui-components";
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
import Notification from "@scm-manager/ui-components/src/Notification";
import { WithTranslation, withTranslation } from "react-i18next";