diff --git a/ui/core/app/routes/account/change-password.js b/ui/core/app/routes/account/change-password.js index f17ec6e84..e4247da8e 100644 --- a/ui/core/app/routes/account/change-password.js +++ b/ui/core/app/routes/account/change-password.js @@ -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(() => {}); } /** diff --git a/ui/core/app/routes/scopes/scope/orgs.js b/ui/core/app/routes/scopes/scope/orgs.js index 626de80fa..5aad80343 100644 --- a/ui/core/app/routes/scopes/scope/orgs.js +++ b/ui/core/app/routes/scopes/scope/orgs.js @@ -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(); } } diff --git a/ui/core/app/routes/scopes/scope/projects/project/sessions.js b/ui/core/app/routes/scopes/scope/projects/project/sessions.js index b537560a7..3e01b9f44 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/sessions.js +++ b/ui/core/app/routes/scopes/scope/projects/project/sessions.js @@ -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(); } }