Files
SCM-Manager/scm-ui/src/containers/Main.js

137 lines
3.8 KiB
JavaScript
Raw Normal View History

2018-07-02 14:50:13 +02:00
//@flow
2018-07-11 14:59:01 +02:00
import React from "react";
2018-07-02 14:50:13 +02:00
import { Redirect, Route, Switch, withRouter } from "react-router-dom";
import type { Links } from "@scm-manager/ui-types";
2018-07-02 14:50:13 +02:00
2018-07-31 16:32:16 +02:00
import Overview from "../repos/containers/Overview";
2018-07-11 14:59:01 +02:00
import Users from "../users/containers/Users";
2018-07-13 10:57:11 +02:00
import Login from "../containers/Login";
import Logout from "../containers/Logout";
2018-07-12 11:35:28 +02:00
import { ProtectedRoute } from "@scm-manager/ui-components";
import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
import AddUser from "../users/containers/AddUser";
2018-07-25 13:21:49 +02:00
import SingleUser from "../users/containers/SingleUser";
2018-08-02 16:09:58 +02:00
import RepositoryRoot from "../repos/containers/RepositoryRoot";
import Create from "../repos/containers/Create";
2018-07-02 14:50:13 +02:00
import Groups from "../groups/containers/Groups";
2018-07-31 15:09:45 +02:00
import SingleGroup from "../groups/containers/SingleGroup";
import AddGroup from "../groups/containers/AddGroup";
2018-08-09 09:38:55 +02:00
import Config from "../config/containers/Config";
import Profile from "./Profile";
2018-08-09 09:38:55 +02:00
2018-07-02 14:50:13 +02:00
type Props = {
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() {
const { authenticated, links } = this.props;
2019-02-05 08:45:03 +01:00
const redirectUrlFactory = binder.getExtension("main.redirect", this.props);
let url = "/repos";
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>
<Redirect exact from="/" to={url} />
2019-03-14 10:12:34 +01:00
<Route exact path="/login" component={Login} />
<Route path="/logout" component={Logout} />
<ProtectedRoute
exact
path="/repos"
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}
/>
<ProtectedRoute
exact
path="/users"
component={Users}
authenticated={authenticated}
/>
<ProtectedRoute
authenticated={authenticated}
path="/users/add"
component={AddUser}
/>
<ProtectedRoute
exact
path="/users/:page"
component={Users}
authenticated={authenticated}
/>
<ProtectedRoute
authenticated={authenticated}
path="/user/:name"
component={SingleUser}
/>
2018-11-07 14:45:27 +01:00
2019-03-14 10:12:34 +01:00
<ProtectedRoute
exact
path="/groups"
component={Groups}
authenticated={authenticated}
/>
<ProtectedRoute
authenticated={authenticated}
path="/group/:name"
component={SingleGroup}
/>
<ProtectedRoute
authenticated={authenticated}
path="/groups/add"
component={AddGroup}
/>
<ProtectedRoute
exact
path="/groups/:page"
component={Groups}
authenticated={authenticated}
/>
<ProtectedRoute
path="/config"
component={Config}
authenticated={authenticated}
/>
<ProtectedRoute
path="/me"
component={Profile}
authenticated={authenticated}
/>
2019-03-14 10:12:34 +01:00
<ExtensionPoint
name="main.route"
renderAll={true}
props={{ authenticated, links }}
2019-03-14 10:12:34 +01:00
/>
</Switch>
</div>
2018-07-02 14:50:13 +02:00
);
}
}
export default withRouter(Main);