2018-02-20 02:35:31 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { Route, Switch, Redirect } from 'react-router-dom';
|
|
|
|
import get from 'lodash.get';
|
|
|
|
|
|
|
|
import {
|
|
|
|
PageContainer,
|
|
|
|
ViewContainer,
|
|
|
|
Message,
|
|
|
|
MessageDescription,
|
2018-02-26 17:54:25 +02:00
|
|
|
MessageTitle,
|
|
|
|
Footer
|
2018-02-20 02:35:31 +02:00
|
|
|
} 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 */}
|
2018-02-20 02:35:31 +02:00
|
|
|
<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} />
|
2018-02-20 02:35:31 +02:00
|
|
|
</Switch>
|
|
|
|
|
2018-03-06 03:14:33 +02:00
|
|
|
{/* Menu */}
|
2018-02-20 02:35:31 +02:00
|
|
|
<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={() => {}} />
|
2018-02-20 02:35:31 +02:00
|
|
|
</Switch>
|
|
|
|
|
2018-03-06 03:14:33 +02:00
|
|
|
{/* Images */}
|
2018-02-20 02:35:31 +02:00
|
|
|
<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} />
|
2018-02-20 02:35:31 +02:00
|
|
|
<Route
|
2018-03-06 03:14:33 +02:00
|
|
|
path="/images/:image"
|
2018-02-20 02:35:31 +02:00
|
|
|
exact
|
|
|
|
component={({ match }) => (
|
2018-03-06 03:14:33 +02:00
|
|
|
<Redirect to={`/images/${get(match, 'params.image')}/summary`} />
|
2018-02-20 02:35:31 +02:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</Switch>
|
|
|
|
|
2018-03-06 03:14:33 +02:00
|
|
|
{/* Create Image */}
|
2018-02-20 02:35:31 +02:00
|
|
|
<Switch>
|
|
|
|
<Route
|
2018-03-06 03:14:33 +02:00
|
|
|
path="/images/~create/:instance?"
|
2018-02-20 02:35:31 +02:00
|
|
|
exact
|
|
|
|
component={({ match }) => (
|
2018-03-06 03:14:33 +02:00
|
|
|
<Redirect to={`/images/~create/${match.params.instance}/name`} />
|
2018-02-20 02:35:31 +02:00
|
|
|
)}
|
|
|
|
/>
|
2018-03-06 03:14:33 +02:00
|
|
|
<Route path="/images/~create/:instance/:step" component={Create} />
|
2018-02-20 02:35:31 +02:00
|
|
|
</Switch>
|
|
|
|
|
2018-03-06 03:14:33 +02:00
|
|
|
<Route path="/images/~server-error" component={ServerError} />
|
2018-02-20 02:35:31 +02:00
|
|
|
|
2018-03-23 02:57:18 +02:00
|
|
|
<Route path="/" exact component={() => <Redirect to="/images" />} />
|
|
|
|
|
2018-02-20 02:35:31 +02:00
|
|
|
<noscript>
|
|
|
|
<ViewContainer main>
|
|
|
|
<Message warning>
|
|
|
|
<MessageTitle>Ooops!</MessageTitle>
|
|
|
|
<MessageDescription>
|
|
|
|
You need to enable JavaScript to run this app.
|
|
|
|
</MessageDescription>
|
|
|
|
</Message>
|
|
|
|
</ViewContainer>
|
|
|
|
</noscript>
|
|
|
|
<Footer />
|
|
|
|
</PageContainer>
|
|
|
|
);
|