blob: bab2897b6b611e2f1d3029bdb0d1c9d538416f94 (
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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var utils = require('../utils/utils.jsx');
var client = require('../utils/client.jsx');
var UserStore = require('../stores/user_store.jsx');
function getStateFromStores() {
return { teams: UserStore.getTeams() };
}
var NavbarDropdown = React.createClass({
handleLogoutClick: function(e) {
e.preventDefault();
client.logout();
},
componentDidMount: function() {
UserStore.addTeamsChangeListener(this._onChange);
},
componentWillUnmount: function() {
UserStore.removeTeamsChangeListener(this._onChange);
},
_onChange: function() {
if (this.isMounted()) {
var newState = getStateFromStores();
if (!utils.areStatesEqual(newState, this.state)) {
this.setState(newState);
}
}
},
getInitialState: function() {
return getStateFromStores();
},
render: function() {
var team_link = "";
var invite_link = "";
var manage_link = "";
var rename_link = "";
var currentUser = UserStore.getCurrentUser();
var isAdmin = false;
if (currentUser != null) {
isAdmin = currentUser.roles.indexOf("admin") > -1;
invite_link = ( <li> <a href="#" data-toggle="modal" data-target="#invite_member">Invite New Member</a> </li>);
if (this.props.teamType == "O") {
team_link = (
<li>
<a href="#" data-toggle="modal" data-target="#get_link" data-title="Team Invite" data-value={location.origin+"/signup_user_complete/?id="+currentUser.team_id}>Get Team Invite Link</a>
</li>
);
}
}
if (isAdmin) {
manage_link = ( <li> <a href="#" data-toggle="modal" data-target="#team_members">Manage Team</a> </li>);
rename_link = ( <li> <a href="#" data-toggle="modal" data-target="#rename_team_link">Rename</a> </li>);
}
var teams = [];
teams.push(<li className="divider" key="div"></li>);
if (this.state.teams.length > 1) {
for (var i = 0; i < this.state.teams.length; i++) {
var teamName = this.state.teams[i];
teams.push(<li key={ teamName }><a href={window.location.origin + "/" + teamName }>Switch to { teamName }</a></li>);
}
}
teams.push(<li><a href={window.location.origin + "/signup_team" }>Create a New Team</a></li>);
return (
<ul className="nav navbar-nav navbar-right">
<li className="dropdown">
<a href="#" className="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span className="dropdown__icon" dangerouslySetInnerHTML={{__html: " <svg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px'width='4px' height='16px' viewBox='0 0 8 32' enable-background='new 0 0 8 32' xml:space='preserve'> <g> <circle cx='4' cy='4.062' r='4'/> <circle cx='4' cy='16' r='4'/> <circle cx='4' cy='28' r='4'/> </g> </svg>"}} />
</a>
<ul className="dropdown-menu" role="menu">
<li><a href="#" data-toggle="modal" data-target="#user_settings1">Account Settings</a></li>
{ isAdmin ? <li><a href="#" data-toggle="modal" data-target="#team_settings">Team Settings</a></li> : null }
{ invite_link }
{ team_link }
{ manage_link }
{ rename_link }
<li><a href="#" onClick={this.handleLogoutClick}>Logout</a></li>
{ teams }
<li className="divider"></li>
<li><a target="_blank" href={config.HelpLink}>Help</a></li>
<li><a target="_blank" href={config.ReportProblemLink}>Report a Problem</a></li>
</ul>
</li>
</ul>
);
}
});
module.exports = React.createClass({
displayName: 'SidebarHeader',
getDefaultProps: function() {
return {
teamName: config.SiteName
};
},
render: function() {
var teamDisplayName = this.props.teamDisplayName ? this.props.teamDisplayName : config.SiteName;
var me = UserStore.getCurrentUser()
if (!me) {
return null;
}
return (
<div className="team__header theme">
<a className="settings_link" href="#" data-toggle="modal" data-target="#user_settings1">
<img className="user__picture" src={"/api/v1/users/" + me.id + "/image?time=" + me.update_at} />
<div className="header__info">
<div className="user__name">{ '@' + me.username}</div>
<div className="team__name">{ teamDisplayName }</div>
</div>
</a>
<NavbarDropdown teamType={this.props.teamType} />
</div>
);
}
});
|