diff --git a/addons/core/README.md b/addons/core/README.md index 98d3efe2f..1b0dd33e9 100644 --- a/addons/core/README.md +++ b/addons/core/README.md @@ -35,6 +35,24 @@ To use internationalization features, install `ember-intl` into your project: To access translations within a template, see `ember-intl` docs. +## Notifications + +To use in-app notifications, first install `ember-notify` in your app. Then use +the notificaiton decorators to notify the user when a function or action +succeeds or fails. For example: + +```js +import { notifySuccess, notifyError } from 'core/decorators/notify'; + +export default class ExampleRoute extends Route { + @notifyError(({ message }) => message, { catch: true }) + @notifySuccess('notifications.delete-success') + async myAction() { + // do something + } +} +``` + ## Confirmations This addon exposes a service to request confirmations and the component diff --git a/ui/admin/app/decorators/notify.js b/addons/core/addon/decorators/notify.js similarity index 100% rename from ui/admin/app/decorators/notify.js rename to addons/core/addon/decorators/notify.js diff --git a/addons/core/app/decorators/notify.js b/addons/core/app/decorators/notify.js new file mode 100644 index 000000000..b878e37d9 --- /dev/null +++ b/addons/core/app/decorators/notify.js @@ -0,0 +1 @@ +export { default } from 'core/decorators/notify'; diff --git a/ui/admin/app/routes/account/change-password.js b/ui/admin/app/routes/account/change-password.js index e1c672d1b..bf097e196 100644 --- a/ui/admin/app/routes/account/change-password.js +++ b/ui/admin/app/routes/account/change-password.js @@ -1,7 +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'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; /** * The change password flow is associated only with password-type auth methods. diff --git a/ui/admin/app/routes/scopes/scope.js b/ui/admin/app/routes/scopes/scope.js index 3dc171cb0..705c8d168 100644 --- a/ui/admin/app/routes/scopes/scope.js +++ b/ui/admin/app/routes/scopes/scope.js @@ -4,7 +4,7 @@ import { A } from '@ember/array'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/auth-methods.js b/ui/admin/app/routes/scopes/scope/auth-methods.js index b0e9e32e3..81b4347da 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeAuthMethodsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts.js b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts.js index b598ca278..4e177662a 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/account/set-password.js b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/account/set-password.js index 55fe81986..72d2c0609 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/account/set-password.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/account/set-password.js @@ -5,7 +5,7 @@ import loading from 'ember-loading/decorator'; import { notifySuccess, notifyError, -} from '../../../../../../../decorators/notify'; +} from 'core/decorators/notify'; export default class ScopesScopeAuthMethodsAuthMethodAccountsAccountSettingsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/groups.js b/ui/admin/app/routes/scopes/scope/groups.js index 5e3628c15..7fa556182 100644 --- a/ui/admin/app/routes/scopes/scope/groups.js +++ b/ui/admin/app/routes/scopes/scope/groups.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeGroupsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/groups/group/add-members.js b/ui/admin/app/routes/scopes/scope/groups/group/add-members.js index d4f392684..a447908e7 100644 --- a/ui/admin/app/routes/scopes/scope/groups/group/add-members.js +++ b/ui/admin/app/routes/scopes/scope/groups/group/add-members.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { hash } from 'rsvp'; import loading from 'ember-loading/decorator'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeGroupsGroupAddMembersRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/groups/group/members.js b/ui/admin/app/routes/scopes/scope/groups/group/members.js index 97bd17a30..51ca9d353 100644 --- a/ui/admin/app/routes/scopes/scope/groups/group/members.js +++ b/ui/admin/app/routes/scopes/scope/groups/group/members.js @@ -4,7 +4,7 @@ import { inject as service } from '@ember/service'; import { hash, all } from 'rsvp'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeGroupsGroupMembersRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs.js b/ui/admin/app/routes/scopes/scope/host-catalogs.js index ce7cf6353..53fd92f7a 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeHostCatalogsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js index b2323fdaf..beb0aa93a 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeHostCatalogsHostCatalogHostSetsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts.js index 6c67301f2..b92c16814 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts.js @@ -6,7 +6,7 @@ import loading from 'ember-loading/decorator'; import { notifySuccess, notifyError, -} from '../../../../../../../decorators/notify'; +} from 'core/decorators/notify'; export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetAddHostsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host.js index 3447a260b..977fc45f4 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host.js @@ -5,7 +5,7 @@ import loading from 'ember-loading/decorator'; import { notifySuccess, notifyError, -} from '../../../../../../../decorators/notify'; +} from 'core/decorators/notify'; export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetCreateAndAddHostRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts.js index 8bc4a25fa..5c3fbae73 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts.js @@ -7,7 +7,7 @@ import { confirm } from 'core/decorators/confirm'; import { notifySuccess, notifyError, -} from '../../../../../../../decorators/notify'; +} from 'core/decorators/notify'; export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetHostsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js index ee964d5f6..a41073688 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeHostCatalogsHostCatalogHostsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/roles.js b/ui/admin/app/routes/scopes/scope/roles.js index fb93bcaaa..88d05373b 100644 --- a/ui/admin/app/routes/scopes/scope/roles.js +++ b/ui/admin/app/routes/scopes/scope/roles.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeRolesRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/roles/role/add-principals.js b/ui/admin/app/routes/scopes/scope/roles/role/add-principals.js index 861ceb1c5..1517470d3 100644 --- a/ui/admin/app/routes/scopes/scope/roles/role/add-principals.js +++ b/ui/admin/app/routes/scopes/scope/roles/role/add-principals.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { hash } from 'rsvp'; import loading from 'ember-loading/decorator'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeRolesRoleAddPrincipalsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/roles/role/grants.js b/ui/admin/app/routes/scopes/scope/roles/role/grants.js index 721e93446..0f051e359 100644 --- a/ui/admin/app/routes/scopes/scope/roles/role/grants.js +++ b/ui/admin/app/routes/scopes/scope/roles/role/grants.js @@ -2,7 +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'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeRolesRoleGrantsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/roles/role/principals.js b/ui/admin/app/routes/scopes/scope/roles/role/principals.js index 910bee7f4..b69b6e3ac 100644 --- a/ui/admin/app/routes/scopes/scope/roles/role/principals.js +++ b/ui/admin/app/routes/scopes/scope/roles/role/principals.js @@ -4,7 +4,7 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeRolesRolePrincipalsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/sessions.js b/ui/admin/app/routes/scopes/scope/sessions.js index a8ae5eb19..2bcb606c1 100644 --- a/ui/admin/app/routes/scopes/scope/sessions.js +++ b/ui/admin/app/routes/scopes/scope/sessions.js @@ -4,7 +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 { notifySuccess, notifyError } from 'core/decorators/notify'; import config from '../../../config/environment'; const POLL_TIMEOUT_SECONDS = config.sessionPollingTimeoutSeconds; diff --git a/ui/admin/app/routes/scopes/scope/targets.js b/ui/admin/app/routes/scopes/scope/targets.js index 232d8f92e..40cd811bb 100644 --- a/ui/admin/app/routes/scopes/scope/targets.js +++ b/ui/admin/app/routes/scopes/scope/targets.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeTargetsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/targets/target/add-host-sets.js b/ui/admin/app/routes/scopes/scope/targets/target/add-host-sets.js index e7851f15c..15cb88ddd 100644 --- a/ui/admin/app/routes/scopes/scope/targets/target/add-host-sets.js +++ b/ui/admin/app/routes/scopes/scope/targets/target/add-host-sets.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { all } from 'rsvp'; import loading from 'ember-loading/decorator'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeTargetsTargetAddHostSetsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/targets/target/host-sets.js b/ui/admin/app/routes/scopes/scope/targets/target/host-sets.js index 62468fca6..8bc1b1bd0 100644 --- a/ui/admin/app/routes/scopes/scope/targets/target/host-sets.js +++ b/ui/admin/app/routes/scopes/scope/targets/target/host-sets.js @@ -4,7 +4,7 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeTargetsTargetHostSetsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/users.js b/ui/admin/app/routes/scopes/scope/users.js index de60dd833..42f9c8832 100644 --- a/ui/admin/app/routes/scopes/scope/users.js +++ b/ui/admin/app/routes/scopes/scope/users.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; import { confirm } from 'core/decorators/confirm'; -import { notifySuccess, notifyError } from '../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeUsersRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/users/user/accounts.js b/ui/admin/app/routes/scopes/scope/users/user/accounts.js index 4408bdd5c..8f2e264ea 100644 --- a/ui/admin/app/routes/scopes/scope/users/user/accounts.js +++ b/ui/admin/app/routes/scopes/scope/users/user/accounts.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { hash, all } from 'rsvp'; import loading from 'ember-loading/decorator'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeUsersUserAccountsRoute extends Route { // =services diff --git a/ui/admin/app/routes/scopes/scope/users/user/add-accounts.js b/ui/admin/app/routes/scopes/scope/users/user/add-accounts.js index 3a1e22f4e..9fce2d85e 100644 --- a/ui/admin/app/routes/scopes/scope/users/user/add-accounts.js +++ b/ui/admin/app/routes/scopes/scope/users/user/add-accounts.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { all } from 'rsvp'; import loading from 'ember-loading/decorator'; -import { notifySuccess, notifyError } from '../../../../../decorators/notify'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeUsersUserAddAccountsRoute extends Route { // =services