diff options
author | Corey Hulen <corey@hulen.com> | 2016-03-22 08:08:46 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-03-22 08:08:46 -0700 |
commit | 6568e15023c009c96a46f022236f5fd4415445c0 (patch) | |
tree | f17fd6d8fce9feb44adc17a4880a4f7dc5cb6897 /webapp/components/channel_invite_button.jsx | |
parent | bb212949f9f90ea3f4f7c07c7e3ca624c2843a90 (diff) | |
parent | 4e3eb2bb181ff6baad9911e231558eee0a08291c (diff) | |
download | chat-6568e15023c009c96a46f022236f5fd4415445c0.tar.gz chat-6568e15023c009c96a46f022236f5fd4415445c0.tar.bz2 chat-6568e15023c009c96a46f022236f5fd4415445c0.zip |
Merge pull request #2498 from hmhealey/plt2285
PLT-2285 Adding spinner after clicking invite channel member button
Diffstat (limited to 'webapp/components/channel_invite_button.jsx')
-rw-r--r-- | webapp/components/channel_invite_button.jsx | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/webapp/components/channel_invite_button.jsx b/webapp/components/channel_invite_button.jsx new file mode 100644 index 000000000..e4af9f9ce --- /dev/null +++ b/webapp/components/channel_invite_button.jsx @@ -0,0 +1,79 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import * as AsyncClient from 'utils/async_client.jsx'; +import * as Client from 'utils/client.jsx'; + +import {FormattedMessage} from 'react-intl'; +import SpinnerButton from 'components/spinner_button.jsx'; + +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 + }); + + const data = { + user_id: this.props.user.id + }; + + Client.addChannelMember( + this.props.channel.id, + data, + () => { + this.setState({ + addingUser: false + }); + + this.props.onInviteError(null); + AsyncClient.getChannelExtraInfo(); + }, + (err) => { + this.setState({ + addingUser: false + }); + + this.props.onInviteError(err); + } + ); + } + + render() { + return ( + <SpinnerButton + onClick={this.handleClick} + spinning={this.state.addingUser} + > + <i className='glyphicon glyphicon-envelope'/> + <FormattedMessage + id='channel_invite.add' + defaultMessage=' Add' + /> + </SpinnerButton> + ); + } +} |