aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pages/settings/index.js
blob: 39e9b26ed4bfe4ba82b9f3d6d098ce046f9110d1 (plain) (blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const { Component } = require('react')
const { Switch, Route, matchPath } = require('react-router-dom')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
const TabBar = require('../../tab-bar')
const Settings = require('./settings')
const Info = require('./info')
const { SETTINGS_ROUTE, INFO_ROUTE } = require('../../../routes')

class Config extends Component {
  renderTabs () {
    const { history, location } = this.props

    return h('div.settings__tabs', [
      h(TabBar, {
        tabs: [
          { content: 'Settings', key: SETTINGS_ROUTE },
          { content: 'Info', key: INFO_ROUTE },
        ],
        isActive: key => matchPath(location.pathname, { path: key, exact: true }),
        onSelect: key => history.push(key),
      }),
    ])
  }

  render () {
    const { history } = this.props

    return (
      h('.main-container.settings', {}, [
        h('.settings__header', [
          h('div.settings__close-button', {
            onClick: () => history.push('/'),
          }),
          this.renderTabs(),
        ]),
        h(Switch, [
          h(Route, {
            exact: true,
            path: INFO_ROUTE,
            component: Info,
          }),
          h(Route, {
            exact: true,
            path: SETTINGS_ROUTE,
            component: Settings,
          }),
        ]),
      ])
    )
  }
}

Config.propTypes = {
  location: PropTypes.object,
  history: PropTypes.object,
}

module.exports = Config