// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import ReactDOM from 'react-dom'; import {FormattedMessage} from 'react-intl'; import {Modal} from 'react-bootstrap'; import React from 'react'; import {sortTeamsByDisplayName} from 'utils/utils.jsx'; export default class SelectTeamModal extends React.Component { constructor(props) { super(props); this.doSubmit = this.doSubmit.bind(this); this.doCancel = this.doCancel.bind(this); } doSubmit(e) { e.preventDefault(); this.props.onModalSubmit(ReactDOM.findDOMNode(this.refs.team).value); } doCancel() { this.props.onModalDismissed(); } render() { if (this.props.teams == null) { return
; } const options = []; let teamsArray = []; Reflect.ownKeys(this.props.teams).forEach((key) => { teamsArray.push(this.props.teams[key]); }); teamsArray = teamsArray.sort(sortTeamsByDisplayName); for (let i = 0; i < teamsArray.length; i++) { const team = teamsArray[i]; options.push( ); } return (
); } } SelectTeamModal.defaultProps = { show: false }; SelectTeamModal.propTypes = { teams: React.PropTypes.object, show: React.PropTypes.bool.isRequired, onModalSubmit: React.PropTypes.func, onModalDismissed: React.PropTypes.func };