Changed ChannelInviteModal to use a FilteredUserList

Этот коммит содержится в:
hmhealey
2016-02-26 12:01:01 -05:00
коммит произвёл Harrison Healey
родитель f7c943e60a
Коммит b61ec9f883

Просмотреть файл

@@ -1,7 +1,7 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
import MemberList from './member_list.jsx'; import FilteredUserList from './filtered_user_list.jsx';
import LoadingScreen from './loading_screen.jsx'; import LoadingScreen from './loading_screen.jsx';
import UserStore from '../stores/user_store.jsx'; import UserStore from '../stores/user_store.jsx';
@@ -22,6 +22,8 @@ export default class ChannelInviteModal extends React.Component {
this.onListenerChange = this.onListenerChange.bind(this); this.onListenerChange = this.onListenerChange.bind(this);
this.handleInvite = this.handleInvite.bind(this); this.handleInvite = this.handleInvite.bind(this);
this.createInviteButton = this.createInviteButton.bind(this);
// the state gets populated when the modal is shown // the state gets populated when the modal is shown
this.state = {}; this.state = {};
} }
@@ -78,12 +80,13 @@ export default class ChannelInviteModal extends React.Component {
}; };
} }
onShow() { onShow() {
if ($(window).width() > 768) { // TODO ugh
/*if ($(window).width() > 768) {
$(ReactDOM.findDOMNode(this.refs.modalBody)).perfectScrollbar(); $(ReactDOM.findDOMNode(this.refs.modalBody)).perfectScrollbar();
$(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 200); $(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 200);
} else { } else {
$(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 150); $(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 150);
} }*/
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if (this.props.show && !prevProps.show) { if (this.props.show && !prevProps.show) {
@@ -108,9 +111,10 @@ export default class ChannelInviteModal extends React.Component {
this.setState(newState); this.setState(newState);
} }
} }
handleInvite(userId) { handleInvite(user) {
var data = {}; const data = {
data.user_id = userId; user_id: user.id
};
Client.addChannelMember( Client.addChannelMember(
this.props.channel.id, this.props.channel.id,
@@ -124,27 +128,34 @@ export default class ChannelInviteModal extends React.Component {
} }
); );
} }
createInviteButton({user}) {
return (
<a
onClick={this.handleInvite.bind(this, user)}
className='btn btn-sm btn-primary'
>
<i className='glyphicon glyphicon-envelope'/>
<FormattedMessage
id='member_item.add'
defaultMessage=' Add'
/>
</a>
);
}
render() { render() {
var inviteError = null; var inviteError = null;
if (this.state.inviteError) { if (this.state.inviteError) {
inviteError = (<label className='has-error control-label'>{this.state.inviteError}</label>); inviteError = (<label className='has-error control-label'>{this.state.inviteError}</label>);
} }
var currentMember = ChannelStore.getCurrentMember();
var isAdmin = false;
if (currentMember) {
isAdmin = Utils.isAdmin(currentMember.roles) || Utils.isAdmin(UserStore.getCurrentUser().roles);
}
var content; var content;
if (this.state.loading) { if (this.state.loading) {
content = (<LoadingScreen/>); content = (<LoadingScreen/>);
} else { } else {
content = ( content = (
<MemberList <FilteredUserList
memberList={this.state.nonmembers} users={this.state.nonmembers}
isAdmin={isAdmin} actions={[this.createInviteButton]}
handleInvite={this.handleInvite}
/> />
); );
} }