| author | Alexandre Segura <mex.zktk@gmail.com> |
| Thu, 29 Jun 2017 17:02:21 +0200 | |
| changeset 107 | e6f85e26b08c |
| parent 105 | 0a1d6560acac |
| child 129 | d48946d164c6 |
| permissions | -rw-r--r-- |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
1 |
import PropTypes from 'prop-types'; |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
2 |
import React, { Component } from 'react'; |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
3 |
import { connect } from 'react-redux'; |
|
105
0a1d6560acac
Introduce authenticated routes.
Alexandre Segura <mex.zktk@gmail.com>
parents:
104
diff
changeset
|
4 |
import { withRouter } from 'react-router'; |
| 52 | 5 |
import { bindActionCreators } from 'redux'; |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
6 |
// import logo from './logo.svg'; |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
7 |
import { Navbar, Nav, NavItem, NavDropdown, MenuItem, Modal, Button } from 'react-bootstrap'; |
| 52 | 8 |
import * as authActions from '../actions/authActions'; |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
9 |
|
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
10 |
const LoginNav = ({isAuthenticated, currentUser, history, authActions, onLogout}) => { |
|
65
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
11 |
|
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
12 |
const onClickSettings = (e) => { |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
13 |
e.preventDefault(); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
14 |
history.push('/settings'); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
15 |
} |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
16 |
|
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
17 |
const onClickLogin = (e) => { |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
18 |
e.preventDefault(); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
19 |
history.push('/login'); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
20 |
} |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
21 |
|
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
22 |
if (isAuthenticated) { |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
23 |
return ( |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
24 |
<NavDropdown title={ currentUser.get('username') } id="user-dropdown"> |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
25 |
<MenuItem onClick={onClickSettings}>Settings</MenuItem> |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
26 |
<MenuItem onClick={onLogout}>Logout</MenuItem> |
|
65
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
27 |
</NavDropdown> |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
28 |
); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
29 |
} |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
30 |
return ( |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
31 |
<NavItem onClick={onClickLogin} href="/login">Login</NavItem> |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
32 |
); |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
33 |
} |
|
14989b339e5d
Use a fonctionnal component for the login part of the navbar
ymh <ymh.work@gmail.com>
parents:
62
diff
changeset
|
34 |
|
|
81
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
35 |
const Online = ({ offline }) => { |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
36 |
return ( |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
37 |
<NavItem> |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
38 |
<span className="material-icons" style={{ color: offline.online ? '#2ECC71' : '#E74C3C' }}>signal_wifi_4_bar</span> |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
39 |
</NavItem> |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
40 |
) |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
41 |
} |
|
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
42 |
|
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
43 |
class AppNavbar extends Component { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
44 |
|
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
45 |
state = { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
46 |
showModal: false |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
47 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
48 |
|
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
49 |
closeModal = () => { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
50 |
this.setState({ showModal: false }); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
51 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
52 |
|
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
53 |
onClickHome = (e) => { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
54 |
e.preventDefault(); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
55 |
this.props.history.push('/'); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
56 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
57 |
|
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
58 |
isOutboxEmpty = () => { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
59 |
return this.props.offline.outbox.length === 0; |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
60 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
61 |
|
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
62 |
onClickLogout = (e) => { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
63 |
e.preventDefault(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
64 |
const isOutboxEmpty = this.isOutboxEmpty(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
65 |
if (isOutboxEmpty) { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
66 |
this.logout(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
67 |
} else { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
68 |
this.setState({ showModal: true }) |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
69 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
70 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
71 |
|
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
72 |
confirmLogout = () => { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
73 |
const isOutboxEmpty = this.isOutboxEmpty(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
74 |
if (!isOutboxEmpty) { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
75 |
this.props.authActions.purgeOutbox(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
76 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
77 |
this.logout(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
78 |
this.closeModal(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
79 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
80 |
|
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
81 |
logout = () => { |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
82 |
this.props.authActions.logout(); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
83 |
this.props.history.push('/'); |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
84 |
} |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
85 |
|
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
86 |
onClickSessions = (e) => { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
87 |
e.preventDefault(); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
88 |
this.props.history.push('/sessions'); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
89 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
90 |
|
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
91 |
render() { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
92 |
return ( |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
93 |
<Navbar fluid inverse fixedTop> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
94 |
<Navbar.Header> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
95 |
<Navbar.Brand> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
96 |
<a onClick={this.onClickHome} href="/">IRI Notes</a> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
97 |
</Navbar.Brand> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
98 |
<Navbar.Toggle /> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
99 |
</Navbar.Header> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
100 |
<Navbar.Collapse> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
101 |
<Nav> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
102 |
<NavItem onClick={this.onClickSessions} href="/sessions">Sessions</NavItem> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
103 |
</Nav> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
104 |
<Nav pullRight> |
|
81
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
105 |
<Online {...this.props} /> |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
106 |
<LoginNav {...this.props} onLogout={this.onClickLogout} /> |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
107 |
</Nav> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
108 |
</Navbar.Collapse> |
|
107
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
109 |
<Modal show={this.state.showModal} onHide={this.closeModal}> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
110 |
<Modal.Body> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
111 |
<p className="text-center"> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
112 |
Some data is not synchronized with server. |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
113 |
<br /> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
114 |
If you continue, it will be lost. |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
115 |
</p> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
116 |
</Modal.Body> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
117 |
<Modal.Footer> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
118 |
<Button bsStyle="primary" onClick={this.confirmLogout}>Confirm</Button> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
119 |
<Button onClick={this.closeModal}>Close</Button> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
120 |
</Modal.Footer> |
|
e6f85e26b08c
Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents:
105
diff
changeset
|
121 |
</Modal> |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
122 |
</Navbar> |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
123 |
); |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
124 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
125 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
126 |
|
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
127 |
AppNavbar.propTypes = { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
128 |
isAuthenticated: PropTypes.bool.isRequired |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
129 |
}; |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
130 |
|
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
131 |
function mapStateToProps(state, props) { |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
132 |
return { |
|
62
b2514a9bcd49
migrate to redux-offline + various optimisation
ymh <ymh.work@gmail.com>
parents:
59
diff
changeset
|
133 |
isAuthenticated: state['isAuthenticated'], |
|
b2514a9bcd49
migrate to redux-offline + various optimisation
ymh <ymh.work@gmail.com>
parents:
59
diff
changeset
|
134 |
currentUser: state['currentUser'], |
|
81
a6bd1aaddc34
Add online/offline indicator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
65
diff
changeset
|
135 |
offline: state['offline'] |
|
12
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
136 |
}; |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
137 |
} |
|
48ddaa42b810
Draft implementation of sessions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
138 |
|
| 52 | 139 |
function mapDispatchToProps(dispatch) { |
140 |
return { |
|
141 |
authActions: bindActionCreators(authActions, dispatch), |
|
142 |
} |
|
143 |
} |
|
144 |
||
|
105
0a1d6560acac
Introduce authenticated routes.
Alexandre Segura <mex.zktk@gmail.com>
parents:
104
diff
changeset
|
145 |
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(AppNavbar)); |