// 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 = (