2019-10-20 18:02:52 +02:00
|
|
|
import React from "react";
|
2018-07-02 14:50:13 +02:00
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
import { Redirect, Route, Switch, withRouter } from "react-router-dom";
|
|
|
|
|
import { Links } from "@scm-manager/ui-types";
|
2018-07-02 14:50:13 +02:00
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
import Overview from "../repos/containers/Overview";
|
|
|
|
|
import Users from "../users/containers/Users";
|
|
|
|
|
import Login from "../containers/Login";
|
|
|
|
|
import Logout from "../containers/Logout";
|
2018-07-12 11:35:28 +02:00
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
import { ProtectedRoute } from "@scm-manager/ui-components";
|
|
|
|
|
import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
|
2019-01-07 10:10:06 +01:00
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
import CreateUser from "../users/containers/CreateUser";
|
|
|
|
|
import SingleUser from "../users/containers/SingleUser";
|
|
|
|
|
import RepositoryRoot from "../repos/containers/RepositoryRoot";
|
|
|
|
|
import Create from "../repos/containers/Create";
|
2018-07-02 14:50:13 +02:00
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
import Groups from "../groups/containers/Groups";
|
|
|
|
|
import SingleGroup from "../groups/containers/SingleGroup";
|
|
|
|
|
import CreateGroup from "../groups/containers/CreateGroup";
|
2018-07-31 10:16:18 +02:00
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
import Admin from "../admin/containers/Admin";
|
2019-06-19 09:59:32 +02:00
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
import Profile from "./Profile";
|
2018-08-09 09:38:55 +02:00
|
|
|
|
2018-07-02 14:50:13 +02:00
|
|
|
type Props = {
|
2019-10-19 16:38:07 +02:00
|
|
|
authenticated?: boolean;
|
|
|
|
|
links: Links;
|
2018-07-11 14:59:01 +02:00
|
|
|
};
|
2018-07-02 14:50:13 +02:00
|
|
|
|
|
|
|
|
class Main extends React.Component<Props> {
|
|
|
|
|
render() {
|
2019-01-11 13:10:15 +01:00
|
|
|
const { authenticated, links } = this.props;
|
2019-10-20 18:02:52 +02:00
|
|
|
const redirectUrlFactory = binder.getExtension("main.redirect", this.props);
|
|
|
|
|
let url = "/repos/";
|
2019-04-17 12:19:17 +02:00
|
|
|
if (redirectUrlFactory) {
|
2019-02-05 08:45:03 +01:00
|
|
|
url = redirectUrlFactory(this.props);
|
|
|
|
|
}
|
2018-07-02 14:50:13 +02:00
|
|
|
return (
|
2019-03-14 10:12:34 +01:00
|
|
|
<div className="main">
|
|
|
|
|
<Switch>
|
2019-04-17 12:19:17 +02:00
|
|
|
<Redirect exact from="/" to={url} />
|
2019-03-14 10:12:34 +01:00
|
|
|
<Route exact path="/login" component={Login} />
|
|
|
|
|
<Route path="/logout" component={Logout} />
|
2019-08-27 11:09:53 +02:00
|
|
|
<Redirect exact strict from="/repos" to="/repos/" />
|
2019-03-14 10:12:34 +01:00
|
|
|
<ProtectedRoute
|
|
|
|
|
exact
|
2019-08-27 11:07:19 +02:00
|
|
|
path="/repos/"
|
2019-03-14 10:12:34 +01:00
|
|
|
component={Overview}
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
exact
|
|
|
|
|
path="/repos/create"
|
|
|
|
|
component={Create}
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
exact
|
|
|
|
|
path="/repos/:page"
|
|
|
|
|
component={Overview}
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
path="/repo/:namespace/:name"
|
|
|
|
|
component={RepositoryRoot}
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
2019-08-27 11:07:19 +02:00
|
|
|
<Redirect exact strict from="/users" to="/users/" />
|
2019-03-14 10:12:34 +01:00
|
|
|
<ProtectedRoute
|
|
|
|
|
exact
|
2019-08-27 11:07:19 +02:00
|
|
|
path="/users/"
|
2019-03-14 10:12:34 +01:00
|
|
|
component={Users}
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
authenticated={authenticated}
|
2019-04-24 09:59:29 +02:00
|
|
|
path="/users/create"
|
|
|
|
|
component={CreateUser}
|
2019-03-14 10:12:34 +01:00
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
exact
|
|
|
|
|
path="/users/:page"
|
|
|
|
|
component={Users}
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
path="/user/:name"
|
|
|
|
|
component={SingleUser}
|
|
|
|
|
/>
|
2019-08-27 11:07:19 +02:00
|
|
|
<Redirect exact strict from="/groups" to="/groups/" />
|
2019-03-14 10:12:34 +01:00
|
|
|
<ProtectedRoute
|
|
|
|
|
exact
|
2019-08-27 11:07:19 +02:00
|
|
|
path="/groups/"
|
2019-03-14 10:12:34 +01:00
|
|
|
component={Groups}
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
path="/group/:name"
|
|
|
|
|
component={SingleGroup}
|
|
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
authenticated={authenticated}
|
2019-04-24 09:59:29 +02:00
|
|
|
path="/groups/create"
|
|
|
|
|
component={CreateGroup}
|
2019-03-14 10:12:34 +01:00
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
exact
|
|
|
|
|
path="/groups/:page"
|
|
|
|
|
component={Groups}
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
2019-06-19 09:59:32 +02:00
|
|
|
path="/admin"
|
|
|
|
|
component={Admin}
|
2019-03-14 10:12:34 +01:00
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
path="/me"
|
|
|
|
|
component={Profile}
|
|
|
|
|
authenticated={authenticated}
|
|
|
|
|
/>
|
|
|
|
|
<ExtensionPoint
|
|
|
|
|
name="main.route"
|
|
|
|
|
renderAll={true}
|
2019-10-19 16:38:07 +02:00
|
|
|
props={{
|
|
|
|
|
authenticated,
|
2019-10-20 18:02:52 +02:00
|
|
|
links
|
2019-10-19 16:38:07 +02:00
|
|
|
}}
|
2019-03-14 10:12:34 +01:00
|
|
|
/>
|
|
|
|
|
</Switch>
|
|
|
|
|
</div>
|
2018-07-02 14:50:13 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-12 08:23:24 +02:00
|
|
|
export default withRouter(Main);
|