mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Changed ChannelInviteModal to use a FilteredUserList
This commit is contained in:
committed by
Harrison Healey
parent
f7c943e60a
commit
b61ec9f883
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||
// 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 UserStore from '../stores/user_store.jsx';
|
||||
@@ -22,6 +22,8 @@ export default class ChannelInviteModal extends React.Component {
|
||||
this.onListenerChange = this.onListenerChange.bind(this);
|
||||
this.handleInvite = this.handleInvite.bind(this);
|
||||
|
||||
this.createInviteButton = this.createInviteButton.bind(this);
|
||||
|
||||
// the state gets populated when the modal is shown
|
||||
this.state = {};
|
||||
}
|
||||
@@ -78,12 +80,13 @@ export default class ChannelInviteModal extends React.Component {
|
||||
};
|
||||
}
|
||||
onShow() {
|
||||
if ($(window).width() > 768) {
|
||||
// TODO ugh
|
||||
/*if ($(window).width() > 768) {
|
||||
$(ReactDOM.findDOMNode(this.refs.modalBody)).perfectScrollbar();
|
||||
$(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 200);
|
||||
} else {
|
||||
$(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 150);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.show && !prevProps.show) {
|
||||
@@ -108,9 +111,10 @@ export default class ChannelInviteModal extends React.Component {
|
||||
this.setState(newState);
|
||||
}
|
||||
}
|
||||
handleInvite(userId) {
|
||||
var data = {};
|
||||
data.user_id = userId;
|
||||
handleInvite(user) {
|
||||
const data = {
|
||||
user_id: user.id
|
||||
};
|
||||
|
||||
Client.addChannelMember(
|
||||
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() {
|
||||
var inviteError = null;
|
||||
if (this.state.inviteError) {
|
||||
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;
|
||||
if (this.state.loading) {
|
||||
content = (<LoadingScreen/>);
|
||||
} else {
|
||||
content = (
|
||||
<MemberList
|
||||
memberList={this.state.nonmembers}
|
||||
isAdmin={isAdmin}
|
||||
handleInvite={this.handleInvite}
|
||||
<FilteredUserList
|
||||
users={this.state.nonmembers}
|
||||
actions={[this.createInviteButton]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user