refactor: routes as constants (#191)
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ import { ThemeProvider } from '@material-ui/styles'
|
|||||||
import CssBaseline from '@material-ui/core/CssBaseline'
|
import CssBaseline from '@material-ui/core/CssBaseline'
|
||||||
import { SnackbarProvider } from 'notistack'
|
import { SnackbarProvider } from 'notistack'
|
||||||
|
|
||||||
import BaseRouter from './routes/routes'
|
import BaseRouter from './routes'
|
||||||
import Dashboard from './layout/Dashboard'
|
import Dashboard from './layout/Dashboard'
|
||||||
import { theme } from './theme'
|
import { theme } from './theme'
|
||||||
import { Provider as StampsProvider } from './providers/Stamps'
|
import { Provider as StampsProvider } from './providers/Stamps'
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { createStyles, Theme, makeStyles } from '@material-ui/core/styles'
|
|||||||
import { ListItemText, ListItemIcon, ListItem, Divider, List, Drawer, Link as MUILink } from '@material-ui/core'
|
import { ListItemText, ListItemIcon, ListItem, Divider, List, Drawer, Link as MUILink } from '@material-ui/core'
|
||||||
import { OpenInNewSharp } from '@material-ui/icons'
|
import { OpenInNewSharp } from '@material-ui/icons'
|
||||||
import { Home, FileText, DollarSign, Share2, Settings, Layers } from 'react-feather'
|
import { Home, FileText, DollarSign, Share2, Settings, Layers } from 'react-feather'
|
||||||
|
import { ROUTES } from '../routes'
|
||||||
|
|
||||||
import SwarmLogoOrange from '../assets/swarm-logo-orange.svg'
|
import SwarmLogoOrange from '../assets/swarm-logo-orange.svg'
|
||||||
|
|
||||||
@@ -14,37 +15,37 @@ const navBarItems = [
|
|||||||
{
|
{
|
||||||
label: 'Info',
|
label: 'Info',
|
||||||
id: 'info',
|
id: 'info',
|
||||||
path: '/',
|
path: ROUTES.INFO,
|
||||||
icon: Home,
|
icon: Home,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Files',
|
label: 'Files',
|
||||||
id: 'files',
|
id: 'files',
|
||||||
path: '/files/',
|
path: ROUTES.FILES,
|
||||||
icon: FileText,
|
icon: FileText,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Stamps',
|
label: 'Stamps',
|
||||||
id: 'stamps',
|
id: 'stamps',
|
||||||
path: '/stamps/',
|
path: ROUTES.STAMPS,
|
||||||
icon: Layers,
|
icon: Layers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Accounting',
|
label: 'Accounting',
|
||||||
id: 'accounting',
|
id: 'accounting',
|
||||||
path: '/accounting/',
|
path: ROUTES.ACCOUNTING,
|
||||||
icon: DollarSign,
|
icon: DollarSign,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Peers',
|
label: 'Peers',
|
||||||
id: 'peers',
|
id: 'peers',
|
||||||
path: '/peers/',
|
path: ROUTES.PEERS,
|
||||||
icon: Share2,
|
icon: Share2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Settings',
|
label: 'Settings',
|
||||||
id: 'settings',
|
id: 'settings',
|
||||||
path: '/settings/',
|
path: ROUTES.SETTINGS,
|
||||||
icon: Settings,
|
icon: Settings,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -99,7 +100,7 @@ export default function SideBar(props: Props): ReactElement {
|
|||||||
anchor="left"
|
anchor="left"
|
||||||
>
|
>
|
||||||
<div className={classes.toolbar} style={{ textAlign: 'left', marginLeft: 20 }}>
|
<div className={classes.toolbar} style={{ textAlign: 'left', marginLeft: 20 }}>
|
||||||
<Link to="/">
|
<Link to={ROUTES.INFO}>
|
||||||
<img
|
<img
|
||||||
alt="swarm"
|
alt="swarm"
|
||||||
className={classes.logo}
|
className={classes.logo}
|
||||||
@@ -137,7 +138,7 @@ export default function SideBar(props: Props): ReactElement {
|
|||||||
</MUILink>
|
</MUILink>
|
||||||
</List>
|
</List>
|
||||||
<div style={{ position: 'fixed', bottom: 0, width: 'inherit', padding: '10px' }}>
|
<div style={{ position: 'fixed', bottom: 0, width: 'inherit', padding: '10px' }}>
|
||||||
<Link to="/status" style={{ marginRight: '30px', color: 'inherit', textDecoration: 'none' }}>
|
<Link to={ROUTES.STATUS} style={{ marginRight: '30px', color: 'inherit', textDecoration: 'none' }}>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom'
|
|||||||
|
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import { Card, CardContent, Typography } from '@material-ui/core/'
|
import { Card, CardContent, Typography } from '@material-ui/core/'
|
||||||
|
import { ROUTES } from '../routes'
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
root: {
|
root: {
|
||||||
@@ -26,7 +27,7 @@ export default function TroubleshootConnectionCard(): ReactElement {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<div style={{ marginBottom: '20px', textAlign: 'center' }}>
|
<div style={{ marginBottom: '20px', textAlign: 'center' }}>
|
||||||
<strong>
|
<strong>
|
||||||
<Link to="/status">Click to run status checks</Link> on your nodes connection or check out the{' '}
|
<Link to={ROUTES.STATUS}>Click to run status checks</Link> on your nodes connection or check out the{' '}
|
||||||
<a href={process.env.REACT_APP_BEE_DOCS_HOST} target="_blank" rel="noreferrer">
|
<a href={process.env.REACT_APP_BEE_DOCS_HOST} target="_blank" rel="noreferrer">
|
||||||
Swarm Bee Docs
|
Swarm Bee Docs
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { createStyles, makeStyles } from '@material-ui/core/styles'
|
|||||||
import { Card, CardContent, Typography, Chip, Button } from '@material-ui/core/'
|
import { Card, CardContent, Typography, Chip, Button } from '@material-ui/core/'
|
||||||
import { ArrowRight, ArrowDropUp } from '@material-ui/icons/'
|
import { ArrowRight, ArrowDropUp } from '@material-ui/icons/'
|
||||||
import { NodeAddresses, Topology } from '@ethersphere/bee-js'
|
import { NodeAddresses, Topology } from '@ethersphere/bee-js'
|
||||||
|
import { ROUTES } from '../../routes'
|
||||||
|
|
||||||
const useStyles = makeStyles(() =>
|
const useStyles = makeStyles(() =>
|
||||||
createStyles({
|
createStyles({
|
||||||
@@ -48,7 +49,7 @@ function StatusCard({
|
|||||||
<span style={{ marginRight: '20px' }}>Discovered Nodes: {nodeTopology?.population}</span>
|
<span style={{ marginRight: '20px' }}>Discovered Nodes: {nodeTopology?.population}</span>
|
||||||
<span style={{ marginRight: '20px' }}>
|
<span style={{ marginRight: '20px' }}>
|
||||||
<span>Connected Peers: </span>
|
<span>Connected Peers: </span>
|
||||||
<Link to="/peers/">{nodeTopology?.connected}</Link>
|
<Link to={ROUTES.PEERS}>{nodeTopology?.connected}</Link>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import type { ReactElement } from 'react'
|
||||||
|
import { Switch } from 'react-router-dom'
|
||||||
|
|
||||||
|
import { Route } from 'react-router-dom'
|
||||||
|
|
||||||
|
import Info from './pages/info'
|
||||||
|
import Status from './pages/status'
|
||||||
|
import Files from './pages/files'
|
||||||
|
import Peers from './pages/peers'
|
||||||
|
import Accounting from './pages/accounting'
|
||||||
|
import Settings from './pages/settings'
|
||||||
|
import Stamps from './pages/stamps'
|
||||||
|
|
||||||
|
export enum ROUTES {
|
||||||
|
INFO = '/',
|
||||||
|
FILES = '/files',
|
||||||
|
PEERS = '/peers',
|
||||||
|
ACCOUNTING = '/accounting',
|
||||||
|
SETTINGS = '/settings',
|
||||||
|
STAMPS = '/stamps',
|
||||||
|
STATUS = '/status',
|
||||||
|
}
|
||||||
|
|
||||||
|
const BaseRouter = (): ReactElement => (
|
||||||
|
<Switch>
|
||||||
|
<Route exact path={ROUTES.INFO} component={Info} />
|
||||||
|
<Route exact path={ROUTES.FILES} component={Files} />
|
||||||
|
<Route exact path={ROUTES.PEERS} component={Peers} />
|
||||||
|
<Route exact path={ROUTES.ACCOUNTING} component={Accounting} />
|
||||||
|
<Route exact path={ROUTES.SETTINGS} component={Settings} />
|
||||||
|
<Route exact path={ROUTES.STAMPS} component={Stamps} />
|
||||||
|
<Route exact path={ROUTES.STATUS} component={Status} />
|
||||||
|
</Switch>
|
||||||
|
)
|
||||||
|
|
||||||
|
export default BaseRouter
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import type { ReactElement } from 'react'
|
|
||||||
import { Switch } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { Route } from 'react-router-dom'
|
|
||||||
|
|
||||||
import Info from '../pages/info'
|
|
||||||
import Status from '../pages/status'
|
|
||||||
import Files from '../pages/files'
|
|
||||||
import Peers from '../pages/peers'
|
|
||||||
import Accounting from '../pages/accounting'
|
|
||||||
import Settings from '../pages/settings'
|
|
||||||
import Stamps from '../pages/stamps'
|
|
||||||
|
|
||||||
const BaseRouter = (): ReactElement => (
|
|
||||||
<Switch>
|
|
||||||
<Route exact path="/" component={Info} />
|
|
||||||
<Route exact path="/files/" component={Files} />
|
|
||||||
<Route exact path="/peers/" component={Peers} />
|
|
||||||
<Route exact path="/accounting/" component={Accounting} />
|
|
||||||
<Route exact path="/settings/" component={Settings} />
|
|
||||||
<Route exact path="/stamps/" component={Stamps} />
|
|
||||||
<Route exact path="/status" component={Status} />
|
|
||||||
</Switch>
|
|
||||||
)
|
|
||||||
|
|
||||||
export default BaseRouter
|
|
||||||
Reference in New Issue
Block a user