joyent-portal/packages/my-joy-images/src/routes.js

86 lines
2.4 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';
import get from 'lodash.get';
import {
PageContainer,
ViewContainer,
Message,
MessageDescription,
MessageTitle,
Footer
} from 'joyent-ui-toolkit';
import Breadcrumb from '@containers/breadcrumb';
import Menu from '@containers/menu';
import List from '@containers/list';
import Summary from '@containers/summary';
import Create from '@containers/create';
import Tags from '@containers/tags';
import { Route as ServerError } from '@root/server-error';
export default () => (
<PageContainer>
2018-03-06 03:14:33 +02:00
{/* Breadcrumb */}
<Switch>
2018-03-06 03:14:33 +02:00
<Route path="/images/~server-error" component={Breadcrumb} />
<Route
path="/images/~create/:instance/:step?"
exact
component={Breadcrumb}
/>
<Route path="/images/:image?" component={Breadcrumb} />
</Switch>
2018-03-06 03:14:33 +02:00
{/* Menu */}
<Switch>
2018-03-06 03:14:33 +02:00
<Route path="/images/~server-error" component={() => null} />
<Route path="/images/:image/:section?" component={Menu} />
<Route path="/images/~create/:instance/:step?" component={() => {}} />
</Switch>
2018-03-06 03:14:33 +02:00
{/* Images */}
<Switch>
2018-03-06 03:14:33 +02:00
{/* <Route path="/images/~server-error" component={() => null} /> */}
<Route path="/images/" exact component={List} />
<Route path="/images/:image/summary" exact component={Summary} />
<Route path="/images/:image/tags" exact component={Tags} />
<Route
2018-03-06 03:14:33 +02:00
path="/images/:image"
exact
component={({ match }) => (
2018-03-06 03:14:33 +02:00
<Redirect to={`/images/${get(match, 'params.image')}/summary`} />
)}
/>
</Switch>
2018-03-06 03:14:33 +02:00
{/* Create Image */}
<Switch>
<Route
2018-03-06 03:14:33 +02:00
path="/images/~create/:instance?"
exact
component={({ match }) => (
2018-03-06 03:14:33 +02:00
<Redirect to={`/images/~create/${match.params.instance}/name`} />
)}
/>
2018-03-06 03:14:33 +02:00
<Route path="/images/~create/:instance/:step" component={Create} />
</Switch>
2018-03-06 03:14:33 +02:00
<Route path="/images/~server-error" component={ServerError} />
<Route path="/" exact component={() => <Redirect to="/images" />} />
<noscript>
<ViewContainer main>
<Message warning>
<MessageTitle>Ooops!</MessageTitle>
<MessageDescription>
You need to enable JavaScript to run this app.
</MessageDescription>
</Message>
</ViewContainer>
</noscript>
<Footer />
</PageContainer>
);