mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Transition after setup step 3 submission even if invite takes a long time
refs #5779 - adds a timeout of 4 seconds to step 3 submission so that we transition even if we haven't heard back from the server yet. Notification alerts will be displayed asynchronously once all server requests have returned. - adds a message to check e-mail configuration to step 3 invitation failure alert
This commit is contained in:
parent
268600d794
commit
167aca64f9
1 changed files with 29 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import DS from 'ember-data';
|
import DS from 'ember-data';
|
||||||
|
|
||||||
const {Controller, RSVP, computed, inject} = Ember;
|
const {Controller, RSVP, computed, inject, run} = Ember;
|
||||||
const {Errors} = DS;
|
const {Errors} = DS;
|
||||||
const {alias} = computed;
|
const {alias} = computed;
|
||||||
const emberA = Ember.A;
|
const emberA = Ember.A;
|
||||||
|
@ -131,6 +131,13 @@ export default Controller.extend({
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
_transitionAfterSubmission() {
|
||||||
|
if (!this._hasTransitioned) {
|
||||||
|
this._hasTransitioned = true;
|
||||||
|
this.transitionToRoute('posts.index');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
validate() {
|
validate() {
|
||||||
this.validate();
|
this.validate();
|
||||||
|
@ -139,10 +146,17 @@ export default Controller.extend({
|
||||||
invite() {
|
invite() {
|
||||||
let users = this.get('usersArray');
|
let users = this.get('usersArray');
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.get('notifications');
|
||||||
let invitationsString;
|
let invitationsString, submissionTimeout;
|
||||||
|
|
||||||
if (this.validate() && users.length > 0) {
|
if (this.validate() && users.length > 0) {
|
||||||
this.toggleProperty('submitting');
|
this.set('submitting', true);
|
||||||
|
this._hasTransitioned = false;
|
||||||
|
|
||||||
|
// wait for 4 seconds, otherwise transition anyway
|
||||||
|
submissionTimeout = run.later(this, function () {
|
||||||
|
this._transitionAfterSubmission();
|
||||||
|
}, 4000);
|
||||||
|
|
||||||
this.get('authorRole').then((authorRole) => {
|
this.get('authorRole').then((authorRole) => {
|
||||||
RSVP.Promise.all(
|
RSVP.Promise.all(
|
||||||
users.map((user) => {
|
users.map((user) => {
|
||||||
|
@ -169,6 +183,8 @@ export default Controller.extend({
|
||||||
let successCount = 0;
|
let successCount = 0;
|
||||||
let message;
|
let message;
|
||||||
|
|
||||||
|
run.cancel(submissionTimeout);
|
||||||
|
|
||||||
invites.forEach((invite) => {
|
invites.forEach((invite) => {
|
||||||
if (invite.success) {
|
if (invite.success) {
|
||||||
successCount++;
|
successCount++;
|
||||||
|
@ -181,6 +197,9 @@ export default Controller.extend({
|
||||||
invitationsString = erroredEmails.length > 1 ? ' invitations: ' : ' invitation: ';
|
invitationsString = erroredEmails.length > 1 ? ' invitations: ' : ' invitation: ';
|
||||||
message = `Failed to send ${erroredEmails.length} ${invitationsString}`;
|
message = `Failed to send ${erroredEmails.length} ${invitationsString}`;
|
||||||
message += erroredEmails.join(', ');
|
message += erroredEmails.join(', ');
|
||||||
|
message += ". Please check your email configuration, see <a href=\'http://support.ghost.org/mail\' target=\'_blank\'>http://support.ghost.org/mail</a> for instructions";
|
||||||
|
|
||||||
|
message = Ember.String.htmlSafe(message);
|
||||||
notifications.showAlert(message, {type: 'error', delayed: successCount > 0, key: 'signup.send-invitations.failed'});
|
notifications.showAlert(message, {type: 'error', delayed: successCount > 0, key: 'signup.send-invitations.failed'});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,9 +208,13 @@ export default Controller.extend({
|
||||||
invitationsString = successCount > 1 ? 'invitations' : 'invitation';
|
invitationsString = successCount > 1 ? 'invitations' : 'invitation';
|
||||||
notifications.showAlert(`${successCount} ${invitationsString} sent!`, {type: 'success', delayed: true, key: 'signup.send-invitations.success'});
|
notifications.showAlert(`${successCount} ${invitationsString} sent!`, {type: 'success', delayed: true, key: 'signup.send-invitations.success'});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.set('submitting', false);
|
||||||
|
|
||||||
|
run.schedule('actions', this, function () {
|
||||||
this.send('loadServerNotifications');
|
this.send('loadServerNotifications');
|
||||||
this.toggleProperty('submitting');
|
this._transitionAfterSubmission();
|
||||||
this.transitionToRoute('posts.index');
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (users.length === 0) {
|
} else if (users.length === 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue