summaryrefslogtreecommitdiff
path: root/frontend/app/views/page/components/page.header.js
blob: 6df3ee500f0d9e0fec9399c2a3b1c3e9f8dc5269 (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
45
46
47
48
49
50
51
52
53
import React from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom'

import { Loader } from 'app/common'
import { capitalize } from 'app/utils'

import * as graphActions from '../../graph/graph.actions'
import * as pageActions from '../page.actions'

function PageHeader(props) {
  return (
    <header>
      <div>
        <Link to={props.graph ? "/" + props.graph.path : "/"} className="logo arrow">{"◁"}</Link>
        <b>{props.site.siteTitle}</b>
        {props.building && (
          <div className='building'>
            <div className='loader'>
              <Loader />
            </div>
            {capitalize(props.building)}ing...
          </div>
        )}
      </div>
      <div>
        <button onClick={() => props.pageActions.toggleAddTileForm()}>+ Add tile</button>
        <button onClick={() => props.pageActions.toggleTileList()}>Sort tiles</button>
        <button onClick={() => props.pageActions.togglePopups()}>Toggle popups</button>
        <button onClick={() => props.graphActions.toggleEditPageForm()}>Edit page</button>
        <button onClick={() => props.graphActions.viewPage(props.graph, props.router.location.pathname)}>View page</button>
      </div>
    </header>
  )
}

const mapStateToProps = (state) => ({
  // auth: state.auth,
  site: state.site,
  graph: state.graph.show.res,
  page: state.page.show.res,
  building: state.graph.editor.building,
  router: state.router,
  // isAuthenticated: state.auth.isAuthenticated,
})

const mapDispatchToProps = (dispatch) => ({
  graphActions: bindActionCreators({ ...graphActions }, dispatch),
  pageActions: bindActionCreators({ ...pageActions }, dispatch),
})

export default connect(mapStateToProps, mapDispatchToProps)(PageHeader)