joyent-portal/frontend/src/router.js

64 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-05-11 20:16:52 +03:00
import React from 'react';
import {
BrowserRouter,
Redirect,
Route,
Switch
} from 'react-router-dom';
2017-05-16 16:46:04 +03:00
import { Header } from '@components/navigation';
2017-05-11 20:16:52 +03:00
import { Breadcrumb, Menu } from '@containers/navigation';
import { DeploymentGroupList } from '@containers/deployment-groups';
2017-05-16 16:46:04 +03:00
import { ServiceList, ServicesTopology, ServicesMenu } from '@containers/services';
2017-05-11 20:16:52 +03:00
import { InstanceList } from '@containers/instances';
import { ServiceMetrics, SingleMetrics } from '@containers/service';
const rootRedirect = (p) => (
<Redirect to='/deployment-groups' />
);
const deploymentGroupRedirect = (p) => (
2017-05-16 16:46:04 +03:00
<Redirect to={`/deployment-groups/${p.match.params.deploymentGroup}/services-list`} />
2017-05-11 20:16:52 +03:00
);
const Router = (
<BrowserRouter>
2017-05-16 16:46:04 +03:00
<div>
<Route path='/' component={Header} />
2017-05-11 20:16:52 +03:00
<Switch>
<Route path='/deployment-groups/:deploymentGroup/services/:service' component={Breadcrumb} />
<Route path='/deployment-groups/:deploymentGroup' component={Breadcrumb} />
2017-05-16 16:46:04 +03:00
<Route path='/deployment-groups' component={Breadcrumb} />
2017-05-11 20:16:52 +03:00
</Switch>
<Switch>
<Route path='/deployment-groups/:deploymentGroup/services/:service' component={Menu} />
<Route path='/deployment-groups/:deploymentGroup' component={Menu} />
</Switch>
<Route path='/' exact component={rootRedirect} />
<Route path='/deployment-groups' exact component={DeploymentGroupList} />
<Route path='/deployment-groups/:deploymentGroup' exact component={deploymentGroupRedirect} />
2017-05-16 16:46:04 +03:00
<Route path='/deployment-groups/:deploymentGroup/services' exact component={deploymentGroupRedirect} />
<Route path={`/deployment-groups/:deploymentGroup/services-list`} exact component={ServicesMenu} />
<Route path='/deployment-groups/:deploymentGroup/services-list' exact component={ServiceList} />
<Route path={`/deployment-groups/:deploymentGroup/services-topology`} exact component={ServicesMenu} />
<Route path={`/deployment-groups/:deploymentGroup/services-topology`} exact component={ServicesTopology} />
2017-05-11 20:16:52 +03:00
<Route path='/deployment-groups/:deploymentGroup/services/:service/instances' exact component={InstanceList} />
<Route path='/deployment-groups/:deploymentGroup/services/:service/metrics' exact component={ServiceMetrics} />
<Route path='/deployment-groups/:deploymentGroup/services/:service/single-metrics' exact component={SingleMetrics} />
2017-05-16 16:46:04 +03:00
</div>
2017-05-11 20:16:52 +03:00
</BrowserRouter>
);
export default Router;