mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Updating client dependancies. Switching to using yarn. * Updating React * Moving pure components to using function syntax (performance gains with newer react version) * Updating client dependancies. * Ignore .yarninstall * Enabling pre-lockfile because it's the entire point of using yarn. * Removing old webpack config * Moving to new prop-types * Fixing ESLint Errors * Updating jest snapshots. * Cleaning up package.json
74 lines
1.8 KiB
JavaScript
74 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 PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
import {FormattedMessage} from 'react-intl';
|
|
|
|
export default class ChannelInviteButton extends React.Component {
|
|
static get propTypes() {
|
|
return {
|
|
user: PropTypes.object.isRequired,
|
|
channel: PropTypes.object.isRequired,
|
|
onInviteError: 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>
|
|
);
|
|
}
|
|
}
|