forked from BoostIO/BoostNote-Legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserContainer.jsx
More file actions
85 lines (80 loc) · 2.05 KB
/
Copy pathUserContainer.jsx
File metadata and controls
85 lines (80 loc) · 2.05 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var React = require('react/addons')
var ReactRouter = require('react-router')
var Link = ReactRouter.Link
var RouteHandler = ReactRouter.RouteHandler
// Dummy
var currentUser = {
name: 'testcat',
email: 'testcat@example.com',
profileName: 'Test Cat'
}
var userPlanets = [
{
id: 1,
name: 'testcat',
profileName: 'TestCat'
},
{
id: 2,
name: 'group1',
profileName: 'Some Group#1'
},
{
id: 3,
name: 'group2',
profileName: 'Some Group#1'
}
]
var UserNavigator = React.createClass({
propTypes: {
currentPlanet: React.PropTypes.object,
currentUser: React.PropTypes.object
},
render: function () {
var planets = userPlanets.map(function (planet, index) {
return (
<li key={planet.id} className={this.props.currentPlanet != null && this.props.currentPlanet.name === planet.name ? 'active' : ''}>
<a href>{planet.profileName[0]}</a>
<div className='shortCut'>⌘{index + 1}</div>
</li>
)
}.bind(this))
if (this.props.currentUser == null) {
return (
<div className='UserNavigator'>
</div>
)
}
return (
<div className='UserNavigator'>
<Link to='userHome' params={{userName: this.props.currentUser.name}} className='userConfig'>
<img width='50' height='50' src='../vendor/dummy.jpg'/>
</Link>
<ul>
{planets}
</ul>
<button className='newPlanet'><i className='fa fa-plus'/></button>
</div>
)
}
})
module.exports = React.createClass({
mixins: [React.addons.LinkedStateMixin, ReactRouter.Navigation],
render: function () {
var currentPlanetName = this.props.params.planetName
var currentPlanet = null
userPlanets.some(function (planet) {
if (planet.name === currentPlanetName) {
currentPlanet = planet
return true
}
return false
})
return (
<div className='UserContainer'>
<UserNavigator currentPlanet={currentPlanet} currentUser={currentUser}/>
<RouteHandler/>
</div>
)
}
})