summaryrefslogtreecommitdiff
path: root/frontend/app/app.js
blob: 8dbbd0fbe7aa6cb29f95bf17811c085341e19691 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React, { Component } from 'react'
import { ConnectedRouter } from 'connected-react-router'
import { Route } from 'react-router'

// import actions from 'app/actions'

import * as views from 'app/views'

const viewList = Object.keys(views).map(name => {
  const view = views[name]
  let path, exact = false
  if (name === 'graph') {
    path = '/:graph_name'
    exact = true
  } else if (name === 'page') {
    path = '/:graph_name/:page_name'
    exact = true
  } else {
    path = '/' + name
  }
  return (
    <Route key={name} path={path} component={view} exact={exact} />
  )
})

export default class App extends Component {
  componentDidMount() {
    // actions.modelzoo.index()
  }
  render() {
    return (
      <ConnectedRouter history={this.props.history}>
        <div className='app'>
          {viewList}
          <Route exact key='root' path='/' render={() => {
            // redirect to index!!
            setTimeout(() => this.props.history.push('/index'), 10)
            return null
          }} />
        </div>
      </ConnectedRouter>
    )
  }
}