chore: 🤖 apply notify decorators to remaining routes

This commit is contained in:
Randall Morey committed 2020-10-09 16:45:49 -04:00
1 parent 5473ca1983
commit 38416cfeb0
3 files changed
+20 -32

No files matched your search

+10 -13
View File
@@ -1,6 +1,7 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { notifySuccess, notifyError } from '../../decorators/notify';
/**
* The change password flow is associated only with password-type auth methods.
@@ -33,20 +34,16 @@ export default class AccountChangePasswordRoute extends Route {
* @param {string} newPassword
*/
@action
@notifyError(({ message }) => message, { catch: true })
@notifySuccess('notifications.save-success')
async changePassword(account, currentPassword, newPassword) {
try {
await account.changePassword(currentPassword, newPassword);
// Transition to index after success. We ignore errors in the transition,
// since the index route is responsible for additional
// redirects depending on the authentication context. These additional
// redirects may abort this initial transition, resulting in a
// TransitionAborted error, which we do not want to show to the user.
await this.replaceWith('index').catch(() => {});
this.notify.success(this.intl.t('notifications.save-success'));
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
}
await account.changePassword(currentPassword, newPassword);
// Transition to index after success. We ignore errors in the transition,
// since the index route is responsible for additional
// redirects depending on the authentication context. These additional
// redirects may abort this initial transition, resulting in a
// TransitionAborted error, which we do not want to show to the user.
await this.replaceWith('index').catch(() => {});
}
/**
+6 -12
View File
@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { notifySuccess, notifyError } from '../../../decorators/notify';
export default class ScopesScopeOrgsRoute extends Route {
// =services
@@ -49,18 +50,11 @@ export default class ScopesScopeOrgsRoute extends Route {
*/
@action
@loading
@notifyError(({ message }) => message, { catch: true })
@notifySuccess('notifications.create-success')
async save(org) {
try {
await org.save();
await this.transitionTo('scopes.scope.projects', org);
this.refresh();
this.notify.success(
this.intl.t('notifications.create-success')
);
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
throw error;
}
await org.save();
await this.transitionTo('scopes.scope.projects', org);
this.refresh();
}
}
@@ -4,6 +4,7 @@ import { action } from '@ember/object';
import { all, hash } from 'rsvp';
import { task, timeout } from 'ember-concurrency';
import { A } from '@ember/array';
import { notifySuccess, notifyError } from '../../../../../decorators/notify';
import config from '../../../../../config/environment';
const POLL_TIMEOUT_SECONDS = config.sessionPollingTimeoutSeconds;
@@ -93,14 +94,10 @@ export default class ScopesScopeProjectsProjectSessionsRoute extends Route {
* @param {SessionModel}
*/
@action
@notifyError(({ message }) => message, { catch: true })
@notifySuccess('notifications.canceled-success')
async cancelSession(session) {
try {
await session.cancelSession();
this.notify.success(this.intl.t('notifications.canceled-success'));
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
}
await session.cancelSession();
}
}