// 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'); var Constants = require('../utils/constants.jsx'); function getStateFromStores() { return { teams: UserStore.getTeams() }; } var NavbarDropdown = React.createClass({ handleLogoutClick: function(e) { e.preventDefault(); client.logout(); }, blockToggle: false, componentDidMount: function() { UserStore.addTeamsChangeListener(this._onChange); var self = this; $(this.refs.dropdown.getDOMNode()).on('hide.bs.dropdown', function(e) { self.blockToggle = true; setTimeout(function(){self.blockToggle = false;}, 100); }); }, componentWillUnmount: function() { UserStore.removeTeamsChangeListener(this._onChange); $(this.refs.dropdown.getDOMNode()).off('hide.bs.dropdown'); }, _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 = (