Files
mattermost/webapp/components/channel_invite_button.jsx
Harrison Healey fb6f2a123c PLT-5860 Updated copyright date (#6058)
* PLT-5860 Updated copyright date in about modal

* PLT-5860 Updated copyright notice in JSX files

* PLT-5860 Updated copyright notice in go files

* Fixed misc copyright dates

* Fixed component snapshots
2017-04-12 08:27:57 -04:00

72 lines
1.8 KiB
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import SpinnerButton from 'components/spinner_button.jsx';
import {addUserToChannel} from 'actions/channel_actions.jsx';
import React from 'react';
import {FormattedMessage} from 'react-intl';
export default class ChannelInviteButton extends React.Component {
static get propTypes() {
return {
user: React.PropTypes.object.isRequired,
channel: React.PropTypes.object.isRequired,
onInviteError: React.PropTypes.func.isRequired
};
}
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
this.state = {
addingUser: false
};
}
handleClick() {
if (this.state.addingUser) {
return;
}
this.setState({
addingUser: true
});
addUserToChannel(
this.props.channel.id,
this.props.user.id,
() => {
this.props.onInviteError(null);
},
(err) => {
this.setState({
addingUser: false
});
this.props.onInviteError(err);
}
);
}
render() {
return (
<SpinnerButton
id='addMembers'
className='btn btn-sm btn-primary'
onClick={this.handleClick}
spinning={this.state.addingUser}
>
<i className='fa fa-envelope fa-margin--right'/>
<FormattedMessage
id='channel_invite.add'
defaultMessage=' Add'
/>
</SpinnerButton>
);
}
}