Added feedback to the Invite Members modal to indicate that emails are currently being sent

Этот коммит содержится в:
hmhealey
2015-11-12 10:29:06 -05:00
родитель 13a251a5ee
Коммит fd9ef64b85

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

@@ -31,7 +31,8 @@ export default class InviteMemberModal extends React.Component {
firstNameErrors: {}, firstNameErrors: {},
lastNameErrors: {}, lastNameErrors: {},
emailEnabled: global.window.mm_config.SendEmailNotifications === 'true', emailEnabled: global.window.mm_config.SendEmailNotifications === 'true',
showConfirmModal: false showConfirmModal: false,
isSendingEmails: false
}; };
} }
@@ -89,10 +90,13 @@ export default class InviteMemberModal extends React.Component {
var data = {}; var data = {};
data.invites = invites; data.invites = invites;
this.setState({isSendingEmails: true});
Client.inviteMembers( Client.inviteMembers(
data, data,
() => { () => {
this.handleHide(false); this.handleHide(false);
this.setState({isSendingEmails: false});
}, },
(err) => { (err) => {
if (err.message === 'This person is already on your team') { if (err.message === 'This person is already on your team') {
@@ -101,6 +105,8 @@ export default class InviteMemberModal extends React.Component {
} else { } else {
this.setState({serverError: err.message}); this.setState({serverError: err.message});
} }
this.setState({isSendingEmails: false});
} }
); );
} }
@@ -289,11 +295,6 @@ export default class InviteMemberModal extends React.Component {
var content = null; var content = null;
var sendButton = null; var sendButton = null;
var sendButtonLabel = 'Send Invitation';
if (this.state.inviteIds.length > 1) {
sendButtonLabel = 'Send Invitations';
}
if (this.state.emailEnabled) { if (this.state.emailEnabled) {
content = ( content = (
<div> <div>
@@ -309,14 +310,25 @@ export default class InviteMemberModal extends React.Component {
</div> </div>
); );
sendButton = var sendButtonLabel = 'Send Invitation';
( if (this.state.isSendingEmails) {
<button sendButtonLabel = (
onClick={this.handleSubmit} <span><i className='fa fa-spinner fa-spin' />{' Sending'}</span>
type='button'
className='btn btn-primary'
>{sendButtonLabel}</button>
); );
} else if (this.state.inviteIds.length > 1) {
sendButtonLabel = 'Send Invitations';
}
sendButton = (
<button
onClick={this.handleSubmit}
type='button'
className='btn btn-primary'
disabled={this.state.isSendingEmails}
>
{sendButtonLabel}
</button>
);
} else { } else {
var teamInviteLink = null; var teamInviteLink = null;
if (currentUser && TeamStore.getCurrent().type === 'O') { if (currentUser && TeamStore.getCurrent().type === 'O') {
@@ -351,12 +363,13 @@ export default class InviteMemberModal extends React.Component {
return ( return (
<div> <div>
<Modal <Modal
className='modal-invite-member' dialogClassName='modal-invite-member'
show={this.state.show} show={this.state.show}
onHide={this.handleHide.bind(this, true)} onHide={this.handleHide.bind(this, true)}
enforceFocus={!this.state.showConfirmModal} enforceFocus={!this.state.showConfirmModal}
backdrop={this.state.isSendingEmails ? 'static' : true}
> >
<Modal.Header closeButton={true}> <Modal.Header closeButton={!this.state.isSendingEmails}>
<Modal.Title>{'Invite New Member'}</Modal.Title> <Modal.Title>{'Invite New Member'}</Modal.Title>
</Modal.Header> </Modal.Header>
<Modal.Body ref='modalBody'> <Modal.Body ref='modalBody'>
@@ -370,6 +383,7 @@ export default class InviteMemberModal extends React.Component {
type='button' type='button'
className='btn btn-default' className='btn btn-default'
onClick={this.handleHide.bind(this, true)} onClick={this.handleHide.bind(this, true)}
disabled={this.state.isSendingEmails}
> >
{'Cancel'} {'Cancel'}
</button> </button>