From 3a847605ed58cd45a82d3662b8c46f2a3006a29f Mon Sep 17 00:00:00 2001 From: hashicc <191911133+hashicc@users.noreply.github.com> Date: Tue, 24 Feb 2026 13:48:34 -0500 Subject: [PATCH] Reapply `ember-can` upgrade (#3111) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 🤖 reapply previous ember-can upgrade from #3093 * chore: 🤖 add missing ember-inflector dependency * chore: 🤖 move @ember/string to be a dependency in desktop * chore: 🤖 re-run pnpm install to resolve lockfile dupe key error * chore: 🤖 remove unused abilities service injections Co-Authored-By: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com> --------- Co-authored-by: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com> --- addons/api/addon/abilities/role.js | 4 +- addons/api/package.json | 2 +- addons/api/tests/dummy/app/app.js | 3 +- .../api/tests/unit/abilities/account-test.js | 56 ++++++++-------- .../tests/unit/abilities/auth-method-test.js | 52 +++++++-------- .../unit/abilities/channel-recording-test.js | 14 ++-- addons/api/tests/unit/abilities/group-test.js | 4 +- .../api/tests/unit/abilities/host-set-test.js | 4 +- addons/api/tests/unit/abilities/model-test.js | 12 ++-- addons/api/tests/unit/abilities/role-test.js | 12 ++-- addons/api/tests/unit/abilities/scope-test.js | 12 ++-- .../unit/abilities/session-recording-test.js | 20 ++++-- .../api/tests/unit/abilities/session-test.js | 40 ++++++------ .../api/tests/unit/abilities/target-test.js | 37 ++++++----- addons/api/tests/unit/abilities/user-test.js | 44 ++++++------- .../api/tests/unit/abilities/worker-test.js | 14 ++-- pnpm-lock.yaml | 50 +++++++-------- ui/admin/app/app.js | 3 +- .../form/user/add-accounts/index.js | 4 +- .../controllers/scopes/scope/aliases/index.js | 8 +-- .../auth-method/accounts/index.js | 8 +-- .../auth-method/managed-groups/index.js | 8 +-- .../scopes/scope/auth-methods/index.js | 8 +-- .../credential-libraries/index.js | 8 +-- .../credential-store/credentials/index.js | 8 +-- .../scopes/scope/credential-stores/index.js | 8 +-- .../controllers/scopes/scope/groups/index.js | 8 +-- .../host-catalog/host-sets/index.js | 10 +-- .../host-catalogs/host-catalog/hosts/index.js | 8 +-- .../scopes/scope/host-catalogs/index.js | 8 +-- .../scopes/scope/policies/index.js | 8 +-- .../controllers/scopes/scope/roles/index.js | 8 +-- .../scopes/scope/storage-buckets/index.js | 6 +- .../controllers/scopes/scope/targets/index.js | 8 +-- .../scopes/scope/targets/target/index.js | 2 +- .../controllers/scopes/scope/users/index.js | 8 +-- .../controllers/scopes/scope/workers/index.js | 16 +++-- .../app/routes/scopes/scope/aliases/index.js | 4 +- .../app/routes/scopes/scope/aliases/new.js | 6 +- .../scopes/scope/auth-methods/auth-method.js | 1 - .../auth-methods/auth-method/accounts.js | 4 +- .../auth-method/accounts/account.js | 1 - .../auth-methods/auth-method/accounts/new.js | 6 +- .../auth-method/managed-groups.js | 4 +- .../auth-method/managed-groups/new.js | 4 +- .../routes/scopes/scope/auth-methods/index.js | 6 +- .../routes/scopes/scope/auth-methods/new.js | 4 +- .../credential-stores/credential-store.js | 1 - .../credential-store/credential-libraries.js | 4 +- .../credential-libraries/new.js | 4 +- .../credential-store/credentials.js | 4 +- .../credentials/credential.js | 1 - .../credential-store/credentials/new.js | 4 +- .../scopes/scope/credential-stores/index.js | 4 +- .../scopes/scope/credential-stores/new.js | 4 +- .../app/routes/scopes/scope/groups/group.js | 1 - .../app/routes/scopes/scope/groups/index.js | 4 +- .../app/routes/scopes/scope/groups/new.js | 8 ++- .../scope/host-catalogs/host-catalog.js | 1 - .../host-catalogs/host-catalog/host-sets.js | 4 +- .../host-catalog/host-sets/host-set.js | 1 - .../host-sets/host-set/create-and-add-host.js | 8 ++- .../host-sets/host-set/hosts/host.js | 1 - .../host-catalog/host-sets/new.js | 6 +- .../scope/host-catalogs/host-catalog/hosts.js | 4 +- .../host-catalogs/host-catalog/hosts/host.js | 1 - .../host-catalogs/host-catalog/hosts/new.js | 8 ++- .../scopes/scope/host-catalogs/index.js | 6 +- .../routes/scopes/scope/host-catalogs/new.js | 4 +- ui/admin/app/routes/scopes/scope/policies.js | 4 +- .../app/routes/scopes/scope/policies/new.js | 6 +- .../routes/scopes/scope/policies/policy.js | 1 - .../app/routes/scopes/scope/roles/index.js | 4 +- ui/admin/app/routes/scopes/scope/roles/new.js | 6 +- .../app/routes/scopes/scope/roles/role.js | 1 - .../app/routes/scopes/scope/scopes/index.js | 1 - .../scopes/scope/session-recordings/index.js | 4 +- .../session-recordings/session-recording.js | 1 - .../channels-by-connection/channel.js | 1 - .../channels-by-connection/channel/index.js | 6 +- .../app/routes/scopes/scope/sessions/index.js | 10 +-- .../routes/scopes/scope/storage-buckets.js | 4 +- .../scopes/scope/storage-buckets/new.js | 4 +- .../scope/storage-buckets/storage-bucket.js | 1 - .../app/routes/scopes/scope/targets/index.js | 6 +- .../app/routes/scopes/scope/targets/new.js | 6 +- .../app/routes/scopes/scope/targets/target.js | 1 - .../app/routes/scopes/scope/users/index.js | 4 +- ui/admin/app/routes/scopes/scope/users/new.js | 6 +- .../app/routes/scopes/scope/users/user.js | 1 - ui/admin/app/routes/scopes/scope/workers.js | 4 +- .../app/routes/scopes/scope/workers/new.js | 4 +- .../app/routes/scopes/scope/workers/worker.js | 1 - .../tests/unit/abilities/auth-method-test.js | 28 ++++---- .../unit/abilities/channel-recording-test.js | 14 ++-- .../tests/unit/abilities/collection-test.js | 2 +- .../unit/abilities/credential-library-test.js | 40 ++++++++---- ui/admin/tests/unit/abilities/role-test.js | 16 ++--- ui/admin/tests/unit/abilities/scope-test.js | 10 +-- .../unit/abilities/session-recording-test.js | 64 ++++++++++++------- .../unit/abilities/storage-bucket-test.js | 30 ++++----- ui/admin/tests/unit/abilities/user-test.js | 20 +++--- ui/desktop/app/app.js | 3 +- .../scopes/scope/projects/sessions/index.js | 4 +- .../scopes/scope/projects/targets/index.js | 4 +- .../scopes/scope/projects/targets/index.js | 4 +- ui/desktop/package.json | 3 +- .../tests/unit/abilities/collection-test.js | 2 +- 108 files changed, 533 insertions(+), 454 deletions(-) diff --git a/addons/api/addon/abilities/role.js b/addons/api/addon/abilities/role.js index 8f48868ff..18368fadc 100644 --- a/addons/api/addon/abilities/role.js +++ b/addons/api/addon/abilities/role.js @@ -16,7 +16,7 @@ class InvalidRolePrincipalTypeError extends Error { export default class RoleAbility extends ModelAbility { // =services - @service can; + @service abilities; // =permissions @@ -64,6 +64,6 @@ export default class RoleAbility extends ModelAbility { `Expected a role principal of type 'user', 'group', or 'managed-group'. Got '${type}'.`, ); } - return this.can.can(`read ${type}`, this.model); + return this.abilities.can(`read ${type}`, this.model); } } diff --git a/addons/api/package.json b/addons/api/package.json index c1049e481..de8e0cdf5 100644 --- a/addons/api/package.json +++ b/addons/api/package.json @@ -33,7 +33,7 @@ "broccoli-plugin": "^4.0.7", "broccoli-source": "^3.0.1", "ember-auto-import": "^2.10.0", - "ember-can": "^4.2.0", + "ember-can": "^8.0.0", "ember-cli-babel": "^8.2.0", "ember-cli-htmlbars": "^6.3.0", "ember-data": "~5.3.12", diff --git a/addons/api/tests/dummy/app/app.js b/addons/api/tests/dummy/app/app.js index 23c7e2b02..3db311993 100644 --- a/addons/api/tests/dummy/app/app.js +++ b/addons/api/tests/dummy/app/app.js @@ -7,11 +7,12 @@ import Application from '@ember/application'; import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from 'dummy/config/environment'; +import { extendResolver } from 'ember-can'; export default class App extends Application { modulePrefix = config.modulePrefix; podModulePrefix = config.podModulePrefix; - Resolver = Resolver; + Resolver = extendResolver(Resolver); } loadInitializers(App, config.modulePrefix); diff --git a/addons/api/tests/unit/abilities/account-test.js b/addons/api/tests/unit/abilities/account-test.js index dbc086bfd..6dbeb5532 100644 --- a/addons/api/tests/unit/abilities/account-test.js +++ b/addons/api/tests/unit/abilities/account-test.js @@ -14,11 +14,11 @@ import { module('Unit | Abilities | Account', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); }); @@ -26,9 +26,9 @@ module('Unit | Abilities | Account', function (hooks) { const account = store.createRecord('auth-method', { authorized_actions: ['set-password'], }); - assert.true(canService.can('setPassword account', account)); + assert.true(abilitiesService.can('setPassword account', account)); account.authorized_actions = []; - assert.false(canService.can('setPassword account', account)); + assert.false(abilitiesService.can('setPassword account', account)); }); test('can read known account types when authorized', function (assert) { @@ -36,13 +36,13 @@ module('Unit | Abilities | Account', function (hooks) { authorized_actions: ['read'], type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('read account', account)); + assert.true(abilitiesService.can('read account', account)); account.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('read account', account)); + assert.true(abilitiesService.can('read account', account)); account.type = TYPE_AUTH_METHOD_LDAP; - assert.true(canService.can('read account', account)); + assert.true(abilitiesService.can('read account', account)); account.type = 'no-such-type'; - assert.false(canService.can('read account', account)); + assert.false(abilitiesService.can('read account', account)); }); test('cannot read accounts when unauthorized', function (assert) { @@ -50,13 +50,13 @@ module('Unit | Abilities | Account', function (hooks) { authorized_actions: [], type: TYPE_AUTH_METHOD_OIDC, }); - assert.false(canService.can('read account', account)); + assert.false(abilitiesService.can('read account', account)); account.type = TYPE_AUTH_METHOD_PASSWORD; - assert.false(canService.can('read account', account)); + assert.false(abilitiesService.can('read account', account)); account.type = TYPE_AUTH_METHOD_LDAP; - assert.false(canService.can('read account', account)); + assert.false(abilitiesService.can('read account', account)); account.type = 'no-such-type'; - assert.false(canService.can('read account', account)); + assert.false(abilitiesService.can('read account', account)); }); test('can delete known account types when authorized', function (assert) { @@ -64,13 +64,13 @@ module('Unit | Abilities | Account', function (hooks) { authorized_actions: ['delete'], type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('delete account', account)); + assert.true(abilitiesService.can('delete account', account)); account.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('delete account', account)); + assert.true(abilitiesService.can('delete account', account)); account.type = TYPE_AUTH_METHOD_LDAP; - assert.true(canService.can('delete account', account)); + assert.true(abilitiesService.can('delete account', account)); account.type = 'no-such-type'; - assert.false(canService.can('delete account', account)); + assert.false(abilitiesService.can('delete account', account)); }); test('cannot delete accounts when unauthorized', function (assert) { @@ -78,13 +78,13 @@ module('Unit | Abilities | Account', function (hooks) { authorized_actions: ['delete'], type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('delete account', account)); + assert.true(abilitiesService.can('delete account', account)); account.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('delete account', account)); + assert.true(abilitiesService.can('delete account', account)); account.type = TYPE_AUTH_METHOD_LDAP; - assert.true(canService.can('delete account', account)); + assert.true(abilitiesService.can('delete account', account)); account.type = 'no-such-type'; - assert.false(canService.can('delete account', account)); + assert.false(abilitiesService.can('delete account', account)); }); test('can update known account types when authorized', function (assert) { @@ -92,13 +92,13 @@ module('Unit | Abilities | Account', function (hooks) { authorized_actions: ['update'], type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('update account', account)); + assert.true(abilitiesService.can('update account', account)); account.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('update account', account)); + assert.true(abilitiesService.can('update account', account)); account.type = TYPE_AUTH_METHOD_LDAP; - assert.true(canService.can('update account', account)); + assert.true(abilitiesService.can('update account', account)); account.type = 'no-such-type'; - assert.false(canService.can('update account', account)); + assert.false(abilitiesService.can('update account', account)); }); test('cannot update accounts when unauthorized', function (assert) { @@ -106,12 +106,12 @@ module('Unit | Abilities | Account', function (hooks) { authorized_actions: [], type: TYPE_AUTH_METHOD_OIDC, }); - assert.false(canService.can('update account', account)); + assert.false(abilitiesService.can('update account', account)); account.type = TYPE_AUTH_METHOD_PASSWORD; - assert.false(canService.can('update account', account)); + assert.false(abilitiesService.can('update account', account)); account.type = TYPE_AUTH_METHOD_LDAP; - assert.false(canService.can('update account', account)); + assert.false(abilitiesService.can('update account', account)); account.type = 'no-such-type'; - assert.false(canService.can('update account', account)); + assert.false(abilitiesService.can('update account', account)); }); }); diff --git a/addons/api/tests/unit/abilities/auth-method-test.js b/addons/api/tests/unit/abilities/auth-method-test.js index 0ad4b84ac..69a52e9c0 100644 --- a/addons/api/tests/unit/abilities/auth-method-test.js +++ b/addons/api/tests/unit/abilities/auth-method-test.js @@ -14,11 +14,11 @@ import { module('Unit | Abilities | Auth Method', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); }); @@ -27,13 +27,13 @@ module('Unit | Abilities | Auth Method', function (hooks) { authorized_actions: ['read'], type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('read auth-method', authMethod)); + assert.true(abilitiesService.can('read auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('read auth-method', authMethod)); + assert.true(abilitiesService.can('read auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_LDAP; - assert.true(canService.can('read auth-method', authMethod)); + assert.true(abilitiesService.can('read auth-method', authMethod)); authMethod.type = 'no-such-type'; - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); }); test('cannot read auth methods when unauthorized', function (assert) { @@ -41,13 +41,13 @@ module('Unit | Abilities | Auth Method', function (hooks) { authorized_actions: [], type: TYPE_AUTH_METHOD_OIDC, }); - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_PASSWORD; - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_LDAP; - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); authMethod.type = 'no-such-type'; - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); }); test('can delete known auth method types when authorized', function (assert) { @@ -55,13 +55,13 @@ module('Unit | Abilities | Auth Method', function (hooks) { authorized_actions: ['delete'], type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('delete auth-method', authMethod)); + assert.true(abilitiesService.can('delete auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('delete auth-method', authMethod)); + assert.true(abilitiesService.can('delete auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_LDAP; - assert.true(canService.can('delete auth-method', authMethod)); + assert.true(abilitiesService.can('delete auth-method', authMethod)); authMethod.type = 'no-such-type'; - assert.false(canService.can('delete auth-method', authMethod)); + assert.false(abilitiesService.can('delete auth-method', authMethod)); }); test('cannot delete auth methods when unauthorized', function (assert) { @@ -69,13 +69,13 @@ module('Unit | Abilities | Auth Method', function (hooks) { authorized_actions: ['delete'], type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('delete auth-method', authMethod)); + assert.true(abilitiesService.can('delete auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('delete auth-method', authMethod)); + assert.true(abilitiesService.can('delete auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_LDAP; - assert.true(canService.can('delete auth-method', authMethod)); + assert.true(abilitiesService.can('delete auth-method', authMethod)); authMethod.type = 'no-such-type'; - assert.false(canService.can('delete auth-method', authMethod)); + assert.false(abilitiesService.can('delete auth-method', authMethod)); }); test('can update known auth method types when authorized', function (assert) { @@ -83,13 +83,13 @@ module('Unit | Abilities | Auth Method', function (hooks) { authorized_actions: ['update'], type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('update auth-method', authMethod)); + assert.true(abilitiesService.can('update auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('update auth-method', authMethod)); + assert.true(abilitiesService.can('update auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_LDAP; - assert.true(canService.can('update auth-method', authMethod)); + assert.true(abilitiesService.can('update auth-method', authMethod)); authMethod.type = 'no-such-type'; - assert.false(canService.can('update auth-method', authMethod)); + assert.false(abilitiesService.can('update auth-method', authMethod)); }); test('cannot update auth methods when unauthorized', function (assert) { @@ -97,12 +97,12 @@ module('Unit | Abilities | Auth Method', function (hooks) { authorized_actions: [], type: TYPE_AUTH_METHOD_OIDC, }); - assert.false(canService.can('update auth-method', authMethod)); + assert.false(abilitiesService.can('update auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_PASSWORD; - assert.false(canService.can('update auth-method', authMethod)); + assert.false(abilitiesService.can('update auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_LDAP; - assert.false(canService.can('update auth-method', authMethod)); + assert.false(abilitiesService.can('update auth-method', authMethod)); authMethod.type = 'no-such-type'; - assert.false(canService.can('update auth-method', authMethod)); + assert.false(abilitiesService.can('update auth-method', authMethod)); }); }); diff --git a/addons/api/tests/unit/abilities/channel-recording-test.js b/addons/api/tests/unit/abilities/channel-recording-test.js index 6f33d8ba7..b7f357746 100644 --- a/addons/api/tests/unit/abilities/channel-recording-test.js +++ b/addons/api/tests/unit/abilities/channel-recording-test.js @@ -11,11 +11,11 @@ import { TYPE_SESSION_RECORDING_SSH } from 'api/models/session-recording'; module('Unit | Ability | channel-recording', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); }); @@ -41,7 +41,10 @@ module('Unit | Ability | channel-recording', function (hooks) { }); assert.true( - canService.can('getAsciicast channel-recording', channelRecordingModel), + abilitiesService.can( + 'getAsciicast channel-recording', + channelRecordingModel, + ), ); }); @@ -62,7 +65,10 @@ module('Unit | Ability | channel-recording', function (hooks) { }); assert.false( - canService.can('getAsciicast channel-recording', channelRecordingModel), + abilitiesService.can( + 'getAsciicast channel-recording', + channelRecordingModel, + ), ); }); }); diff --git a/addons/api/tests/unit/abilities/group-test.js b/addons/api/tests/unit/abilities/group-test.js index 1780ebb20..36fd16495 100644 --- a/addons/api/tests/unit/abilities/group-test.js +++ b/addons/api/tests/unit/abilities/group-test.js @@ -10,7 +10,7 @@ module('Unit | Abilities | Group', function (hooks) { setupTest(hooks); test('it reflects when a given group resource may add members based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['add-members'], }; @@ -20,7 +20,7 @@ module('Unit | Abilities | Group', function (hooks) { }); test('it reflects when a given group resource may remove members based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['remove-members'], }; diff --git a/addons/api/tests/unit/abilities/host-set-test.js b/addons/api/tests/unit/abilities/host-set-test.js index d444d953a..9c7a8500c 100644 --- a/addons/api/tests/unit/abilities/host-set-test.js +++ b/addons/api/tests/unit/abilities/host-set-test.js @@ -10,7 +10,7 @@ module('Unit | Abilities | Host Set', function (hooks) { setupTest(hooks); test('it reflects when a given host set resource may add hosts based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['add-hosts'], }; @@ -20,7 +20,7 @@ module('Unit | Abilities | Host Set', function (hooks) { }); test('it reflects when a given hostSet resource may remove hosts based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['remove-hosts'], }; diff --git a/addons/api/tests/unit/abilities/model-test.js b/addons/api/tests/unit/abilities/model-test.js index fd2ed8675..20e2a3017 100644 --- a/addons/api/tests/unit/abilities/model-test.js +++ b/addons/api/tests/unit/abilities/model-test.js @@ -10,7 +10,7 @@ module('Unit | Abilities | Model', function (hooks) { setupTest(hooks); test('it reflects when a given model may be read based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['read'], }; @@ -20,7 +20,7 @@ module('Unit | Abilities | Model', function (hooks) { }); test('it reflects when a given model may be updated based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['update'], }; @@ -30,7 +30,7 @@ module('Unit | Abilities | Model', function (hooks) { }); test('it reflects when a given model may be saved based on isNew and authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); let model = { isNew: false, authorized_actions: ['update'], @@ -58,7 +58,7 @@ module('Unit | Abilities | Model', function (hooks) { }); test('it reflects when a given model may be deleted based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['delete'], }; @@ -70,7 +70,7 @@ module('Unit | Abilities | Model', function (hooks) { // =collections test('it reflects when a resource may be listed based on authorized_collection_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_collection_actions: { foobars: ['list'], @@ -82,7 +82,7 @@ module('Unit | Abilities | Model', function (hooks) { }); test('it reflects when a resource may be created based on authorized_collection_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_collection_actions: { foobars: ['create'], diff --git a/addons/api/tests/unit/abilities/role-test.js b/addons/api/tests/unit/abilities/role-test.js index bdf4bbfd0..eb5d30888 100644 --- a/addons/api/tests/unit/abilities/role-test.js +++ b/addons/api/tests/unit/abilities/role-test.js @@ -10,7 +10,7 @@ module('Unit | Abilities | Role', function (hooks) { setupTest(hooks); test('it reflects when a given role may set grants based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['set-grants'], }; @@ -20,7 +20,7 @@ module('Unit | Abilities | Role', function (hooks) { }); test('it reflects when a given role may add principals based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['add-principals'], }; @@ -30,7 +30,7 @@ module('Unit | Abilities | Role', function (hooks) { }); test('it reflects when a given role may remove principals based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['remove-principals'], }; @@ -40,7 +40,7 @@ module('Unit | Abilities | Role', function (hooks) { }); test('it proxies role principal read ability to the appropriate ability type', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const user = { constructor: { modelName: 'user' }, authorized_actions: [], @@ -65,7 +65,7 @@ module('Unit | Abilities | Role', function (hooks) { }); test('it throws an error for unknown principal types on principal read check', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const account = { constructor: { modelName: 'account' }, authorized_actions: ['read'], @@ -77,7 +77,7 @@ module('Unit | Abilities | Role', function (hooks) { }); test('can set grant scopes based on authorized_actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_actions: ['set-grant-scopes'], }; diff --git a/addons/api/tests/unit/abilities/scope-test.js b/addons/api/tests/unit/abilities/scope-test.js index 8f4aabbca..f898815ff 100644 --- a/addons/api/tests/unit/abilities/scope-test.js +++ b/addons/api/tests/unit/abilities/scope-test.js @@ -9,10 +9,10 @@ import { setupTest } from 'ember-qunit'; module('Unit | Abilities | Scope', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); }); test('it exists', function (assert) { const ability = this.owner.lookup('ability:scope'); @@ -23,9 +23,9 @@ module('Unit | Abilities | Scope', function (hooks) { const model = { authorized_actions: ['attach-storage-policy'], }; - assert.true(canService.can('attachStoragePolicy scope', model)); + assert.true(abilitiesService.can('attachStoragePolicy scope', model)); model.authorized_actions = []; - assert.false(canService.can('attachStoragePolicy scope', model)); + assert.false(abilitiesService.can('attachStoragePolicy scope', model)); }); test('it reflects when a given scope may remove a policy in org scope', function (assert) { @@ -33,8 +33,8 @@ module('Unit | Abilities | Scope', function (hooks) { authorized_actions: ['detach-storage-policy'], }; - assert.true(canService.can('detachStoragePolicy scope', model)); + assert.true(abilitiesService.can('detachStoragePolicy scope', model)); model.authorized_actions = []; - assert.false(canService.can('detachStoragePolicy scope', model)); + assert.false(abilitiesService.can('detachStoragePolicy scope', model)); }); }); diff --git a/addons/api/tests/unit/abilities/session-recording-test.js b/addons/api/tests/unit/abilities/session-recording-test.js index cc763db64..32ad0706d 100644 --- a/addons/api/tests/unit/abilities/session-recording-test.js +++ b/addons/api/tests/unit/abilities/session-recording-test.js @@ -14,11 +14,11 @@ import { module('Unit | Ability | session-recording', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); }); @@ -42,13 +42,13 @@ module('Unit | Ability | session-recording', function (hooks) { ); assert.true( - canService.can( + abilitiesService.can( 'download session-recording', recordingWithAuthorizedAction, ), ); assert.false( - canService.can( + abilitiesService.can( 'download session-recording', recordingWithoutAuthorizedAction, ), @@ -70,10 +70,16 @@ module('Unit | Ability | session-recording', function (hooks) { state: STATE_SESSION_RECORDING_AVAILABLE, }); assert.false( - canService.can('delete session-recording', recordingNotinAvaialableState), + abilitiesService.can( + 'delete session-recording', + recordingNotinAvaialableState, + ), ); assert.true( - canService.can('delete session-recording', recordingInAvailableState), + abilitiesService.can( + 'delete session-recording', + recordingInAvailableState, + ), ); }); @@ -83,7 +89,7 @@ module('Unit | Ability | session-recording', function (hooks) { }); assert.true( - canService.can('reapplyStoragePolicy session-recording', recording), + abilitiesService.can('reapplyStoragePolicy session-recording', recording), ); }); }); diff --git a/addons/api/tests/unit/abilities/session-test.js b/addons/api/tests/unit/abilities/session-test.js index b546e6ed2..9f20bb197 100644 --- a/addons/api/tests/unit/abilities/session-test.js +++ b/addons/api/tests/unit/abilities/session-test.js @@ -15,11 +15,11 @@ import { module('Unit | Ability | session', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); }); @@ -34,7 +34,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_ACTIVE, }); - assert.true(canService.can('read session', session)); + assert.true(abilitiesService.can('read session', session)); }); test('can read a session that is pending', function (assert) { @@ -43,7 +43,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_PENDING, }); - assert.true(canService.can('read session', session)); + assert.true(abilitiesService.can('read session', session)); }); test('cannot read a session that is not authorized', function (assert) { @@ -64,10 +64,10 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_TERMINATED, }); - assert.false(canService.can('read session', activeSession)); - assert.false(canService.can('read session', pendingSession)); - assert.false(canService.can('read session', cancelingSession)); - assert.false(canService.can('read session', terminatedSession)); + assert.false(abilitiesService.can('read session', activeSession)); + assert.false(abilitiesService.can('read session', pendingSession)); + assert.false(abilitiesService.can('read session', cancelingSession)); + assert.false(abilitiesService.can('read session', terminatedSession)); }); test('cannot read a session that is canceling', function (assert) { @@ -76,7 +76,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_CANCELING, }); - assert.false(canService.can('read session', session)); + assert.false(abilitiesService.can('read session', session)); }); test('cannot read a session that is terminated', function (assert) { @@ -85,7 +85,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_TERMINATED, }); - assert.false(canService.can('read session', session)); + assert.false(abilitiesService.can('read session', session)); }); test('can read a session that has read:self', function (assert) { @@ -94,7 +94,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_ACTIVE, }); - assert.true(canService.can('read session', session)); + assert.true(abilitiesService.can('read session', session)); }); test('can cancel a session that is active', function (assert) { @@ -103,7 +103,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_ACTIVE, }); - assert.true(canService.can('cancel session', session)); + assert.true(abilitiesService.can('cancel session', session)); }); test('can cancel a session that has cancel:self', function (assert) { @@ -112,7 +112,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_ACTIVE, }); - assert.true(canService.can('cancel session', session)); + assert.true(abilitiesService.can('cancel session', session)); }); test('can cancel a session that is pending', function (assert) { @@ -121,7 +121,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_PENDING, }); - assert.true(canService.can('cancel session', session)); + assert.true(abilitiesService.can('cancel session', session)); }); test('cannot cancel a session that is canceling', function (assert) { @@ -130,7 +130,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_CANCELING, }); - assert.false(canService.can('cancel session', session)); + assert.false(abilitiesService.can('cancel session', session)); }); test('cannot cancel a session that is terminated', function (assert) { @@ -139,7 +139,7 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_TERMINATED, }); - assert.false(canService.can('cancel session', session)); + assert.false(abilitiesService.can('cancel session', session)); }); test('cannot cancel a session that is not authorized', function (assert) { @@ -160,9 +160,9 @@ module('Unit | Ability | session', function (hooks) { status: STATUS_SESSION_TERMINATED, }); - assert.false(canService.can('cancel session', activeSession)); - assert.false(canService.can('cancel session', pendingSession)); - assert.false(canService.can('cancel session', cancelingSession)); - assert.false(canService.can('cancel session', terminatedSession)); + assert.false(abilitiesService.can('cancel session', activeSession)); + assert.false(abilitiesService.can('cancel session', pendingSession)); + assert.false(abilitiesService.can('cancel session', cancelingSession)); + assert.false(abilitiesService.can('cancel session', terminatedSession)); }); }); diff --git a/addons/api/tests/unit/abilities/target-test.js b/addons/api/tests/unit/abilities/target-test.js index 42f3f64da..9d8909ca5 100644 --- a/addons/api/tests/unit/abilities/target-test.js +++ b/addons/api/tests/unit/abilities/target-test.js @@ -9,55 +9,59 @@ import { setupTest } from 'ember-qunit'; module('Unit | Abilities | Target', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); }); test('it reflects when a given target may connect based on authorized_actions', function (assert) { const model = { authorized_actions: ['authorize-session'], }; - assert.true(canService.can('connect target', model)); + assert.true(abilitiesService.can('connect target', model)); model.authorized_actions = []; - assert.false(canService.can('connect target', model)); + assert.false(abilitiesService.can('connect target', model)); }); test('it reflects when a given target may add host sources', function (assert) { const model = { authorized_actions: ['add-host-sources'], }; - assert.true(canService.can('addHostSources target', model)); + assert.true(abilitiesService.can('addHostSources target', model)); model.authorized_actions = []; - assert.false(canService.can('addHostSources target', model)); + assert.false(abilitiesService.can('addHostSources target', model)); }); test('it reflects when a given target may remove host sources', function (assert) { const model = { authorized_actions: ['remove-host-sources'], }; - assert.true(canService.can('removeHostSources target', model)); + assert.true(abilitiesService.can('removeHostSources target', model)); model.authorized_actions = []; - assert.false(canService.can('removeHostSources target', model)); + assert.false(abilitiesService.can('removeHostSources target', model)); }); test('it reflects when a given target may add brokered credential sources', function (assert) { const model = { authorized_actions: ['add-credential-sources'], }; - assert.true(canService.can('addBrokeredCredentialSources target', model)); + assert.true( + abilitiesService.can('addBrokeredCredentialSources target', model), + ); model.authorized_actions = []; - assert.false(canService.can('addBrokeredCredentialSources target', model)); + assert.false( + abilitiesService.can('addBrokeredCredentialSources target', model), + ); }); test('it reflects when a given target may remove credential sources', function (assert) { const model = { authorized_actions: ['remove-credential-sources'], }; - assert.true(canService.can('removeCredentialSources target', model)); + assert.true(abilitiesService.can('removeCredentialSources target', model)); model.authorized_actions = []; - assert.false(canService.can('removeCredentialSources target', model)); + assert.false(abilitiesService.can('removeCredentialSources target', model)); }); test('it reflects when a given ssh target may add injected application credential sources', function (assert) { @@ -74,16 +78,19 @@ module('Unit | Abilities | Target', function (hooks) { }; assert.true( - canService.can('addInjectedApplicationCredentialSources target', model), + abilitiesService.can( + 'addInjectedApplicationCredentialSources target', + model, + ), ); assert.false( - canService.can( + abilitiesService.can( 'addInjectedApplicationCredentialSources target', modelWithoutAuthorizedActions, ), ); assert.false( - canService.can( + abilitiesService.can( 'addInjectedApplicationCredentialSources target', modelWithoutSSHType, ), diff --git a/addons/api/tests/unit/abilities/user-test.js b/addons/api/tests/unit/abilities/user-test.js index ded506813..e6efd0e27 100644 --- a/addons/api/tests/unit/abilities/user-test.js +++ b/addons/api/tests/unit/abilities/user-test.js @@ -14,7 +14,7 @@ import { module('Unit | Abilities | User', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; const instances = { @@ -23,7 +23,7 @@ module('Unit | Abilities | User', function (hooks) { }; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); instances.user = store.createRecord('user'); instances.account = store.createRecord('account'); @@ -31,28 +31,28 @@ module('Unit | Abilities | User', function (hooks) { test('can add accounts to user when authorized and given a known account type', function (assert) { instances.user.authorized_actions = ['add-accounts']; - assert.true(canService.can('addAccounts user', instances.user)); + assert.true(abilitiesService.can('addAccounts user', instances.user)); instances.account.type = TYPE_AUTH_METHOD_OIDC; assert.true( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_PASSWORD; assert.true( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_LDAP; assert.true( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); instances.account.type = 'no-such-type'; assert.false( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); @@ -60,28 +60,28 @@ module('Unit | Abilities | User', function (hooks) { test('cannot add accounts to user when unauthorized', function (assert) { instances.user.authorized_actions = []; - assert.false(canService.can('addAccounts user', instances.user)); + assert.false(abilitiesService.can('addAccounts user', instances.user)); instances.account.type = TYPE_AUTH_METHOD_OIDC; assert.false( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_PASSWORD; assert.false( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_LDAP; assert.false( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); instances.account.type = 'no-such-type'; assert.false( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); @@ -89,28 +89,28 @@ module('Unit | Abilities | User', function (hooks) { test('can remove accounts from user when authorized and given a known account type', function (assert) { instances.user.authorized_actions = ['remove-accounts']; - assert.true(canService.can('removeAccounts user', instances.user)); + assert.true(abilitiesService.can('removeAccounts user', instances.user)); instances.account.type = TYPE_AUTH_METHOD_OIDC; assert.true( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_PASSWORD; assert.true( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_LDAP; assert.true( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); instances.account.type = 'no-such-type'; assert.false( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); @@ -118,28 +118,28 @@ module('Unit | Abilities | User', function (hooks) { test('cannot remove accounts from user when unauthorized', function (assert) { instances.user.authorized_actions = []; - assert.false(canService.can('removeAccounts user', instances.user)); + assert.false(abilitiesService.can('removeAccounts user', instances.user)); instances.account.type = TYPE_AUTH_METHOD_OIDC; assert.false( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_PASSWORD; assert.false( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_LDAP; assert.false( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); instances.account.type = 'no-such-type'; assert.false( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); diff --git a/addons/api/tests/unit/abilities/worker-test.js b/addons/api/tests/unit/abilities/worker-test.js index 601139cbf..8deaa3cf8 100644 --- a/addons/api/tests/unit/abilities/worker-test.js +++ b/addons/api/tests/unit/abilities/worker-test.js @@ -9,7 +9,7 @@ import { setupTest } from 'ember-qunit'; module('Unit | Abilities | Worker', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; const instances = { @@ -17,7 +17,7 @@ module('Unit | Abilities | Worker', function (hooks) { }; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); instances.worker = store.createRecord('worker'); }); @@ -27,7 +27,7 @@ module('Unit | Abilities | Worker', function (hooks) { authorized_collection_actions: { workers: ['create:worker-led'] }, }; assert.true( - canService.can('createWorkerLed worker', model, { + abilitiesService.can('createWorkerLed worker', model, { collection: 'workers', }), ); @@ -38,7 +38,7 @@ module('Unit | Abilities | Worker', function (hooks) { authorized_collection_actions: { workers: [] }, }; assert.true( - canService.cannot('createWorkerLed worker', model, { + abilitiesService.cannot('createWorkerLed worker', model, { collection: 'workers', }), ); @@ -46,11 +46,13 @@ module('Unit | Abilities | Worker', function (hooks) { test('can set worker tags', function (assert) { instances.worker.authorized_actions = ['set-worker-tags']; - assert.true(canService.can('setWorkerTags worker', instances.worker)); + assert.true(abilitiesService.can('setWorkerTags worker', instances.worker)); }); test('cannot set worker tags', function (assert) { instances.worker.authorized_actions = []; - assert.true(canService.cannot('setWorkerTags worker', instances.worker)); + assert.true( + abilitiesService.cannot('setWorkerTags worker', instances.worker), + ); }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3843c7939..a0022f15a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -77,8 +77,8 @@ importers: specifier: ^2.10.0 version: 2.10.0(@glint/template@1.5.2)(webpack@5.104.1(esbuild@0.25.9)) ember-can: - specifier: ^4.2.0 - version: 4.2.0(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))) + specifier: ^8.0.0 + version: 8.0.0(@babel/core@7.27.1)(@ember/string@4.0.1)(ember-inflector@6.0.0(@babel/core@7.27.1))(ember-resolver@12.0.1(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))))(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))) ember-cli-babel: specifier: ^8.2.0 version: 8.2.0(@babel/core@7.27.1) @@ -978,6 +978,9 @@ importers: '@babel/runtime': specifier: 7.27.6 version: 7.27.6 + '@ember/string': + specifier: ^4.0.0 + version: 4.0.1 '@xterm/addon-canvas': specifier: ^0.7.0 version: 0.7.0(@xterm/xterm@5.5.0) @@ -987,6 +990,9 @@ importers: '@xterm/xterm': specifier: ^5.5.0 version: 5.5.0 + ember-inflector: + specifier: ^6.0.0 + version: 6.0.0(@babel/core@7.27.1) ember-named-blocks-polyfill: specifier: ^0.2.5 version: 0.2.5 @@ -1012,9 +1018,6 @@ importers: '@ember/render-modifiers': specifier: ^2.0.4 version: 2.1.0(@babel/core@7.27.1)(@glint/template@1.5.2)(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))) - '@ember/string': - specifier: ^4.0.0 - version: 4.0.1 '@ember/test-helpers': specifier: ^5.2.1 version: 5.2.2(@babel/core@7.27.1)(@glint/template@1.5.2) @@ -4669,9 +4672,13 @@ packages: ember-browser-services@4.0.4: resolution: {integrity: sha512-ZjQPD7wlqMhHIq+uuesW+SWYCN+TsQtyY2Fy7QpluxEQff/j2JHiQAk3K0GUtEwef1gJ8/dRsBqSnaG2/Fxhmg==} - ember-can@4.2.0: - resolution: {integrity: sha512-hiaWZspmI4zWeWmmFWgyw1+yEStSo6edGRHHUXCUPR+vBoqlT/hEfmndlfDGso2GFP8IV59DORMVY0KReMcO+w==} - engines: {node: 12.* || 14.* || >= 16} + ember-can@8.0.0: + resolution: {integrity: sha512-JsS7tJ7sg52p8jPY2ND9uqHdEpAB+RpJLN8+lo7t5j65JgBX5gWXCCJ8seJ28AE278Im2ok0OoQBv5VXWqkvOw==} + peerDependencies: + '@ember/string': '>= 3.0.1' + ember-inflector: '>= 5.0.1' + ember-resolver: '>= 10.0.0' + ember-source: '>= 4.12.0' ember-cli-babel-plugin-helpers@1.1.1: resolution: {integrity: sha512-sKvOiPNHr5F/60NLd7SFzMpYPte/nnGkq/tMIfXejfKHIhaiIkYFqX8Z9UFTKWLLn+V7NOaby6niNPZUdvKCRw==} @@ -4912,12 +4919,6 @@ packages: resolution: {integrity: sha512-uNmv1cPG/4qsac8oIf5txJ2FZ8p88LEpG4P3dNcjsJS98Y8hd0GPMFwVqpnzI78Lz7VYRGQWY4jnE4qm5R3j4g==} engines: {node: 12.* || 14.* || >= 16} - ember-inflector@4.0.3: - resolution: {integrity: sha512-E+NnmzybMRWn1JyEfDxY7arjOTJLIcGjcXnUxizgjD4TlvO1s3O65blZt+Xq2C2AFSPeqHLC6PXd6XHYM8BxdQ==} - engines: {node: 14.* || 16.* || >= 18} - peerDependencies: - ember-source: ^3.16.0 || ^4.0.0 || ^5.0.0 - ember-inflector@6.0.0: resolution: {integrity: sha512-g6trqBhQHRwlq9bBmoyxhAl0tD0/CaTKK0xWPUgi3BfxFOgGG1bbiwAx+tjyiAkLzDqU+ihyjtT+sd41y6K1hA==} @@ -7736,7 +7737,6 @@ packages: engines: {node: '>=0.6.0', teleport: '>=0.2.0'} deprecated: |- You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other. - (For a CapTP with native promises, see @endo/eventual-send and @endo/captp) qs@6.14.1: @@ -13653,13 +13653,16 @@ snapshots: transitivePeerDependencies: - supports-color - ember-can@4.2.0(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))): + ember-can@8.0.0(@babel/core@7.27.1)(@ember/string@4.0.1)(ember-inflector@6.0.0(@babel/core@7.27.1))(ember-resolver@12.0.1(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))))(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))): dependencies: - ember-cli-babel: 7.26.11 - ember-cli-htmlbars: 6.3.0 - ember-inflector: 4.0.3(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))) + '@ember/string': 4.0.1 + '@embroider/addon-shim': 1.10.2 + decorator-transforms: 2.3.0(@babel/core@7.27.1) + ember-inflector: 6.0.0(@babel/core@7.27.1) + ember-resolver: 12.0.1(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))) + ember-source: 5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9)) transitivePeerDependencies: - - ember-source + - '@babel/core' - supports-color ember-cli-babel-plugin-helpers@1.1.1: {} @@ -14308,13 +14311,6 @@ snapshots: - '@glint/template' - supports-color - ember-inflector@4.0.3(ember-source@5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9))): - dependencies: - ember-cli-babel: 7.26.11 - ember-source: 5.12.0(@glimmer/component@2.0.0)(@glint/template@1.5.2)(rsvp@4.8.5)(webpack@5.104.1(esbuild@0.25.9)) - transitivePeerDependencies: - - supports-color - ember-inflector@6.0.0(@babel/core@7.27.1): dependencies: '@embroider/addon-shim': 1.10.0 diff --git a/ui/admin/app/app.js b/ui/admin/app/app.js index c2ffabc19..40bf072f0 100644 --- a/ui/admin/app/app.js +++ b/ui/admin/app/app.js @@ -14,11 +14,12 @@ import { getOwnConfig, isTesting, } from '@embroider/macros'; +import { extendResolver } from 'ember-can'; export default class App extends Application { modulePrefix = config.modulePrefix; podModulePrefix = config.podModulePrefix; - Resolver = Resolver; + Resolver = extendResolver(Resolver); } loadInitializers(App, config.modulePrefix); diff --git a/ui/admin/app/components/form/user/add-accounts/index.js b/ui/admin/app/components/form/user/add-accounts/index.js index 34bf4e183..ac3aecc64 100644 --- a/ui/admin/app/components/form/user/add-accounts/index.js +++ b/ui/admin/app/components/form/user/add-accounts/index.js @@ -10,7 +10,7 @@ import { service } from '@ember/service'; export default class FormUserAddAccountsComponent extends Component { // =properties - @service can; + @service abilities; /** * Array of selected account IDs. * @type {EmberArray} @@ -36,7 +36,7 @@ export default class FormUserAddAccountsComponent extends Component { const notAddedAccounts = this.args.accounts.filter( (account) => !alreadyAddedAccountIDs.includes(account.id) && - this.can.can('addAccount user', this.args.model, { account }), + this.abilities.can('addAccount user', this.args.model, { account }), ); return notAddedAccounts; } diff --git a/ui/admin/app/controllers/scopes/scope/aliases/index.js b/ui/admin/app/controllers/scopes/scope/aliases/index.js index e8550eebf..ce8739e34 100644 --- a/ui/admin/app/controllers/scopes/scope/aliases/index.js +++ b/ui/admin/app/controllers/scopes/scope/aliases/index.js @@ -14,7 +14,7 @@ import { confirm } from 'core/decorators/confirm'; export default class ScopesScopeAliasesIndexController extends Controller { // =services - @service can; + @service abilities; @service intl; @service router; @@ -41,10 +41,10 @@ export default class ScopesScopeAliasesIndexController extends Controller { * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.scope, { + const canList = this.abilities.can('list model', this.scope, { collection: 'aliases', }); - const canCreate = this.can.can('create model', this.scope, { + const canCreate = this.abilities.can('create model', this.scope, { collection: 'aliases', }); const resource = this.intl.t('resources.alias.title_plural'); @@ -84,7 +84,7 @@ export default class ScopesScopeAliasesIndexController extends Controller { ) async save(alias) { await alias.save(); - if (this.can.can('read model', alias)) { + if (this.abilities.can('read model', alias)) { await this.router.transitionTo('scopes.scope.aliases.alias', alias); } else { this.router.transitionTo('scopes.scope.aliases'); diff --git a/ui/admin/app/controllers/scopes/scope/auth-methods/auth-method/accounts/index.js b/ui/admin/app/controllers/scopes/scope/auth-methods/auth-method/accounts/index.js index 06fafdd9a..528ca82fc 100644 --- a/ui/admin/app/controllers/scopes/scope/auth-methods/auth-method/accounts/index.js +++ b/ui/admin/app/controllers/scopes/scope/auth-methods/auth-method/accounts/index.js @@ -15,7 +15,7 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsIndexController ext // =services - @service can; + @service abilities; @service intl; @service router; @@ -28,10 +28,10 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsIndexController ext * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.authMethod, { + const canList = this.abilities.can('list model', this.authMethod, { collection: 'accounts', }); - const canCreate = this.can.can('create model', this.authMethod, { + const canCreate = this.abilities.can('create model', this.authMethod, { collection: 'accounts', }); const resource = this.intl.t('resources.account.title_plural'); @@ -80,7 +80,7 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsIndexController ext adapterOptions.password = password; } await account.save({ adapterOptions }); - if (this.can.can('read model', account)) { + if (this.abilities.can('read model', account)) { await this.router.transitionTo( 'scopes.scope.auth-methods.auth-method.accounts.account', account, diff --git a/ui/admin/app/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index.js b/ui/admin/app/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index.js index 76a1c38b3..9e3006ec5 100644 --- a/ui/admin/app/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index.js +++ b/ui/admin/app/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index.js @@ -15,7 +15,7 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsIndexControlle // =services - @service can; + @service abilities; @service intl; @service router; @@ -28,10 +28,10 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsIndexControlle * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.authMethod, { + const canList = this.abilities.can('list model', this.authMethod, { collection: 'managed-groups', }); - const canCreate = this.can.can('create model', this.authMethod, { + const canCreate = this.abilities.can('create model', this.authMethod, { collection: 'managed-groups', }); const resource = this.intl.t('resources.managed-group.title_plural'); @@ -75,7 +75,7 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsIndexControlle ) async save(managedGroup) { await managedGroup.save(); - if (this.can.can('read model', managedGroup)) { + if (this.abilities.can('read model', managedGroup)) { await this.router.transitionTo( 'scopes.scope.auth-methods.auth-method.managed-groups.managed-group', managedGroup, diff --git a/ui/admin/app/controllers/scopes/scope/auth-methods/index.js b/ui/admin/app/controllers/scopes/scope/auth-methods/index.js index d988aeed1..1322d5bf7 100644 --- a/ui/admin/app/controllers/scopes/scope/auth-methods/index.js +++ b/ui/admin/app/controllers/scopes/scope/auth-methods/index.js @@ -16,7 +16,7 @@ export default class ScopesScopeAuthMethodsIndexController extends Controller { // =services @service router; - @service can; + @service abilities; @service intl; @service store; @@ -82,10 +82,10 @@ export default class ScopesScopeAuthMethodsIndexController extends Controller { * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.scopeModel, { + const canList = this.abilities.can('list model', this.scopeModel, { collection: 'auth-methods', }); - const canCreate = this.can.can('create model', this.scopeModel, { + const canCreate = this.abilities.can('create model', this.scopeModel, { collection: 'auth-methods', }); const resource = this.intl.t('resources.auth-method.title_plural'); @@ -148,7 +148,7 @@ export default class ScopesScopeAuthMethodsIndexController extends Controller { ) async save(authMethod) { await authMethod.save(); - if (this.can.can('read model', authMethod)) { + if (this.abilities.can('read model', authMethod)) { await this.router.transitionTo( 'scopes.scope.auth-methods.auth-method', authMethod, diff --git a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index.js b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index.js index 28ba215ce..3c53696fb 100644 --- a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index.js +++ b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index.js @@ -15,7 +15,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari // =services - @service can; + @service abilities; @service intl; @service router; @@ -28,10 +28,10 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.credentialStore, { + const canList = this.abilities.can('list model', this.credentialStore, { collection: 'credential-libraries', }); - const canCreate = this.can.can('create model', this.credentialStore, { + const canCreate = this.abilities.can('create model', this.credentialStore, { collection: 'credential-libraries', }); const resource = this.intl.t('resources.credential-library.title_plural'); @@ -75,7 +75,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari ) async save(credentialLibrary) { await credentialLibrary.save(); - if (this.can.can('read model', credentialLibrary)) { + if (this.abilities.can('read model', credentialLibrary)) { await this.router.transitionTo( 'scopes.scope.credential-stores.credential-store.credential-libraries.credential-library', credentialLibrary, diff --git a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credentials/index.js b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credentials/index.js index c5aae1cb4..24ab2b5f2 100644 --- a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credentials/index.js +++ b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credentials/index.js @@ -15,7 +15,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsIndexC // =services - @service can; + @service abilities; @service intl; @service router; @@ -28,10 +28,10 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsIndexC * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.credentialStore, { + const canList = this.abilities.can('list model', this.credentialStore, { collection: 'credentials', }); - const canCreate = this.can.can('create model', this.credentialStore, { + const canCreate = this.abilities.can('create model', this.credentialStore, { collection: 'credentials', }); const resource = this.intl.t('resources.credential.title_plural'); @@ -75,7 +75,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsIndexC ) async save(credential) { await credential.save(); - if (this.can.can('read credential', credential)) { + if (this.abilities.can('read credential', credential)) { await this.router.transitionTo( 'scopes.scope.credential-stores.credential-store.credentials.credential', credential, diff --git a/ui/admin/app/controllers/scopes/scope/credential-stores/index.js b/ui/admin/app/controllers/scopes/scope/credential-stores/index.js index 9b519c9bb..3c285b9cd 100644 --- a/ui/admin/app/controllers/scopes/scope/credential-stores/index.js +++ b/ui/admin/app/controllers/scopes/scope/credential-stores/index.js @@ -15,7 +15,7 @@ import { TYPES_CREDENTIAL_STORE } from 'api/models/credential-store'; export default class ScopesScopeCredentialStoresIndexController extends Controller { // =services - @service can; + @service abilities; @service router; @service intl; @@ -58,10 +58,10 @@ export default class ScopesScopeCredentialStoresIndexController extends Controll * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.scope, { + const canList = this.abilities.can('list model', this.scope, { collection: 'credential-stores', }); - const canCreate = this.can.can('create model', this.scope, { + const canCreate = this.abilities.can('create model', this.scope, { collection: 'credential-stores', }); const resource = this.intl.t('resources.credential-store.title_plural'); @@ -88,7 +88,7 @@ export default class ScopesScopeCredentialStoresIndexController extends Controll @notifySuccess('notifications.save-success') async save(credentialStore) { await credentialStore.save(); - if (this.can.can('read model', credentialStore)) { + if (this.abilities.can('read model', credentialStore)) { await this.router.transitionTo( 'scopes.scope.credential-stores.credential-store', credentialStore, diff --git a/ui/admin/app/controllers/scopes/scope/groups/index.js b/ui/admin/app/controllers/scopes/scope/groups/index.js index 28298bc84..05fcbbac8 100644 --- a/ui/admin/app/controllers/scopes/scope/groups/index.js +++ b/ui/admin/app/controllers/scopes/scope/groups/index.js @@ -14,7 +14,7 @@ import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeGroupsIndexController extends Controller { // =services - @service can; + @service abilities; @service intl; @service router; @@ -41,10 +41,10 @@ export default class ScopesScopeGroupsIndexController extends Controller { * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.scope, { + const canList = this.abilities.can('list model', this.scope, { collection: 'groups', }); - const canCreate = this.can.can('create model', this.scope, { + const canCreate = this.abilities.can('create model', this.scope, { collection: 'groups', }); const resource = this.intl.t('resources.group.title_plural'); @@ -84,7 +84,7 @@ export default class ScopesScopeGroupsIndexController extends Controller { ) async save(group) { await group.save(); - if (this.can.can('read model', group)) { + if (this.abilities.can('read model', group)) { await this.router.transitionTo('scopes.scope.groups.group', group); } else { this.router.transitionTo('scopes.scope.groups'); diff --git a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index.js b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index.js index b13c40cba..29564fc1f 100644 --- a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index.js +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index.js @@ -15,7 +15,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsIndexController e // =services - @service can; + @service abilities; @service intl; @service router; @service store; @@ -29,10 +29,10 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsIndexController e * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.hostCatalog, { + const canList = this.abilities.can('list model', this.hostCatalog, { collection: 'host-sets', }); - const canCreate = this.can.can('create model', this.hostCatalog, { + const canCreate = this.abilities.can('create model', this.hostCatalog, { collection: 'host-sets', }); const resource = this.intl.t('resources.host-set.title_plural'); @@ -79,7 +79,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsIndexController e // Fetch newest host set as updates to host set attributes cause an async db update which // updates the version again and can cause a version mismatch if the host set is updated // again and we haven't fetched the newest version. - if (this.can.can('read host-set', hostSet)) { + if (this.abilities.can('read host-set', hostSet)) { const newestHostSet = await this.store.findRecord( 'host-set', hostSet.id, @@ -93,7 +93,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsIndexController e await hostSet.save(); - if (this.can.can('read host-set', hostSet)) { + if (this.abilities.can('read host-set', hostSet)) { await this.router.transitionTo( 'scopes.scope.host-catalogs.host-catalog.host-sets.host-set', hostSet, diff --git a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index.js b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index.js index c97ae5a0d..b6b75104f 100644 --- a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index.js +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index.js @@ -15,7 +15,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsIndexController exte // =services - @service can; + @service abilities; @service intl; @service router; @@ -28,10 +28,10 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsIndexController exte * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.hostCatalog, { + const canList = this.abilities.can('list model', this.hostCatalog, { collection: 'hosts', }); - const canCreate = this.can.can('create model', this.hostCatalog, { + const canCreate = this.abilities.can('create model', this.hostCatalog, { collection: 'hosts', }); const resource = this.intl.t('resources.host.title_plural'); @@ -74,7 +74,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsIndexController exte ) async save(host) { await host.save(); - if (this.can.can('read model', host)) { + if (this.abilities.can('read model', host)) { await this.router.transitionTo( 'scopes.scope.host-catalogs.host-catalog.hosts.host', host, diff --git a/ui/admin/app/controllers/scopes/scope/host-catalogs/index.js b/ui/admin/app/controllers/scopes/scope/host-catalogs/index.js index 3b84222a1..f871e4ae3 100644 --- a/ui/admin/app/controllers/scopes/scope/host-catalogs/index.js +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/index.js @@ -15,7 +15,7 @@ import { TYPE_CREDENTIAL_STATIC } from 'api/models/host-catalog'; export default class ScopesScopeHostCatalogsIndexController extends Controller { // =services - @service can; + @service abilities; @service intl; @service router; @@ -42,10 +42,10 @@ export default class ScopesScopeHostCatalogsIndexController extends Controller { * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.scope, { + const canList = this.abilities.can('list model', this.scope, { collection: 'host-catalogs', }); - const canCreate = this.can.can('create model', this.scope, { + const canCreate = this.abilities.can('create model', this.scope, { collection: 'host-catalogs', }); const resource = this.intl.t('resources.host-catalog.title_plural'); @@ -101,7 +101,7 @@ export default class ScopesScopeHostCatalogsIndexController extends Controller { hostCatalog.credentialType = TYPE_CREDENTIAL_STATIC; } await hostCatalog.save(); - if (this.can.can('read host-catalog', hostCatalog)) { + if (this.abilities.can('read host-catalog', hostCatalog)) { await this.router.transitionTo( 'scopes.scope.host-catalogs.host-catalog', hostCatalog, diff --git a/ui/admin/app/controllers/scopes/scope/policies/index.js b/ui/admin/app/controllers/scopes/scope/policies/index.js index 3bb2e6406..5e146c702 100644 --- a/ui/admin/app/controllers/scopes/scope/policies/index.js +++ b/ui/admin/app/controllers/scopes/scope/policies/index.js @@ -13,7 +13,7 @@ import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopePoliciesIndexController extends Controller { // =services - @service can; + @service abilities; @service intl; @service router; @@ -26,10 +26,10 @@ export default class ScopesScopePoliciesIndexController extends Controller { * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.scope, { + const canList = this.abilities.can('list model', this.scope, { collection: 'policies', }); - const canCreate = this.can.can('create model', this.scope, { + const canCreate = this.abilities.can('create model', this.scope, { collection: 'policies', }); const resource = this.intl.t('resources.policy.title_plural'); @@ -67,7 +67,7 @@ export default class ScopesScopePoliciesIndexController extends Controller { @notifySuccess('notifications.save-success') async save(policy) { await policy.save(); - if (this.can.can('read model', policy)) { + if (this.abilities.can('read model', policy)) { await this.router.transitionTo('scopes.scope.policies.policy', policy); } else { await this.router.transitionTo('scopes.scope.policies'); diff --git a/ui/admin/app/controllers/scopes/scope/roles/index.js b/ui/admin/app/controllers/scopes/scope/roles/index.js index b088f3fe6..378931fab 100644 --- a/ui/admin/app/controllers/scopes/scope/roles/index.js +++ b/ui/admin/app/controllers/scopes/scope/roles/index.js @@ -15,7 +15,7 @@ import { GRANT_SCOPE_THIS } from 'api/models/role'; export default class ScopesScopeRolesIndexController extends Controller { // =services - @service can; + @service abilities; @service intl; @service router; @@ -44,10 +44,10 @@ export default class ScopesScopeRolesIndexController extends Controller { * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.scope, { + const canList = this.abilities.can('list model', this.scope, { collection: 'roles', }); - const canCreate = this.can.can('create model', this.scope, { + const canCreate = this.abilities.can('create model', this.scope, { collection: 'roles', }); const resource = this.intl.t('resources.role.title_plural'); @@ -98,7 +98,7 @@ export default class ScopesScopeRolesIndexController extends Controller { ) async save(role) { await role.save(); - if (this.can.can('read model', role)) { + if (this.abilities.can('read model', role)) { await this.router.transitionTo('scopes.scope.roles.role', role); } else { this.router.transitionTo('scopes.scope.roles'); diff --git a/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js b/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js index 66d491e28..b1265646c 100644 --- a/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js +++ b/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js @@ -14,7 +14,7 @@ import { TYPE_CREDENTIAL_STATIC } from 'api/models/storage-bucket'; export default class ScopesScopeStorageBucketsIndexController extends Controller { // =services - @service can; + @service abilities; @service intl; @service router; @@ -27,10 +27,10 @@ export default class ScopesScopeStorageBucketsIndexController extends Controller * @type {string} */ get messageDescription() { - const canList = this.can.can('list scope', this.scope, { + const canList = this.abilities.can('list scope', this.scope, { collection: 'storage-buckets', }); - const canCreate = this.can.can('create scope', this.scope, { + const canCreate = this.abilities.can('create scope', this.scope, { collection: 'storage-buckets', }); const resource = this.intl.t('resources.storage-bucket.title_plural'); diff --git a/ui/admin/app/controllers/scopes/scope/targets/index.js b/ui/admin/app/controllers/scopes/scope/targets/index.js index fbe0882cd..a1bfdc38d 100644 --- a/ui/admin/app/controllers/scopes/scope/targets/index.js +++ b/ui/admin/app/controllers/scopes/scope/targets/index.js @@ -20,7 +20,7 @@ export default class ScopesScopeTargetsIndexController extends Controller { // =services @service intl; - @service can; + @service abilities; @service router; @service confirm; @service features; @@ -80,10 +80,10 @@ export default class ScopesScopeTargetsIndexController extends Controller { * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.scope, { + const canList = this.abilities.can('list model', this.scope, { collection: 'targets', }); - const canCreate = this.can.can('create model', this.scope, { + const canCreate = this.abilities.can('create model', this.scope, { collection: 'targets', }); const resource = this.intl.t('resources.target.title_plural'); @@ -187,7 +187,7 @@ export default class ScopesScopeTargetsIndexController extends Controller { ) async save(target) { await target.save(); - if (this.can.can('read model', target)) { + if (this.abilities.can('read model', target)) { await this.router.transitionTo('scopes.scope.targets.target', target); } else { this.router.transitionTo('scopes.scope.targets'); diff --git a/ui/admin/app/controllers/scopes/scope/targets/target/index.js b/ui/admin/app/controllers/scopes/scope/targets/target/index.js index ca4c0f88a..e5916ac98 100644 --- a/ui/admin/app/controllers/scopes/scope/targets/target/index.js +++ b/ui/admin/app/controllers/scopes/scope/targets/target/index.js @@ -13,7 +13,7 @@ export default class ScopesScopeTargetsTargetIndexController extends Controller // =services - @service can; + @service abilities; @service router; // =attributes diff --git a/ui/admin/app/controllers/scopes/scope/users/index.js b/ui/admin/app/controllers/scopes/scope/users/index.js index d201c7c41..b5683b1a4 100644 --- a/ui/admin/app/controllers/scopes/scope/users/index.js +++ b/ui/admin/app/controllers/scopes/scope/users/index.js @@ -14,7 +14,7 @@ import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeUsersIndexController extends Controller { // =services - @service can; + @service abilities; @service intl; @service router; @tracked sortAttribute; @@ -41,10 +41,10 @@ export default class ScopesScopeUsersIndexController extends Controller { * @type {string} */ get messageDescription() { - const canList = this.can.can('list model', this.scope, { + const canList = this.abilities.can('list model', this.scope, { collection: 'users', }); - const canCreate = this.can.can('create model', this.scope, { + const canCreate = this.abilities.can('create model', this.scope, { collection: 'users', }); const resource = this.intl.t('resources.user.title_plural'); @@ -98,7 +98,7 @@ export default class ScopesScopeUsersIndexController extends Controller { ) async save(user) { await user.save(); - if (this.can.can('read model', user)) { + if (this.abilities.can('read model', user)) { await this.router.transitionTo('scopes.scope.users.user', user); } else { this.router.transitionTo('scopes.scope.users'); diff --git a/ui/admin/app/controllers/scopes/scope/workers/index.js b/ui/admin/app/controllers/scopes/scope/workers/index.js index c334c7629..f1e6f228b 100644 --- a/ui/admin/app/controllers/scopes/scope/workers/index.js +++ b/ui/admin/app/controllers/scopes/scope/workers/index.js @@ -14,7 +14,7 @@ import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeWorkersIndexController extends Controller { // =services - @service can; + @service abilities; @service intl; @service router; @@ -79,12 +79,16 @@ export default class ScopesScopeWorkersIndexController extends Controller { * @type {string} */ get messageDescription() { - const canList = this.can.can('list worker', this.scope, { - collection: 'workers', - }); - const canCreate = this.can.can('create worker led worker', this.scope, { + const canList = this.abilities.can('list worker', this.scope, { collection: 'workers', }); + const canCreate = this.abilities.can( + 'create worker led worker', + this.scope, + { + collection: 'workers', + }, + ); const resource = this.intl.t('titles.workers'); let description = 'descriptions.neither-list-nor-create'; @@ -159,7 +163,7 @@ export default class ScopesScopeWorkersIndexController extends Controller { ) async save(worker) { await worker.save(); - if (this.can.can('read model', worker)) { + if (this.abilities.can('read model', worker)) { await this.router.transitionTo('scopes.scope.workers.worker', worker); } else { this.router.transitionTo('scopes.scope.workers'); diff --git a/ui/admin/app/routes/scopes/scope/aliases/index.js b/ui/admin/app/routes/scopes/scope/aliases/index.js index aa04ce810..36b39dc57 100644 --- a/ui/admin/app/routes/scopes/scope/aliases/index.js +++ b/ui/admin/app/routes/scopes/scope/aliases/index.js @@ -11,7 +11,7 @@ export default class ScopesScopeAliasesIndexRoute extends Route { // =services @service store; - @service can; + @service abilities; // =attributes @@ -69,7 +69,7 @@ export default class ScopesScopeAliasesIndexRoute extends Route { let totalItems = 0; if ( - this.can.can('list model', scope, { + this.abilities.can('list model', scope, { collection: 'aliases', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/aliases/new.js b/ui/admin/app/routes/scopes/scope/aliases/new.js index 540bdd035..d0378d93b 100644 --- a/ui/admin/app/routes/scopes/scope/aliases/new.js +++ b/ui/admin/app/routes/scopes/scope/aliases/new.js @@ -11,7 +11,7 @@ export default class ScopesScopeAliasesNewRoute extends Route { // =services @service store; - @service can; + @service abilities; @service router; // =methods @@ -22,7 +22,9 @@ export default class ScopesScopeAliasesNewRoute extends Route { beforeModel() { const scopeModel = this.modelFor('scopes.scope'); if ( - this.can.cannot('create model', scopeModel, { collection: 'aliases' }) + this.abilities.cannot('create model', scopeModel, { + collection: 'aliases', + }) ) { this.router.replaceWith('scopes.scope.aliases'); } diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method.js b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method.js index 969883e69..0b3d3787e 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method.js @@ -11,7 +11,6 @@ export default class ScopesScopeAuthMethodsAuthMethodRoute extends Route { // =services @service store; - @service can; @service router; // =methods 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 abf73ce8d..cb637203c 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 @@ -10,7 +10,7 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route // =services @service store; - @service can; + @service abilities; // =methods @@ -24,7 +24,7 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route let accounts; if ( - this.can.can('list model', authMethod, { + this.abilities.can('list model', authMethod, { collection: 'accounts', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/account.js b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/account.js index 4f9fcfc0e..9532b0358 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/account.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/account.js @@ -10,7 +10,6 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsAccountRoute extend // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/new.js b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/new.js index 4b14d51b7..c68189300 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/new.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts/new.js @@ -10,7 +10,7 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsNewRoute extends Ro // =services @service store; - @service can; + @service abilities; @service router; // =methods @@ -21,7 +21,9 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsNewRoute extends Ro beforeModel() { const authMethod = this.modelFor('scopes.scope.auth-methods.auth-method'); if ( - this.can.cannot('create model', authMethod, { collection: 'accounts' }) + this.abilities.cannot('create model', authMethod, { + collection: 'accounts', + }) ) { this.router.replaceWith('scopes.scope.auth-methods.auth-method.accounts'); } diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups.js b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups.js index b931a2ae2..1237a1c0b 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups.js @@ -10,7 +10,7 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends // =services @service store; - @service can; + @service abilities; //=methods @@ -21,7 +21,7 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends async model() { const authMethod = this.modelFor('scopes.scope.auth-methods.auth-method'); const { id: auth_method_id } = authMethod; - const canListManagedGroups = this.can.can('list model', authMethod, { + const canListManagedGroups = this.abilities.can('list model', authMethod, { collection: 'managed-groups', }); let managedGroups; diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups/new.js b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups/new.js index 5b197d77a..d47e071e5 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups/new.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups/new.js @@ -10,7 +10,7 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsNewRoute exten // =services @service store; - @service can; + @service abilities; @service router; // =methods @@ -21,7 +21,7 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsNewRoute exten beforeModel() { const authMethod = this.modelFor('scopes.scope.auth-methods.auth-method'); if ( - this.can.cannot('create model', authMethod, { + this.abilities.cannot('create model', authMethod, { collection: 'managed-groups', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/index.js b/ui/admin/app/routes/scopes/scope/auth-methods/index.js index dc60036ce..bfacae48b 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/index.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/index.js @@ -11,7 +11,7 @@ export default class ScopesScopeAuthMethodsIndexRoute extends Route { // =services @service store; - @service can; + @service abilities; @service router; // =attributes @@ -101,7 +101,9 @@ export default class ScopesScopeAuthMethodsIndexRoute extends Route { let authMethods; let totalItems = 0; let doAuthMethodsExist = false; - if (this.can.can('list model', scope, { collection: 'auth-methods' })) { + if ( + this.abilities.can('list model', scope, { collection: 'auth-methods' }) + ) { // TODO: Remove storeToken option as this is a temporary fix for auth-methods. const options = { storeToken: false }; authMethods = await this.store.query( diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/new.js b/ui/admin/app/routes/scopes/scope/auth-methods/new.js index b20401320..0e2ef3929 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/new.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/new.js @@ -10,7 +10,7 @@ export default class ScopesScopeAuthMethodsNewRoute extends Route { // =services @service store; - @service can; + @service abilities; @service router; // =attributes @@ -29,7 +29,7 @@ export default class ScopesScopeAuthMethodsNewRoute extends Route { beforeModel() { const scopeModel = this.modelFor('scopes.scope'); if ( - this.can.cannot('create model', scopeModel, { + this.abilities.cannot('create model', scopeModel, { collection: 'auth-methods', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store.js index a8fbe7d23..754e428a1 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store.js @@ -11,7 +11,6 @@ export default class ScopesScopeCredentialStoresCredentialStoreRoute extends Rou // =services @service store; - @service can; @service router; /** diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js index fbb56d6b1..4c0057f22 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js @@ -10,7 +10,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari // =services @service store; - @service can; + @service abilities; // =methods @@ -24,7 +24,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari ); const { id: credential_store_id } = credentialStore; if ( - this.can.can('list model', credentialStore, { + this.abilities.can('list model', credentialStore, { collection: 'credential-libraries', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new.js index 93ae671e4..cfaa04ed2 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new.js @@ -16,7 +16,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari @service store; @service router; @service features; - @service can; + @service abilities; // =attributes @@ -36,7 +36,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari 'scopes.scope.credential-stores.credential-store', ); if ( - this.can.cannot('create model', credentialStore, { + this.abilities.cannot('create model', credentialStore, { collection: 'credential-libraries', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials.js index 5980b8e06..682e0c0de 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials.js @@ -10,7 +10,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsRoute // =services @service store; - @service can; + @service abilities; // =methods @@ -24,7 +24,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsRoute ); const { id: credential_store_id } = credentialStore; if ( - this.can.can('list model', credentialStore, { + this.abilities.can('list model', credentialStore, { collection: 'credentials', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/credential.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/credential.js index 5187d0aaf..9a7f838a4 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/credential.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/credential.js @@ -10,7 +10,6 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsCreden // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/new.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/new.js index 23ef4b8fd..66cc7f91e 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/new.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/new.js @@ -11,7 +11,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsNewRou @service store; @service router; - @service can; + @service abilities; // =attributes @@ -31,7 +31,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsNewRou 'scopes.scope.credential-stores.credential-store', ); if ( - this.can.cannot('create model', credentialStore, { + this.abilities.cannot('create model', credentialStore, { collection: 'credentials', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/index.js b/ui/admin/app/routes/scopes/scope/credential-stores/index.js index c76a2e120..8b223c818 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/index.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/index.js @@ -11,7 +11,7 @@ export default class ScopesScopeCredentialStoresIndexRoute extends Route { // =services @service store; - @service can; + @service abilities; // =attributes @@ -90,7 +90,7 @@ export default class ScopesScopeCredentialStoresIndexRoute extends Route { let totalItems = 0; let doCredentialStoresExist = false; if ( - this.can.can('list model', scope, { + this.abilities.can('list model', scope, { collection: 'credential-stores', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/new.js b/ui/admin/app/routes/scopes/scope/credential-stores/new.js index 9915bfd6a..6f33d0717 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/new.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/new.js @@ -12,7 +12,7 @@ export default class ScopesScopeCredentialStoresNewRoute extends Route { @service store; @service router; @service features; - @service can; + @service abilities; // =attributes @@ -30,7 +30,7 @@ export default class ScopesScopeCredentialStoresNewRoute extends Route { beforeModel() { const scopeModel = this.modelFor('scopes.scope'); if ( - this.can.cannot('create model', scopeModel, { + this.abilities.cannot('create model', scopeModel, { collection: 'credential-stores', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/groups/group.js b/ui/admin/app/routes/scopes/scope/groups/group.js index b3aa47f0d..508569760 100644 --- a/ui/admin/app/routes/scopes/scope/groups/group.js +++ b/ui/admin/app/routes/scopes/scope/groups/group.js @@ -10,7 +10,6 @@ export default class ScopesScopeGroupsGroupRoute extends Route { // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/app/routes/scopes/scope/groups/index.js b/ui/admin/app/routes/scopes/scope/groups/index.js index ce7dca37e..2370f475f 100644 --- a/ui/admin/app/routes/scopes/scope/groups/index.js +++ b/ui/admin/app/routes/scopes/scope/groups/index.js @@ -11,7 +11,7 @@ export default class ScopesScopeGroupsIndexRoute extends Route { // =services @service store; - @service can; + @service abilities; // =attributes @@ -77,7 +77,7 @@ export default class ScopesScopeGroupsIndexRoute extends Route { let groups = []; let totalItems = 0; let doGroupsExist = false; - if (this.can.can('list model', scope, { collection: 'groups' })) { + if (this.abilities.can('list model', scope, { collection: 'groups' })) { groups = await this.store.query('group', { scope_id, query: { filters, search, sort }, diff --git a/ui/admin/app/routes/scopes/scope/groups/new.js b/ui/admin/app/routes/scopes/scope/groups/new.js index 999c3aa7d..8c2cf0bfa 100644 --- a/ui/admin/app/routes/scopes/scope/groups/new.js +++ b/ui/admin/app/routes/scopes/scope/groups/new.js @@ -10,7 +10,7 @@ export default class ScopesScopeGroupsNewRoute extends Route { // =services @service store; - @service can; + @service abilities; @service router; // =methods @@ -20,7 +20,11 @@ export default class ScopesScopeGroupsNewRoute extends Route { */ beforeModel() { const scopeModel = this.modelFor('scopes.scope'); - if (this.can.cannot('create model', scopeModel, { collection: 'groups' })) { + if ( + this.abilities.cannot('create model', scopeModel, { + collection: 'groups', + }) + ) { this.router.replaceWith('scopes.scope.groups'); } } diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog.js index feeede34c..0baebaad3 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog.js @@ -11,7 +11,6 @@ export default class ScopesScopeHostCatalogsHostCatalogRoute extends Route { // =services @service store; - @service can; @service router; // =methods 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 442f9edf0..a8c536ad5 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 @@ -10,7 +10,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsRoute extends Rou // =services @service store; - @service can; + @service abilities; // =methods @@ -26,7 +26,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsRoute extends Rou let hostSets; if ( - this.can.can('list model', hostCatalog, { + this.abilities.can('list model', hostCatalog, { collection: 'host-sets', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set.js index 8160fd1d8..0017911b6 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set.js @@ -11,7 +11,6 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetRoute exte // =services @service store; - @service can; @service router; // =methods 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 c60dc8c98..e093f1911 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 @@ -11,7 +11,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetCreateAndA @service store; @service router; - @service can; + @service abilities; // =methods @@ -22,7 +22,11 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetCreateAndA const hostCatalog = this.modelFor( 'scopes.scope.host-catalogs.host-catalog', ); - if (this.can.cannot('create model', hostCatalog, { collection: 'hosts' })) { + if ( + this.abilities.cannot('create model', hostCatalog, { + collection: 'hosts', + }) + ) { this.router.replaceWith( 'scopes.scope.host-catalogs.host-catalog.host-sets.host-set.hosts', ); diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts/host.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts/host.js index 7aac13562..bc8a8a535 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts/host.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts/host.js @@ -10,7 +10,6 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetHostsHostR // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js index 6a3d993a7..82496f5c2 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js @@ -11,7 +11,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsNewRoute extends @service store; @service router; - @service can; + @service abilities; // =methods @@ -23,7 +23,9 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsNewRoute extends 'scopes.scope.host-catalogs.host-catalog', ); if ( - this.can.cannot('create model', hostCatalog, { collection: 'host-sets' }) + this.abilities.cannot('create model', hostCatalog, { + collection: 'host-sets', + }) ) { this.router.replaceWith( 'scopes.scope.host-catalogs.host-catalog.host-sets', 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 001c2fda8..59ffe8b6a 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 @@ -10,7 +10,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsRoute extends Route // =services @service store; - @service can; + @service abilities; // =methods @@ -26,7 +26,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsRoute extends Route let hosts; if ( - this.can.can('list model', hostCatalog, { + this.abilities.can('list model', hostCatalog, { collection: 'hosts', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts/host.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts/host.js index 3496f24de..5dbc63d72 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts/host.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts/host.js @@ -10,7 +10,6 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsHostRoute extends Ro // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts/new.js index ecf2b3580..64a8524e3 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts/new.js @@ -10,7 +10,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsNewRoute extends Rou // =services @service store; - @service can; + @service abilities; @service router; // =methods @@ -22,7 +22,11 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsNewRoute extends Rou const hostCatalog = this.modelFor( 'scopes.scope.host-catalogs.host-catalog', ); - if (this.can.cannot('create model', hostCatalog, { collection: 'hosts' })) { + if ( + this.abilities.cannot('create model', hostCatalog, { + collection: 'hosts', + }) + ) { this.router.replaceWith('scopes.scope.host-catalogs.host-catalog.hosts'); } } diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/index.js b/ui/admin/app/routes/scopes/scope/host-catalogs/index.js index cf250fe93..de564d37c 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/index.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/index.js @@ -11,7 +11,7 @@ export default class ScopesScopeHostCatalogsIndexRoute extends Route { // =services @service store; - @service can; + @service abilities; // =attributes @@ -82,7 +82,9 @@ export default class ScopesScopeHostCatalogsIndexRoute extends Route { let hostCatalogs; let totalItems = 0; let doHostCatalogsExist = false; - if (this.can.can('list model', scope, { collection: 'host-catalogs' })) { + if ( + this.abilities.can('list model', scope, { collection: 'host-catalogs' }) + ) { hostCatalogs = await this.store.query('host-catalog', { scope_id, query: { search, filters, sort }, diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index 38d9143b6..b3f92b311 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -11,7 +11,7 @@ export default class ScopesScopeHostCatalogsNewRoute extends Route { @service store; @service router; - @service can; + @service abilities; // =attributes @@ -29,7 +29,7 @@ export default class ScopesScopeHostCatalogsNewRoute extends Route { beforeModel() { const scopeModel = this.modelFor('scopes.scope'); if ( - this.can.cannot('create model', scopeModel, { + this.abilities.cannot('create model', scopeModel, { collection: 'host-catalogs', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/policies.js b/ui/admin/app/routes/scopes/scope/policies.js index e225d1262..481259fba 100644 --- a/ui/admin/app/routes/scopes/scope/policies.js +++ b/ui/admin/app/routes/scopes/scope/policies.js @@ -11,7 +11,7 @@ export default class ScopesScopePoliciesRoute extends Route { @service store; @service session; - @service can; + @service abilities; @service router; // =methods @@ -32,7 +32,7 @@ export default class ScopesScopePoliciesRoute extends Route { const { id: scope_id } = scope; if ( - this.can.can('list model', scope, { + this.abilities.can('list model', scope, { collection: 'policies', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/policies/new.js b/ui/admin/app/routes/scopes/scope/policies/new.js index 9b8371797..a22f27552 100644 --- a/ui/admin/app/routes/scopes/scope/policies/new.js +++ b/ui/admin/app/routes/scopes/scope/policies/new.js @@ -10,7 +10,7 @@ export default class ScopesScopePoliciesNewRoute extends Route { // =services @service store; - @service can; + @service abilities; @service router; // =methods @@ -21,7 +21,9 @@ export default class ScopesScopePoliciesNewRoute extends Route { beforeModel() { const scopeModel = this.modelFor('scopes.scope'); if ( - this.can.cannot('create model', scopeModel, { collection: 'policies' }) + this.abilities.cannot('create model', scopeModel, { + collection: 'policies', + }) ) { this.router.replaceWith('scopes.scope.policies'); } diff --git a/ui/admin/app/routes/scopes/scope/policies/policy.js b/ui/admin/app/routes/scopes/scope/policies/policy.js index fad7ad28d..cafcecbf4 100644 --- a/ui/admin/app/routes/scopes/scope/policies/policy.js +++ b/ui/admin/app/routes/scopes/scope/policies/policy.js @@ -8,7 +8,6 @@ import { service } from '@ember/service'; export default class ScopesScopePoliciesPolicyRoute extends Route { @service store; - @service can; // =methods diff --git a/ui/admin/app/routes/scopes/scope/roles/index.js b/ui/admin/app/routes/scopes/scope/roles/index.js index fde37a91d..d244953a9 100644 --- a/ui/admin/app/routes/scopes/scope/roles/index.js +++ b/ui/admin/app/routes/scopes/scope/roles/index.js @@ -33,7 +33,7 @@ export default class ScopesScopeRolesIndexRoute extends Route { // =services - @service can; + @service abilities; @service store; // =methods @@ -79,7 +79,7 @@ export default class ScopesScopeRolesIndexRoute extends Route { let roles; let totalItems = 0; let doRolesExist = false; - if (this.can.can('list model', scope, { collection: 'roles' })) { + if (this.abilities.can('list model', scope, { collection: 'roles' })) { roles = await this.store.query('role', { scope_id, query: { search, filters, sort }, diff --git a/ui/admin/app/routes/scopes/scope/roles/new.js b/ui/admin/app/routes/scopes/scope/roles/new.js index bed130278..ab75f51be 100644 --- a/ui/admin/app/routes/scopes/scope/roles/new.js +++ b/ui/admin/app/routes/scopes/scope/roles/new.js @@ -10,7 +10,7 @@ export default class ScopesScopeRolesNewRoute extends Route { // =services @service store; - @service can; + @service abilities; @service router; // =methods @@ -20,7 +20,9 @@ export default class ScopesScopeRolesNewRoute extends Route { */ beforeModel() { const scopeModel = this.modelFor('scopes.scope'); - if (this.can.cannot('create model', scopeModel, { collection: 'roles' })) { + if ( + this.abilities.cannot('create model', scopeModel, { collection: 'roles' }) + ) { this.router.replaceWith('scopes.scope.roles'); } } diff --git a/ui/admin/app/routes/scopes/scope/roles/role.js b/ui/admin/app/routes/scopes/scope/roles/role.js index 63c7d7355..f5b830a83 100644 --- a/ui/admin/app/routes/scopes/scope/roles/role.js +++ b/ui/admin/app/routes/scopes/scope/roles/role.js @@ -11,7 +11,6 @@ export default class ScopesScopeRolesRoleRoute extends Route { // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/app/routes/scopes/scope/scopes/index.js b/ui/admin/app/routes/scopes/scope/scopes/index.js index 97cec0c9f..559b602d9 100644 --- a/ui/admin/app/routes/scopes/scope/scopes/index.js +++ b/ui/admin/app/routes/scopes/scope/scopes/index.js @@ -33,7 +33,6 @@ export default class ScopesScopeScopesIndexRoute extends Route { // =services - @service can; @service store; // =methods diff --git a/ui/admin/app/routes/scopes/scope/session-recordings/index.js b/ui/admin/app/routes/scopes/scope/session-recordings/index.js index 82d543033..476ffad29 100644 --- a/ui/admin/app/routes/scopes/scope/session-recordings/index.js +++ b/ui/admin/app/routes/scopes/scope/session-recordings/index.js @@ -16,7 +16,7 @@ export default class ScopesScopeSessionRecordingsIndexRoute extends Route { // =services @service store; @service router; - @service can; + @service abilities; @service intl; // =attributes @@ -124,7 +124,7 @@ export default class ScopesScopeSessionRecordingsIndexRoute extends Route { : { attributes: [sortAttribute], direction: sortDirection }; if ( - this.can.can('list scope', scope, { + this.abilities.can('list scope', scope, { collection: 'session-recordings', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/session-recordings/session-recording.js b/ui/admin/app/routes/scopes/scope/session-recordings/session-recording.js index 7b6cb3178..9473e6e23 100644 --- a/ui/admin/app/routes/scopes/scope/session-recordings/session-recording.js +++ b/ui/admin/app/routes/scopes/scope/session-recordings/session-recording.js @@ -12,7 +12,6 @@ export default class ScopesScopeSessionRecordingsSessionRecordingRoute extends R @service store; @service session; @service router; - @service can; // =methods diff --git a/ui/admin/app/routes/scopes/scope/session-recordings/session-recording/channels-by-connection/channel.js b/ui/admin/app/routes/scopes/scope/session-recordings/session-recording/channels-by-connection/channel.js index 32f8d56ae..3c7f0ee6e 100644 --- a/ui/admin/app/routes/scopes/scope/session-recordings/session-recording/channels-by-connection/channel.js +++ b/ui/admin/app/routes/scopes/scope/session-recordings/session-recording/channels-by-connection/channel.js @@ -9,7 +9,6 @@ import { service } from '@ember/service'; export default class ScopesScopeSessionRecordingsSessionRecordingChannelsByConnectionChannelRoute extends Route { // =services @service store; - @service can; @service router; @service flashMessages; @service intl; diff --git a/ui/admin/app/routes/scopes/scope/session-recordings/session-recording/channels-by-connection/channel/index.js b/ui/admin/app/routes/scopes/scope/session-recordings/session-recording/channels-by-connection/channel/index.js index c81273973..b8e83c5be 100644 --- a/ui/admin/app/routes/scopes/scope/session-recordings/session-recording/channels-by-connection/channel/index.js +++ b/ui/admin/app/routes/scopes/scope/session-recordings/session-recording/channels-by-connection/channel/index.js @@ -8,7 +8,7 @@ import { service } from '@ember/service'; export default class ScopesScopeSessionRecordingsSessionRecordingChannelsByConnectionChannelIndexRoute extends Route { // =services - @service can; + @service abilities; @service flashMessages; @service intl; @@ -22,7 +22,9 @@ export default class ScopesScopeSessionRecordingsSessionRecordingChannelsByConne 'scopes.scope.session-recordings.session-recording.channels-by-connection.channel', ); - if (this.can.can('getAsciicast channel-recording', channelRecording)) { + if ( + this.abilities.can('getAsciicast channel-recording', channelRecording) + ) { try { asciicast = await channelRecording.getAsciicast(); } catch (e) { diff --git a/ui/admin/app/routes/scopes/scope/sessions/index.js b/ui/admin/app/routes/scopes/scope/sessions/index.js index 53a7f6754..f6c22eeb0 100644 --- a/ui/admin/app/routes/scopes/scope/sessions/index.js +++ b/ui/admin/app/routes/scopes/scope/sessions/index.js @@ -10,7 +10,7 @@ import { restartableTask, timeout } from 'ember-concurrency'; export default class ScopesScopeSessionsIndexRoute extends Route { // =services - @service can; + @service abilities; @service store; // =attributes @@ -134,7 +134,7 @@ export default class ScopesScopeSessionsIndexRoute extends Route { // Preload the associated targets and users into the cache let refreshUsersPromise, refreshTargetsPromise; - const canListTargets = this.can.can('list model', scope, { + const canListTargets = this.abilities.can('list model', scope, { collection: 'targets', }); if (canListTargets) { @@ -152,8 +152,10 @@ export default class ScopesScopeSessionsIndexRoute extends Route { const orgScope = await this.store.findRecord('scope', scope.scope.id); const globalScope = await this.store.findRecord('scope', 'global'); const canListUsers = - this.can.can('list model', globalScope, { collection: 'users' }) || - this.can.can('list model', orgScope, { collection: 'users' }); + this.abilities.can('list model', globalScope, { + collection: 'users', + }) || + this.abilities.can('list model', orgScope, { collection: 'users' }); if (canListUsers) { refreshUsersPromise = this.store.query( diff --git a/ui/admin/app/routes/scopes/scope/storage-buckets.js b/ui/admin/app/routes/scopes/scope/storage-buckets.js index e48ccec28..d0a6ab6af 100644 --- a/ui/admin/app/routes/scopes/scope/storage-buckets.js +++ b/ui/admin/app/routes/scopes/scope/storage-buckets.js @@ -11,7 +11,7 @@ export default class ScopesScopeStorageBucketsRoute extends Route { @service store; @service session; - @service can; + @service abilities; @service router; // =methods @@ -31,7 +31,7 @@ export default class ScopesScopeStorageBucketsRoute extends Route { const scope = this.modelFor('scopes.scope'); const { id: scope_id } = scope; if ( - this.can.can('list scope', scope, { + this.abilities.can('list scope', scope, { collection: 'storage-buckets', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/storage-buckets/new.js b/ui/admin/app/routes/scopes/scope/storage-buckets/new.js index 96fad2812..26bc24b88 100644 --- a/ui/admin/app/routes/scopes/scope/storage-buckets/new.js +++ b/ui/admin/app/routes/scopes/scope/storage-buckets/new.js @@ -14,7 +14,7 @@ export default class ScopesScopeStorageBucketsNewRoute extends Route { // =services @service store; - @service can; + @service abilities; @service router; // =attributes @@ -32,7 +32,7 @@ export default class ScopesScopeStorageBucketsNewRoute extends Route { beforeModel() { const scopeModel = this.modelFor('scopes.scope'); if ( - this.can.cannot('create scope', scopeModel, { + this.abilities.cannot('create scope', scopeModel, { collection: 'storage-buckets', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/storage-buckets/storage-bucket.js b/ui/admin/app/routes/scopes/scope/storage-buckets/storage-bucket.js index 3586d1529..55ede6955 100644 --- a/ui/admin/app/routes/scopes/scope/storage-buckets/storage-bucket.js +++ b/ui/admin/app/routes/scopes/scope/storage-buckets/storage-bucket.js @@ -10,7 +10,6 @@ export default class ScopesScopeStorageBucketsStorageBucketRoute extends Route { // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/app/routes/scopes/scope/targets/index.js b/ui/admin/app/routes/scopes/scope/targets/index.js index cda337f43..f803f95ac 100644 --- a/ui/admin/app/routes/scopes/scope/targets/index.js +++ b/ui/admin/app/routes/scopes/scope/targets/index.js @@ -17,7 +17,7 @@ import { TYPE_TARGET_SSH, TYPE_TARGET_TCP } from 'api/models/target'; export default class ScopesScopeTargetsIndexRoute extends Route { // =services - @service can; + @service abilities; @service store; @service session; @service intl; @@ -93,7 +93,7 @@ export default class ScopesScopeTargetsIndexRoute extends Route { filters.type.push({ equals: type }); }); - if (this.can.can('list model', scope, { collection: 'sessions' })) { + if (this.abilities.can('list model', scope, { collection: 'sessions' })) { await this.store.query( 'session', { @@ -133,7 +133,7 @@ export default class ScopesScopeTargetsIndexRoute extends Route { let targets; let totalItems = 0; let doTargetsExist = false; - if (this.can.can('list model', scope, { collection: 'targets' })) { + if (this.abilities.can('list model', scope, { collection: 'targets' })) { targets = await this.store.query('target', { scope_id, query: { search, filters, sort }, diff --git a/ui/admin/app/routes/scopes/scope/targets/new.js b/ui/admin/app/routes/scopes/scope/targets/new.js index 51e6752d7..3c20e7aed 100644 --- a/ui/admin/app/routes/scopes/scope/targets/new.js +++ b/ui/admin/app/routes/scopes/scope/targets/new.js @@ -13,7 +13,7 @@ export default class ScopesScopeTargetsNewRoute extends Route { @service store; @service router; @service features; - @service can; + @service abilities; // =attributes queryParams = { @@ -30,7 +30,9 @@ export default class ScopesScopeTargetsNewRoute extends Route { beforeModel() { const scopeModel = this.modelFor('scopes.scope'); if ( - this.can.cannot('create model', scopeModel, { collection: 'targets' }) + this.abilities.cannot('create model', scopeModel, { + collection: 'targets', + }) ) { this.router.replaceWith('scopes.scope.targets'); } diff --git a/ui/admin/app/routes/scopes/scope/targets/target.js b/ui/admin/app/routes/scopes/scope/targets/target.js index 8f1e59dd1..b5051ec0c 100644 --- a/ui/admin/app/routes/scopes/scope/targets/target.js +++ b/ui/admin/app/routes/scopes/scope/targets/target.js @@ -10,7 +10,6 @@ export default class ScopesScopeTargetsTargetRoute extends Route { // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/app/routes/scopes/scope/users/index.js b/ui/admin/app/routes/scopes/scope/users/index.js index c114829bf..f1da86236 100644 --- a/ui/admin/app/routes/scopes/scope/users/index.js +++ b/ui/admin/app/routes/scopes/scope/users/index.js @@ -34,7 +34,7 @@ export default class ScopesScopeUsersIndexRoute extends Route { // =services @service store; - @service can; + @service abilities; // =methods @@ -80,7 +80,7 @@ export default class ScopesScopeUsersIndexRoute extends Route { let users; let totalItems = 0; let doUsersExist = false; - if (this.can.can('list model', scope, { collection: 'users' })) { + if (this.abilities.can('list model', scope, { collection: 'users' })) { users = await this.store.query('user', { scope_id, query: { search, filters, sort }, diff --git a/ui/admin/app/routes/scopes/scope/users/new.js b/ui/admin/app/routes/scopes/scope/users/new.js index 99f123039..34c07a4e4 100644 --- a/ui/admin/app/routes/scopes/scope/users/new.js +++ b/ui/admin/app/routes/scopes/scope/users/new.js @@ -10,7 +10,7 @@ export default class ScopesScopeUsersNewRoute extends Route { // =services @service store; - @service can; + @service abilities; @service router; // =methods @@ -20,7 +20,9 @@ export default class ScopesScopeUsersNewRoute extends Route { */ beforeModel() { const scopeModel = this.modelFor('scopes.scope'); - if (this.can.cannot('create model', scopeModel, { collection: 'users' })) { + if ( + this.abilities.cannot('create model', scopeModel, { collection: 'users' }) + ) { this.router.replaceWith('scopes.scope.users'); } } diff --git a/ui/admin/app/routes/scopes/scope/users/user.js b/ui/admin/app/routes/scopes/scope/users/user.js index c28c39bce..f02661d23 100644 --- a/ui/admin/app/routes/scopes/scope/users/user.js +++ b/ui/admin/app/routes/scopes/scope/users/user.js @@ -10,7 +10,6 @@ export default class ScopesScopeUsersUserRoute extends Route { // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/app/routes/scopes/scope/workers.js b/ui/admin/app/routes/scopes/scope/workers.js index 0649b09b2..e4ba364e6 100644 --- a/ui/admin/app/routes/scopes/scope/workers.js +++ b/ui/admin/app/routes/scopes/scope/workers.js @@ -10,7 +10,7 @@ export default class ScopesScopeWorkersRoute extends Route { // =services @service store; - @service can; + @service abilities; @service session; @service router; @@ -30,7 +30,7 @@ export default class ScopesScopeWorkersRoute extends Route { model() { const scope = this.modelFor('scopes.scope'); const { id: scope_id } = scope; - if (this.can.can('list worker', scope, { collection: 'workers' })) { + if (this.abilities.can('list worker', scope, { collection: 'workers' })) { return this.store.query('worker', { scope_id }); } } diff --git a/ui/admin/app/routes/scopes/scope/workers/new.js b/ui/admin/app/routes/scopes/scope/workers/new.js index bdf21849a..30db0a944 100644 --- a/ui/admin/app/routes/scopes/scope/workers/new.js +++ b/ui/admin/app/routes/scopes/scope/workers/new.js @@ -10,7 +10,7 @@ export default class ScopesScopeWorkersNewRoute extends Route { // =services @service store; - @service can; + @service abilities; @service router; // =methods @@ -21,7 +21,7 @@ export default class ScopesScopeWorkersNewRoute extends Route { beforeModel() { const scopeModel = this.modelFor('scopes.scope'); if ( - this.can.cannot('create worker led worker', scopeModel, { + this.abilities.cannot('create worker led worker', scopeModel, { collection: 'workers', }) ) { diff --git a/ui/admin/app/routes/scopes/scope/workers/worker.js b/ui/admin/app/routes/scopes/scope/workers/worker.js index 086ac96c6..102e9bbcf 100644 --- a/ui/admin/app/routes/scopes/scope/workers/worker.js +++ b/ui/admin/app/routes/scopes/scope/workers/worker.js @@ -10,7 +10,6 @@ export default class ScopesScopeWorkersWorkerRoute extends Route { // =services @service store; - @service can; @service router; // =methods diff --git a/ui/admin/tests/unit/abilities/auth-method-test.js b/ui/admin/tests/unit/abilities/auth-method-test.js index a26f1435e..5b45b8c00 100644 --- a/ui/admin/tests/unit/abilities/auth-method-test.js +++ b/ui/admin/tests/unit/abilities/auth-method-test.js @@ -14,12 +14,12 @@ import { module('Unit | Abilities | auth-method', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; let features; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); features = this.owner.lookup('service:features'); }); @@ -30,9 +30,9 @@ module('Unit | Abilities | auth-method', function (hooks) { authorized_actions: ['read'], type: TYPE_AUTH_METHOD_LDAP, }); - assert.true(canService.can('read auth-method', authMethod)); + assert.true(abilitiesService.can('read auth-method', authMethod)); authMethod.authorized_actions = []; - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); }); test('cannot read LDAP auth-method when authorized and feature flag disabled', function (assert) { @@ -40,9 +40,9 @@ module('Unit | Abilities | auth-method', function (hooks) { authorized_actions: ['read'], type: TYPE_AUTH_METHOD_LDAP, }); - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); authMethod.authorized_actions = []; - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); }); test('can read non-LDAP auth-method when authorized', function (assert) { @@ -50,9 +50,9 @@ module('Unit | Abilities | auth-method', function (hooks) { authorized_actions: ['read'], type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('read auth-method', authMethod)); + assert.true(abilitiesService.can('read auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('read auth-method', authMethod)); + assert.true(abilitiesService.can('read auth-method', authMethod)); }); test('cannot read non-LDAP auth-method when unauthorized', function (assert) { @@ -60,16 +60,16 @@ module('Unit | Abilities | auth-method', function (hooks) { authorized_actions: [], type: TYPE_AUTH_METHOD_OIDC, }); - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_PASSWORD; - assert.false(canService.can('read auth-method', authMethod)); + assert.false(abilitiesService.can('read auth-method', authMethod)); }); test('cannot make LDAP auth-method primary when feature flag disabled', function (assert) { const authMethod = store.createRecord('auth-method', { type: TYPE_AUTH_METHOD_LDAP, }); - assert.false(canService.can('makePrimary auth-method', authMethod)); + assert.false(abilitiesService.can('makePrimary auth-method', authMethod)); }); test('can make LDAP auth-method primary when feature flag enabled', function (assert) { @@ -77,15 +77,15 @@ module('Unit | Abilities | auth-method', function (hooks) { const authMethod = store.createRecord('auth-method', { type: TYPE_AUTH_METHOD_LDAP, }); - assert.true(canService.can('makePrimary auth-method', authMethod)); + assert.true(abilitiesService.can('makePrimary auth-method', authMethod)); }); test('can make non-LDAP auth-method primary', function (assert) { const authMethod = store.createRecord('auth-method', { type: TYPE_AUTH_METHOD_OIDC, }); - assert.true(canService.can('makePrimary auth-method', authMethod)); + assert.true(abilitiesService.can('makePrimary auth-method', authMethod)); authMethod.type = TYPE_AUTH_METHOD_PASSWORD; - assert.true(canService.can('makePrimary auth-method', authMethod)); + assert.true(abilitiesService.can('makePrimary auth-method', authMethod)); }); }); diff --git a/ui/admin/tests/unit/abilities/channel-recording-test.js b/ui/admin/tests/unit/abilities/channel-recording-test.js index c84e6367d..683fdf2e4 100644 --- a/ui/admin/tests/unit/abilities/channel-recording-test.js +++ b/ui/admin/tests/unit/abilities/channel-recording-test.js @@ -11,7 +11,7 @@ import { MIME_TYPE_ASCIICAST } from 'api/models/channel-recording'; module('Unit | Abilities | channel-recording', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; let sessionRecording; let connectionRecording; @@ -19,7 +19,7 @@ module('Unit | Abilities | channel-recording', function (hooks) { let noneAsciicastChannel; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); sessionRecording = store.createRecord('session-recording', { @@ -39,18 +39,20 @@ module('Unit | Abilities | channel-recording', function (hooks) { }); test('returns true if session recording complete and channel mime type is asciicast', function (assert) { - assert.true(canService.can('play channel-recording', asciicastChannel)); + assert.true( + abilitiesService.can('play channel-recording', asciicastChannel), + ); assert.false( - canService.can('play channel-recording', noneAsciicastChannel), + abilitiesService.can('play channel-recording', noneAsciicastChannel), ); }); test('returns false if session recording complete and channel mime type is not asciicast', function (assert) { assert.true( - canService.can('viewOnly channel-recording', noneAsciicastChannel), + abilitiesService.can('viewOnly channel-recording', noneAsciicastChannel), ); assert.false( - canService.can('viewOnly channel-recording', asciicastChannel), + abilitiesService.can('viewOnly channel-recording', asciicastChannel), ); }); }); diff --git a/ui/admin/tests/unit/abilities/collection-test.js b/ui/admin/tests/unit/abilities/collection-test.js index 7f2818bb4..4a3050a6f 100644 --- a/ui/admin/tests/unit/abilities/collection-test.js +++ b/ui/admin/tests/unit/abilities/collection-test.js @@ -10,7 +10,7 @@ module('Unit | Abilities | model', function (hooks) { setupTest(hooks); test('it reflects when a resource may be navigated to based on list and create actions', function (assert) { - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_collection_actions: { foobars: [] }, }; diff --git a/ui/admin/tests/unit/abilities/credential-library-test.js b/ui/admin/tests/unit/abilities/credential-library-test.js index b26141c40..ac057e3f1 100644 --- a/ui/admin/tests/unit/abilities/credential-library-test.js +++ b/ui/admin/tests/unit/abilities/credential-library-test.js @@ -21,32 +21,40 @@ module('Unit | Abilities | credential-library', function (hooks) { test('can read credential library type when authorized and feature is enabled', function (assert) { features.enable('ssh-target'); - const canService = this.owner.lookup('service:can'); + const abilitiesService = this.owner.lookup('service:abilities'); const store = this.owner.lookup('service:store'); const credentialLibrary = store.createRecord('credential-library', { authorized_actions: ['read'], type: TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE, }); - assert.true(canService.can('read credential-library', credentialLibrary)); + assert.true( + abilitiesService.can('read credential-library', credentialLibrary), + ); credentialLibrary.type = TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC; - assert.true(canService.can('read credential-library', credentialLibrary)); + assert.true( + abilitiesService.can('read credential-library', credentialLibrary), + ); }); test('cannot read credential library type when unauthorized and feature is enabled', function (assert) { features.enable('ssh-target'); - const canService = this.owner.lookup('service:can'); + const abilitiesService = this.owner.lookup('service:abilities'); const store = this.owner.lookup('service:store'); const credentialLibrary = store.createRecord('credential-library', { authorized_actions: [], type: TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE, }); - assert.false(canService.can('read credential-library', credentialLibrary)); + assert.false( + abilitiesService.can('read credential-library', credentialLibrary), + ); credentialLibrary.type = TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC; - assert.false(canService.can('read credential-library', credentialLibrary)); + assert.false( + abilitiesService.can('read credential-library', credentialLibrary), + ); }); test('cannot read credential library type when unauthorized and feature is disabled', function (assert) { - const canService = this.owner.lookup('service:can'); + const abilitiesService = this.owner.lookup('service:abilities'); const store = this.owner.lookup('service:store'); const featuresService = this.owner.lookup('service:features'); const credentialLibrary = store.createRecord('credential-library', { @@ -54,13 +62,17 @@ module('Unit | Abilities | credential-library', function (hooks) { type: TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE, }); assert.false(featuresService.isEnabled('ssh-target')); - assert.false(canService.can('read credential-library', credentialLibrary)); + assert.false( + abilitiesService.can('read credential-library', credentialLibrary), + ); credentialLibrary.type = TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC; - assert.false(canService.can('read credential-library', credentialLibrary)); + assert.false( + abilitiesService.can('read credential-library', credentialLibrary), + ); }); test('can read vault-generic but not vault-ssh-certificate when authorized and feature is disabled', function (assert) { - const canService = this.owner.lookup('service:can'); + const abilitiesService = this.owner.lookup('service:abilities'); const store = this.owner.lookup('service:store'); const featuresService = this.owner.lookup('service:features'); const credentialLibrary = store.createRecord('credential-library', { @@ -68,8 +80,12 @@ module('Unit | Abilities | credential-library', function (hooks) { type: TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE, }); assert.false(featuresService.isEnabled('ssh-target')); - assert.false(canService.can('read credential-library', credentialLibrary)); + assert.false( + abilitiesService.can('read credential-library', credentialLibrary), + ); credentialLibrary.type = TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC; - assert.true(canService.can('read credential-library', credentialLibrary)); + assert.true( + abilitiesService.can('read credential-library', credentialLibrary), + ); }); }); diff --git a/ui/admin/tests/unit/abilities/role-test.js b/ui/admin/tests/unit/abilities/role-test.js index e714897cd..f0a0105dc 100644 --- a/ui/admin/tests/unit/abilities/role-test.js +++ b/ui/admin/tests/unit/abilities/role-test.js @@ -9,11 +9,11 @@ import { setupTest } from 'ember-qunit'; module('Unit | Abilities | role', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); }); @@ -23,9 +23,9 @@ module('Unit | Abilities | role', function (hooks) { authorized_actions: ['set-grant-scopes'], scope: globalScope, }); - assert.true(canService.can('setGrantScopes role', role)); + assert.true(abilitiesService.can('setGrantScopes role', role)); role.authorized_actions = []; - assert.false(canService.can('setGrantScopes role', role)); + assert.false(abilitiesService.can('setGrantScopes role', role)); }); test('can setGrantScopes on role when authorized and scope is org type', function (assert) { @@ -38,9 +38,9 @@ module('Unit | Abilities | role', function (hooks) { authorized_actions: ['set-grant-scopes'], scope: orgScope, }); - assert.true(canService.can('setGrantScopes role', role)); + assert.true(abilitiesService.can('setGrantScopes role', role)); role.authorized_actions = []; - assert.false(canService.can('setGrantScopes role', role)); + assert.false(abilitiesService.can('setGrantScopes role', role)); }); test('cannot setGrantScopes on role when authorized and scope is project type', function (assert) { @@ -57,8 +57,8 @@ module('Unit | Abilities | role', function (hooks) { authorized_actions: ['set-grant-scopes'], scope: projectScope, }); - assert.false(canService.can('setGrantScopes role', role)); + assert.false(abilitiesService.can('setGrantScopes role', role)); role.authorized_actions = []; - assert.false(canService.can('setGrantScopes role', role)); + assert.false(abilitiesService.can('setGrantScopes role', role)); }); }); diff --git a/ui/admin/tests/unit/abilities/scope-test.js b/ui/admin/tests/unit/abilities/scope-test.js index 96a0ab5fe..9e50b378c 100644 --- a/ui/admin/tests/unit/abilities/scope-test.js +++ b/ui/admin/tests/unit/abilities/scope-test.js @@ -10,12 +10,12 @@ module('Unit | Abilities | Scope', function (hooks) { setupTest(hooks); let features; - let canService; + let abilitiesService; let store; hooks.beforeEach(function () { store = this.owner.lookup('service:store'); - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); features = this.owner.lookup('service:features'); }); @@ -25,7 +25,7 @@ module('Unit | Abilities | Scope', function (hooks) { const scopeModel = store.createRecord('scope', { authorized_actions: ['attach-storage-policy'], }); - assert.true(canService.can('attachStoragePolicy scope', scopeModel)); + assert.true(abilitiesService.can('attachStoragePolicy scope', scopeModel)); }); test('cannot attach storage policy when unauthorized', function (assert) { @@ -35,7 +35,7 @@ module('Unit | Abilities | Scope', function (hooks) { authorized_actions: [], }); - assert.false(canService.can('attachStoragePolicy scope', scopeModel)); + assert.false(abilitiesService.can('attachStoragePolicy scope', scopeModel)); }); test('can detach storage policy when authorized', function (assert) { @@ -44,6 +44,6 @@ module('Unit | Abilities | Scope', function (hooks) { const scopeModel = store.createRecord('scope', { authorized_actions: ['detach-storage-policy'], }); - assert.true(canService.can('detachStoragePolicy scope', scopeModel)); + assert.true(abilitiesService.can('detachStoragePolicy scope', scopeModel)); }); }); diff --git a/ui/admin/tests/unit/abilities/session-recording-test.js b/ui/admin/tests/unit/abilities/session-recording-test.js index 55b461825..cfe97340c 100644 --- a/ui/admin/tests/unit/abilities/session-recording-test.js +++ b/ui/admin/tests/unit/abilities/session-recording-test.js @@ -15,12 +15,12 @@ module('Unit | Abilities | session-recording', function (hooks) { setupTest(hooks); let features; - let canService; + let abilitiesService; let store; hooks.beforeEach(function () { features = this.owner.lookup('service:features'); - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); }); @@ -43,10 +43,13 @@ module('Unit | Abilities | session-recording', function (hooks) { ); assert.true( - canService.can('read session-recording', recordingWithAuthorizedAction), + abilitiesService.can( + 'read session-recording', + recordingWithAuthorizedAction, + ), ); assert.false( - canService.can( + abilitiesService.can( 'read session-recording', recordingWithoutAuthorizedAction, ), @@ -70,10 +73,13 @@ module('Unit | Abilities | session-recording', function (hooks) { ); assert.false( - canService.can('read session-recording', recordingWithAuthorizedAction), + abilitiesService.can( + 'read session-recording', + recordingWithAuthorizedAction, + ), ); assert.false( - canService.can( + abilitiesService.can( 'read session-recording', recordingWithoutAuthorizedAction, ), @@ -95,12 +101,12 @@ module('Unit | Abilities | session-recording', function (hooks) { }); assert.true( - canService.can('list scope', scopeModelWithAuthorizedAction, { + abilitiesService.can('list scope', scopeModelWithAuthorizedAction, { collection: 'session-recordings', }), ); assert.false( - canService.can('list scope', scopeModelWithoutAuthorizedAction, { + abilitiesService.can('list scope', scopeModelWithoutAuthorizedAction, { collection: 'session-recordings', }), ); @@ -121,12 +127,12 @@ module('Unit | Abilities | session-recording', function (hooks) { }); assert.true( - canService.can('list scope', scopeModelWithAuthorizedAction, { + abilitiesService.can('list scope', scopeModelWithAuthorizedAction, { collection: 'session-recordings', }), ); assert.false( - canService.can('list scope', scopeModelWithoutAuthorizedAction, { + abilitiesService.can('list scope', scopeModelWithoutAuthorizedAction, { collection: 'session-recordings', }), ); @@ -147,14 +153,18 @@ module('Unit | Abilities | session-recording', function (hooks) { }); assert.true( - canService.can('navigate scope', scopeModelWithAuthorizedAction, { + abilitiesService.can('navigate scope', scopeModelWithAuthorizedAction, { collection: 'session-recordings', }), ); assert.false( - canService.can('navigate scope', scopeModelWithoutAuthorizedAction, { - collection: 'session-recordings', - }), + abilitiesService.can( + 'navigate scope', + scopeModelWithoutAuthorizedAction, + { + collection: 'session-recordings', + }, + ), ); }); @@ -171,14 +181,18 @@ module('Unit | Abilities | session-recording', function (hooks) { }); assert.false( - canService.can('navigate scope', scopeModelWithAuthorizedAction, { + abilitiesService.can('navigate scope', scopeModelWithAuthorizedAction, { collection: 'session-recordings', }), ); assert.false( - canService.can('navigate scope', scopeModelWithoutAuthorizedAction, { - collection: 'session-recordings', - }), + abilitiesService.can( + 'navigate scope', + scopeModelWithoutAuthorizedAction, + { + collection: 'session-recordings', + }, + ), ); }); @@ -204,10 +218,13 @@ module('Unit | Abilities | session-recording', function (hooks) { ); assert.true( - canService.can('delete session-recording', recordingWithAuthorizedAction), + abilitiesService.can( + 'delete session-recording', + recordingWithAuthorizedAction, + ), ); assert.false( - canService.can( + abilitiesService.can( 'delete session-recording', recordingWithoutAuthorizedAction, ), @@ -236,10 +253,13 @@ module('Unit | Abilities | session-recording', function (hooks) { ); assert.false( - canService.can('delete session-recording', recordingWithAuthorizedAction), + abilitiesService.can( + 'delete session-recording', + recordingWithAuthorizedAction, + ), ); assert.false( - canService.can( + abilitiesService.can( 'delete session-recording', recordingWithoutAuthorizedAction, ), diff --git a/ui/admin/tests/unit/abilities/storage-bucket-test.js b/ui/admin/tests/unit/abilities/storage-bucket-test.js index 8b692d9dd..e464ae32c 100644 --- a/ui/admin/tests/unit/abilities/storage-bucket-test.js +++ b/ui/admin/tests/unit/abilities/storage-bucket-test.js @@ -14,12 +14,12 @@ module('Unit | Abilities | storage-bucket', function (hooks) { setupTest(hooks); let features; - let canService; + let abilitiesService; let store; hooks.beforeEach(function () { store = this.owner.lookup('service:store'); - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); features = this.owner.lookup('service:features'); }); @@ -32,7 +32,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3, }); - assert.true(canService.can('read storage-bucket', storageBucket)); + assert.true(abilitiesService.can('read storage-bucket', storageBucket)); }); test('cannot read storage bucket when unauthorized and feature is enabled', function (assert) { @@ -44,7 +44,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3, }); - assert.false(canService.can('read storage-bucket', storageBucket)); + assert.false(abilitiesService.can('read storage-bucket', storageBucket)); }); test('cannot read storage bucket when authorized and feature is disabled', function (assert) { @@ -54,7 +54,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3, }); - assert.false(canService.can('read storage-bucket', storageBucket)); + assert.false(abilitiesService.can('read storage-bucket', storageBucket)); }); test('cannot read storage bucket when unauthorized and feature is disabled', function (assert) { @@ -64,7 +64,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3, }); - assert.false(canService.can('read storage-bucket', storageBucket)); + assert.false(abilitiesService.can('read storage-bucket', storageBucket)); }); test('can list storage bucket when authorized and in global scope', function (assert) { @@ -77,7 +77,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { }); assert.true( - canService.can('list scope', scopeModel, { + abilitiesService.can('list scope', scopeModel, { collection: 'storage-buckets', }), ); @@ -93,7 +93,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { }); assert.false( - canService.can('list scope', scopeModel, { + abilitiesService.can('list scope', scopeModel, { collection: 'storage-buckets', }), ); @@ -109,7 +109,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { }); assert.true( - canService.can('list scope', scopeModel, { + abilitiesService.can('list scope', scopeModel, { collection: 'storage-buckets', }), ); @@ -125,7 +125,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { }); assert.true( - canService.can('create scope', scopeModel, { + abilitiesService.can('create scope', scopeModel, { collection: 'storage-buckets', }), ); @@ -141,7 +141,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { }); assert.true( - canService.can('create scope', scopeModel, { + abilitiesService.can('create scope', scopeModel, { collection: 'storage-buckets', }), ); @@ -157,7 +157,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { }); assert.true( - canService.can('create scope', scopeModel, { + abilitiesService.can('create scope', scopeModel, { collection: 'storage-buckets', }), ); @@ -173,7 +173,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { }); assert.false( - canService.can('create scope', scopeModel, { + abilitiesService.can('create scope', scopeModel, { collection: 'storage-buckets', }), ); @@ -189,7 +189,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { }); assert.true( - canService.can('navigate scope', scopeModel, { + abilitiesService.can('navigate scope', scopeModel, { collection: 'storage-buckets', }), ); @@ -203,7 +203,7 @@ module('Unit | Abilities | storage-bucket', function (hooks) { }); assert.false( - canService.can('navigate scope', scopeModel, { + abilitiesService.can('navigate scope', scopeModel, { collection: 'storage-buckets', }), ); diff --git a/ui/admin/tests/unit/abilities/user-test.js b/ui/admin/tests/unit/abilities/user-test.js index c5e4dde3b..67009271b 100644 --- a/ui/admin/tests/unit/abilities/user-test.js +++ b/ui/admin/tests/unit/abilities/user-test.js @@ -14,7 +14,7 @@ import { module('Unit | Abilities | user', function (hooks) { setupTest(hooks); - let canService; + let abilitiesService; let store; let features; @@ -24,7 +24,7 @@ module('Unit | Abilities | user', function (hooks) { }; hooks.beforeEach(function () { - canService = this.owner.lookup('service:can'); + abilitiesService = this.owner.lookup('service:abilities'); store = this.owner.lookup('service:store'); features = this.owner.lookup('service:features'); instances.user = store.createRecord('user', { @@ -37,7 +37,7 @@ module('Unit | Abilities | user', function (hooks) { features.enable('ldap-auth-methods'); instances.account.type = TYPE_AUTH_METHOD_LDAP; assert.true( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); @@ -46,13 +46,13 @@ module('Unit | Abilities | user', function (hooks) { test('can add non-ldap account to user', function (assert) { instances.account.type = TYPE_AUTH_METHOD_OIDC; assert.true( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_PASSWORD; assert.true( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); @@ -61,7 +61,7 @@ module('Unit | Abilities | user', function (hooks) { test('cannot add ldap account to user when feature flag disabled', function (assert) { instances.account.type = TYPE_AUTH_METHOD_LDAP; assert.false( - canService.can('addAccount user', instances.user, { + abilitiesService.can('addAccount user', instances.user, { account: instances.account, }), ); @@ -71,7 +71,7 @@ module('Unit | Abilities | user', function (hooks) { features.enable('ldap-auth-methods'); instances.account.type = TYPE_AUTH_METHOD_LDAP; assert.true( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); @@ -80,7 +80,7 @@ module('Unit | Abilities | user', function (hooks) { test('cannot remove ldap account from user when feature flag disabled', function (assert) { instances.account.type = TYPE_AUTH_METHOD_LDAP; assert.false( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); @@ -89,13 +89,13 @@ module('Unit | Abilities | user', function (hooks) { test('can remove non-ldap account from user', function (assert) { instances.account.type = TYPE_AUTH_METHOD_OIDC; assert.true( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); instances.account.type = TYPE_AUTH_METHOD_PASSWORD; assert.true( - canService.can('removeAccount user', instances.user, { + abilitiesService.can('removeAccount user', instances.user, { account: instances.account, }), ); diff --git a/ui/desktop/app/app.js b/ui/desktop/app/app.js index e721cd857..41d16cc89 100644 --- a/ui/desktop/app/app.js +++ b/ui/desktop/app/app.js @@ -13,11 +13,12 @@ import { importSync, isTesting, } from '@embroider/macros'; +import { extendResolver } from 'ember-can'; export default class App extends Application { modulePrefix = config.modulePrefix; podModulePrefix = config.podModulePrefix; - Resolver = Resolver; + Resolver = extendResolver(Resolver); } loadInitializers(App, config.modulePrefix); diff --git a/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js b/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js index f64e0c7df..6bf642de9 100644 --- a/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js +++ b/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js @@ -25,7 +25,7 @@ export default class ScopesScopeProjectsSessionsIndexController extends Controll @service ipc; @service session; @service router; - @service can; + @service abilities; // =attributes @@ -129,7 +129,7 @@ export default class ScopesScopeProjectsSessionsIndexController extends Controll async cancelSession(session) { let updatedSession = session; // fetch session from API to verify we have most up to date record - if (this.can.can('read session', session)) { + if (this.abilities.can('read session', session)) { updatedSession = await this.store.findRecord('session', session.id, { reload: true, }); diff --git a/ui/desktop/app/controllers/scopes/scope/projects/targets/index.js b/ui/desktop/app/controllers/scopes/scope/projects/targets/index.js index 2f98bf9f4..36c74ef0c 100644 --- a/ui/desktop/app/controllers/scopes/scope/projects/targets/index.js +++ b/ui/desktop/app/controllers/scopes/scope/projects/targets/index.js @@ -24,7 +24,7 @@ export default class ScopesScopeProjectsTargetsIndexController extends Controlle @service router; @service session; @service store; - @service can; + @service abilities; @service intl; @service rdp; @@ -300,7 +300,7 @@ export default class ScopesScopeProjectsTargetsIndexController extends Controlle async cancelSession(session) { let updatedSession = session; // fetch session from API to verify we have most up to date record - if (this.can.can('read session', session)) { + if (this.abilities.can('read session', session)) { updatedSession = await this.store.findRecord('session', session.id, { reload: true, }); diff --git a/ui/desktop/app/routes/scopes/scope/projects/targets/index.js b/ui/desktop/app/routes/scopes/scope/projects/targets/index.js index 2b99abd7d..e80d35d98 100644 --- a/ui/desktop/app/routes/scopes/scope/projects/targets/index.js +++ b/ui/desktop/app/routes/scopes/scope/projects/targets/index.js @@ -17,7 +17,7 @@ const { __electronLog } = globalThis; export default class ScopesScopeProjectsTargetsIndexRoute extends Route { // =services - @service can; + @service abilities; @service clusterUrl; @service resourceFilterStore; @service router; @@ -148,7 +148,7 @@ export default class ScopesScopeProjectsTargetsIndexRoute extends Route { const { totalItems, isLoadIncomplete, isCacheRefreshing } = targets.meta; // Filter out targets to which users do not have the connect ability targets = targets.filter((target) => - this.can.can('connect target', target), + this.abilities.can('connect target', target), ); const aliasPromise = this.store.query('alias', { diff --git a/ui/desktop/package.json b/ui/desktop/package.json index bdfcf7fea..9558159e8 100644 --- a/ui/desktop/package.json +++ b/ui/desktop/package.json @@ -42,9 +42,11 @@ }, "dependencies": { "@babel/runtime": "7.27.6", + "@ember/string": "^4.0.0", "@xterm/addon-canvas": "^0.7.0", "@xterm/addon-fit": "^0.10.0", "@xterm/xterm": "^5.5.0", + "ember-inflector": "^6.0.0", "ember-named-blocks-polyfill": "^0.2.5", "lodash": "^4.17.23", "uuid": "^11.0.3" @@ -55,7 +57,6 @@ "@babel/plugin-proposal-decorators": "^7.24.7", "@ember/optional-features": "^2.1.0", "@ember/render-modifiers": "^2.0.4", - "@ember/string": "^4.0.0", "@ember/test-helpers": "^5.2.1", "@embroider/macros": "^1.18.1", "@faker-js/faker": "^8.0.2", diff --git a/ui/desktop/tests/unit/abilities/collection-test.js b/ui/desktop/tests/unit/abilities/collection-test.js index 5ff1ecd31..3bf072a22 100644 --- a/ui/desktop/tests/unit/abilities/collection-test.js +++ b/ui/desktop/tests/unit/abilities/collection-test.js @@ -11,7 +11,7 @@ module('Unit | Abilities | model', function (hooks) { test('it reflects when a resource may be navigated to based on list and create actions', function (assert) { assert.expect(4); - const service = this.owner.lookup('service:can'); + const service = this.owner.lookup('service:abilities'); const model = { authorized_collection_actions: { foobars: [] }, };