// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import UserStore from '../stores/user_store.jsx'; import * as Utils from '../utils/utils.jsx'; export default class MemberListItem extends React.Component { constructor(props) { super(props); this.handleInvite = this.handleInvite.bind(this); this.handleRemove = this.handleRemove.bind(this); this.handleMakeAdmin = this.handleMakeAdmin.bind(this); } handleInvite(e) { e.preventDefault(); this.props.handleInvite(this.props.member.id); } handleRemove(e) { e.preventDefault(); this.props.handleRemove(this.props.member.id); } handleMakeAdmin(e) { e.preventDefault(); this.props.handleMakeAdmin(this.props.member.id); } render() { var member = this.props.member; var isAdmin = this.props.isAdmin; var isMemberAdmin = Utils.isAdmin(member.roles); var timestamp = UserStore.getCurrentUser().update_at; var invite; if (member.invited && this.props.handleInvite) { invite = Added; } else if (this.props.handleInvite) { invite = ( {' Add'} ); } else if (isAdmin && !isMemberAdmin && (member.id !== UserStore.getCurrentId())) { var self = this; let makeAdminOption = null; if (this.props.handleMakeAdmin) { makeAdminOption = (
  • Make Admin
  • ); } let handleRemoveOption = null; if (this.props.handleRemove) { handleRemoveOption = (
  • Remove Member
  • ); } invite = (
    {member.roles || 'Member'}
    ); } else { invite =
    {member.roles || 'Member'}
    ; } return (
    {Utils.displayUsername(member.id)}
    {member.email}
    {invite} ); } } MemberListItem.propTypes = { handleInvite: React.PropTypes.func, handleRemove: React.PropTypes.func, handleMakeAdmin: React.PropTypes.func, member: React.PropTypes.object, isAdmin: React.PropTypes.bool };