diff --git a/addons/api/addon/abilities/collection.js b/addons/api/addon/abilities/collection.js deleted file mode 100644 index 92f0e4342..000000000 --- a/addons/api/addon/abilities/collection.js +++ /dev/null @@ -1,37 +0,0 @@ -import { Ability } from 'ember-can'; - -/** - * Generic ability provides abilities common to all models in the API. - */ -export default class CollectionAbility extends Ability { - // =permissions - - /** - * @type {boolean} - */ - get canList() { - return this.hasAuthorizedCollectionAction('list'); - } - - /** - * @type {boolean} - */ - get canCreate() { - return this.hasAuthorizedCollectionAction('create'); - } - - // =methods - - /** - * Returns true if the given action is contained in the ability model's - * `authorized_collection_actions` array. - * @param {string} action - * @return {boolean} - */ - hasAuthorizedCollectionAction(action) { - const authorized_collection_actions = - (this.model || {}).authorized_collection_actions || {}; - const collection = this.collection || {}; - return authorized_collection_actions[collection]?.includes(action); - } -} diff --git a/addons/api/addon/abilities/model.js b/addons/api/addon/abilities/model.js index d820a8e02..d85663b5f 100644 --- a/addons/api/addon/abilities/model.js +++ b/addons/api/addon/abilities/model.js @@ -45,6 +45,20 @@ export default class ModelAbility extends Ability { return false; } + /** + * @type {boolean} + */ + get canList() { + return this.hasAuthorizedCollectionAction('list'); + } + + /** + * @type {boolean} + */ + get canCreate() { + return this.hasAuthorizedCollectionAction('create'); + } + // =methods /** @@ -56,4 +70,17 @@ export default class ModelAbility extends Ability { hasAuthorizedAction(action) { return this.model.authorized_actions?.includes(action); } + + /** + * Returns true if the given action is contained in the ability model's + * `authorized_collection_actions` array. + * @param {string} action + * @return {boolean} + */ + hasAuthorizedCollectionAction(action) { + const authorized_collection_actions = + (this.model || {}).authorized_collection_actions || {}; + const collection = this.collection || {}; + return authorized_collection_actions[collection]?.includes(action); + } } diff --git a/addons/api/app/abilities/collection.js b/addons/api/app/abilities/collection.js deleted file mode 100644 index 041825d2d..000000000 --- a/addons/api/app/abilities/collection.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'api/abilities/collection'; diff --git a/addons/api/tests/unit/abilities/collection-test.js b/addons/api/tests/unit/abilities/collection-test.js deleted file mode 100644 index b810e6939..000000000 --- a/addons/api/tests/unit/abilities/collection-test.js +++ /dev/null @@ -1,38 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Abilities | Collection', function (hooks) { - setupTest(hooks); - - test('it reflects when a resource may be listed based on authorized_collection_actions', function (assert) { - assert.expect(2); - const service = this.owner.lookup('service:can'); - const model = { - authorized_collection_actions: { - foobars: ['list'], - }, - }; - assert.ok(service.can('list collection', model, { collection: 'foobars' })); - model.authorized_collection_actions.foobars = []; - assert.notOk( - service.can('list collection', model, { collection: 'foobars' }) - ); - }); - - test('it reflects when a resource may be created based on authorized_collection_actions', function (assert) { - assert.expect(2); - const service = this.owner.lookup('service:can'); - const model = { - authorized_collection_actions: { - foobars: ['create'], - }, - }; - assert.ok( - service.can('create collection', model, { collection: 'foobars' }) - ); - model.authorized_collection_actions.foobars = []; - assert.notOk( - service.can('create collection', model, { collection: 'foobars' }) - ); - }); -}); diff --git a/addons/api/tests/unit/abilities/model-test.js b/addons/api/tests/unit/abilities/model-test.js index 8bff24680..f19472db1 100644 --- a/addons/api/tests/unit/abilities/model-test.js +++ b/addons/api/tests/unit/abilities/model-test.js @@ -65,4 +65,32 @@ module('Unit | Abilities | Model', function (hooks) { model.authorized_actions = []; assert.notOk(service.can('delete model', model)); }); + + // =collections + + test('it reflects when a resource may be listed based on authorized_collection_actions', function (assert) { + assert.expect(2); + const service = this.owner.lookup('service:can'); + const model = { + authorized_collection_actions: { + foobars: ['list'], + }, + }; + assert.ok(service.can('list model', model, { collection: 'foobars' })); + model.authorized_collection_actions.foobars = []; + assert.notOk(service.can('list model', model, { collection: 'foobars' })); + }); + + test('it reflects when a resource may be created based on authorized_collection_actions', function (assert) { + assert.expect(2); + const service = this.owner.lookup('service:can'); + const model = { + authorized_collection_actions: { + foobars: ['create'], + }, + }; + assert.ok(service.can('create model', model, { collection: 'foobars' })); + model.authorized_collection_actions.foobars = []; + assert.notOk(service.can('create model', model, { collection: 'foobars' })); + }); }); diff --git a/ui/admin/app/abilities/collection.js b/ui/admin/app/abilities/collection.js deleted file mode 100644 index 1da414d43..000000000 --- a/ui/admin/app/abilities/collection.js +++ /dev/null @@ -1,30 +0,0 @@ -import CollectionAbility from 'api/abilities/collection'; -import { inject as service } from '@ember/service'; - -export default class OverrideCollectionAbility extends CollectionAbility { - // =services - - @service features; - - // =permissions - - /** - * Navigating to a resource is allowed if either list or create grants - * are present. - * @type {boolean} - */ - get canNavigate() { - return this.canList || this.canCreate; - } - - // =methods - - /** - * If the capabilities feature flag is disabled, actions are always - * authorized. This mimics pre-capabilities behavior. - */ - hasAuthorizedCollectionAction() { - if (!this.features.isEnabled('capabilities')) return true; - return super.hasAuthorizedCollectionAction(...arguments); - } -} diff --git a/ui/admin/app/abilities/model.js b/ui/admin/app/abilities/model.js index 0081f7d57..d7e2b4c70 100644 --- a/ui/admin/app/abilities/model.js +++ b/ui/admin/app/abilities/model.js @@ -1,19 +1,12 @@ import ModelAbility from 'api/abilities/model'; -import { inject as service } from '@ember/service'; export default class OverrideModelAbility extends ModelAbility { - // =services - - @service features; - - // =methods - /** - * If the capabilities feature flag is disabled, actions are always - * authorized. This mimics pre-capabilities behavior. + * Navigating to a resource is allowed if either list or create grants + * are present. + * @type {boolean} */ - hasAuthorizedAction() { - if (!this.features.isEnabled('capabilities')) return true; - return super.hasAuthorizedAction(...arguments); + get canNavigate() { + return this.canList || this.canCreate; } } diff --git a/ui/admin/app/components/auth-methods/auth-method/actions/index.hbs b/ui/admin/app/components/auth-methods/auth-method/actions/index.hbs index 39c4a1d96..ec4111027 100644 --- a/ui/admin/app/components/auth-methods/auth-method/actions/index.hbs +++ b/ui/admin/app/components/auth-methods/auth-method/actions/index.hbs @@ -57,7 +57,7 @@ {{/if}} {{/if}} - {{#if (can 'create collection' @model collection='accounts')}} + {{#if (can 'create model' @model collection='accounts')}} {{t 'titles.details'}} - {{#if (can 'navigate collection' @model collection='accounts')}} + {{#if (can 'navigate model' @model collection='accounts')}} {{t 'resources.account.title_plural'}} @@ -10,7 +10,7 @@ {{/if}} {{#if (feature-flag 'managed-groups')}} - {{#if (can 'navigate collection' @model collection='managed-groups')}} + {{#if (can 'navigate model' @model collection='managed-groups')}} {{#if @model.isOIDC}} {{t 'resources.managed-group.title_plural'}} diff --git a/ui/admin/app/components/credential-stores/credential-store/actions/index.hbs b/ui/admin/app/components/credential-stores/credential-store/actions/index.hbs index b264a425a..4ba98f07d 100644 --- a/ui/admin/app/components/credential-stores/credential-store/actions/index.hbs +++ b/ui/admin/app/components/credential-stores/credential-store/actions/index.hbs @@ -3,7 +3,7 @@ @dropdownRight={{true}} as |dropdown| > - {{#if (can 'create collection' @model collection='credential-libraries')}} + {{#if (can 'create model' @model collection='credential-libraries')}} {{t 'titles.details'}} - {{#if (can 'navigate collection' @model collection='credential-libraries')}} + {{#if (can 'navigate model' @model collection='credential-libraries')}} --}} - {{#if (can 'navigate collection' @model collection='sessions')}} + {{#if (can 'navigate model' @model collection='sessions')}} {{/if}} - {{#if (can 'navigate collection' @model collection='targets')}} + {{#if (can 'navigate model' @model collection='targets')}} {{/if}} - {{#if (can 'navigate collection' @model collection='host-catalogs')}} + {{#if (can 'navigate model' @model collection='host-catalogs')}} {{/if}} - {{#if - (can 'navigate collection' @model collection='credential-stores') - }} + {{#if (can 'navigate model' @model collection='credential-stores')}} {{#if (feature-flag 'credential-store')}} @@ -113,13 +111,13 @@ {{#unless @model.isProject}} - {{#if (can 'navigate collection' @model collection='users')}} + {{#if (can 'navigate model' @model collection='users')}} {{t 'resources.user.title_plural'}} {{/if}} - {{#if (can 'navigate collection' @model collection='groups')}} + {{#if (can 'navigate model' @model collection='groups')}} {{/if}} - {{#if (can 'navigate collection' @model collection='roles')}} + {{#if (can 'navigate model' @model collection='roles')}} {{/if}} - {{#if (can 'navigate collection' @model collection='auth-methods')}} + {{#if (can 'navigate model' @model collection='auth-methods')}} {{t 'resources.auth-method.title_plural'}} diff --git a/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs b/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs index 23568129e..b82aca3cb 100644 --- a/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs +++ b/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs @@ -131,14 +131,12 @@ > - {{#if - (can 'list collection' this.authMethod collection='accounts') - }} + {{#if (can 'list model' this.authMethod collection='accounts')}} {{! can list (at least): show default welcome message}} {{t 'resources.account.description'}} {{else if (can - 'create collection' this.authMethod collection='accounts' + 'create model' this.authMethod collection='accounts' )}} {{! can create (only): show create-but-not-list welcome message}} {{t @@ -155,9 +153,7 @@ - {{#if - (can 'create collection' this.authMethod collection='accounts') - }} + {{#if (can 'create model' this.authMethod collection='accounts')}} {{#if - (can - 'list collection' this.authMethod collection='managed-groups' - ) + (can 'list model' this.authMethod collection='managed-groups') }} {{! Can list (at least): show default welcome message }} {{t 'resources.managed-group.description'}} {{else if (can - 'create collection' this.authMethod collection='managed-groups' + 'create model' this.authMethod collection='managed-groups' )}} {{! Can create only: show create but not list welcome message }} {{t @@ -93,9 +91,7 @@ {{#if - (can - 'create collection' this.authMethod collection='managed-groups' - ) + (can 'create model' this.authMethod collection='managed-groups') }} - {{#if (can 'create collection' this.scopeModel collection='auth-methods')}} + {{#if (can 'create model' this.scopeModel collection='auth-methods')}} - {{#if - (can 'list collection' this.scopeModel collection='auth-methods') - }} + {{#if (can 'list model' this.scopeModel collection='auth-methods')}} {{! can list (at least): show default welcome message}} {{t 'resources.auth-method.messages.welcome.description'}} {{else if (can - 'create collection' this.scopeModel collection='auth-methods' + 'create model' this.scopeModel collection='auth-methods' )}} {{! can create (only): show create-but-not-list welcome message}} {{t diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/index.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/index.hbs index d231ca381..3c3b603c5 100644 --- a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/index.hbs +++ b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/index.hbs @@ -79,7 +79,7 @@ {{#if (can - 'list collection' + 'list model' this.credentialStore collection='credential-libraries' ) @@ -88,7 +88,7 @@ {{t 'resources.credential-library.description'}} {{else if (can - 'create collection' + 'create model' this.credentialStore collection='credential-libraries' )}} @@ -108,7 +108,7 @@ {{#if (can - 'create collection' + 'create model' this.credentialStore collection='credential-libraries' ) diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/index.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/index.hbs index 299fa5844..49e297ebd 100644 --- a/ui/admin/app/templates/scopes/scope/credential-stores/index.hbs +++ b/ui/admin/app/templates/scopes/scope/credential-stores/index.hbs @@ -15,7 +15,7 @@ - {{#if (can 'create collection' this.scope collection='credential-stores')}} + {{#if (can 'create model' this.scope collection='credential-stores')}} {{#if @model}} - {{#if - (can 'list collection' this.scope collection='credential-stores') - }} + {{#if (can 'list model' this.scope collection='credential-stores')}} {{! can list (at least): show default welcome message}} {{t 'resources.credential-store.description'}} {{else if (can - 'create collection' this.scope collection='credential-stores' + 'create model' this.scope collection='credential-stores' )}} {{! can create (only): show create-but-not-list welcome message}} {{t @@ -103,9 +101,7 @@ }} {{/if}} - {{#if - (can 'create collection' this.scope collection='credential-stores') - }} + {{#if (can 'create model' this.scope collection='credential-stores')}} {{t 'titles.new'}} diff --git a/ui/admin/app/templates/scopes/scope/groups/index.hbs b/ui/admin/app/templates/scopes/scope/groups/index.hbs index 67bacc5f8..bbab758dc 100644 --- a/ui/admin/app/templates/scopes/scope/groups/index.hbs +++ b/ui/admin/app/templates/scopes/scope/groups/index.hbs @@ -13,7 +13,7 @@ - {{#if (can 'create collection' this.scope collection='groups')}} + {{#if (can 'create model' this.scope collection='groups')}} {{#if @model}} {{t 'titles.new' @@ -71,10 +71,10 @@ as |message| > - {{#if (can 'list collection' this.scope collection='groups')}} + {{#if (can 'list model' this.scope collection='groups')}} {{! can list (at least): show default welcome message}} {{t 'resources.group.description'}} - {{else if (can 'create collection' this.scope collection='groups')}} + {{else if (can 'create model' this.scope collection='groups')}} {{! can create (only): show create-but-not-list welcome message}} {{t 'descriptions.create-but-not-list' @@ -88,7 +88,7 @@ }} {{/if}} - {{#if (can 'create collection' this.scope collection='groups')}} + {{#if (can 'create model' this.scope collection='groups')}} {{t 'titles.new'}} diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/-actions.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/-actions.hbs index 696c9e35e..e4166f25a 100644 --- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/-actions.hbs +++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/-actions.hbs @@ -3,7 +3,7 @@ @dropdownRight={{true}} as |dropdown| > - {{#if (can 'create collection' @model collection='hosts')}} + {{#if (can 'create model' @model collection='hosts')}} {{/if}} - {{#if (can 'create collection' @model collection='host-sets')}} + {{#if (can 'create model' @model collection='host-sets')}} {{t 'titles.details'}} - {{#if (can 'navigate collection' @model collection='hosts')}} + {{#if (can 'navigate model' @model collection='hosts')}} {{t 'resources.host.title_plural'}} {{/if}} - {{#if (can 'navigate collection' @model collection='host-sets')}} + {{#if (can 'navigate model' @model collection='host-sets')}} {{t 'resources.host-set.title_plural'}} diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/index.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/index.hbs index b13cf374d..8e60985ca 100644 --- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/index.hbs +++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/index.hbs @@ -64,13 +64,11 @@ > - {{#if (can 'list collection' this.hostCatalog collection='host-sets')}} + {{#if (can 'list model' this.hostCatalog collection='host-sets')}} {{! can list (at least): show default welcome message}} {{t 'resources.host-set.description'}} - {{else if (can - 'create collection' this.hostCatalog collection='host-sets' - )}} + {{else if (can 'create model' this.hostCatalog collection='host-sets')}} {{! can create (only): show create-but-not-list welcome message}} {{t 'descriptions.create-but-not-list' @@ -85,7 +83,7 @@ {{/if}} - {{#if (can 'create collection' this.hostCatalog collection='host-sets')}} + {{#if (can 'create model' this.hostCatalog collection='host-sets')}} diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs index c60732eea..c86594f02 100644 --- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs +++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs @@ -69,13 +69,11 @@ > - {{#if (can 'list collection' this.hostCatalog collection='hosts')}} + {{#if (can 'list model' this.hostCatalog collection='hosts')}} {{! can list (at least): show default welcome message}} {{t 'resources.host.description'}} - {{else if (can - 'create collection' this.hostCatalog collection='hosts' - )}} + {{else if (can 'create model' this.hostCatalog collection='hosts')}} {{! can create (only): show create-but-not-list welcome message}} {{t 'descriptions.create-but-not-list' @@ -90,7 +88,7 @@ {{/if}} - {{#if (can 'create collection' this.hostCatalog collection='hosts')}} + {{#if (can 'create model' this.hostCatalog collection='hosts')}} - {{#if (can 'create collection' this.scope collection='host-catalogs')}} + {{#if (can 'create model' this.scope collection='host-catalogs')}} {{#if @model}} - {{#if - (can 'list collection' this.scope collection='host-catalogs') - }} + {{#if (can 'list model' this.scope collection='host-catalogs')}} {{! can list (at least): show default welcome message}} {{t 'resources.host-catalog.description'}} {{else if (can - 'create collection' this.scope collection='host-catalogs' + 'create model' this.scope collection='host-catalogs' )}} {{! can create (only): show create-but-not-list welcome message}} {{t @@ -134,9 +132,7 @@ }} {{/if}} - {{#if - (can 'create collection' this.scope collection='host-catalogs') - }} + {{#if (can 'create model' this.scope collection='host-catalogs')}} {{t 'titles.new'}} diff --git a/ui/admin/app/templates/scopes/scope/roles/index.hbs b/ui/admin/app/templates/scopes/scope/roles/index.hbs index 64b1dd0a9..19fd914dc 100644 --- a/ui/admin/app/templates/scopes/scope/roles/index.hbs +++ b/ui/admin/app/templates/scopes/scope/roles/index.hbs @@ -15,7 +15,7 @@ - {{#if (can 'create collection' this.scope collection='roles')}} + {{#if (can 'create model' this.scope collection='roles')}} {{#if @model}} {{t 'titles.new' @@ -70,10 +70,10 @@ as |message| > - {{#if (can 'list collection' this.scope collection='roles')}} + {{#if (can 'list model' this.scope collection='roles')}} {{! can list (at least): show default welcome message}} {{t 'resources.roles.description'}} - {{else if (can 'create collection' this.scope collection='roles')}} + {{else if (can 'create model' this.scope collection='roles')}} {{! can create (only): show create-but-not-list welcome message}} {{t 'descriptions.create-but-not-list' @@ -87,7 +87,7 @@ }} {{/if}} - {{#if (can 'create collection' this.scope collection='roles')}} + {{#if (can 'create model' this.scope collection='roles')}} {{t 'titles.new'}} diff --git a/ui/admin/app/templates/scopes/scope/scopes/index.hbs b/ui/admin/app/templates/scopes/scope/scopes/index.hbs index 93ad6668a..5c2546baf 100644 --- a/ui/admin/app/templates/scopes/scope/scopes/index.hbs +++ b/ui/admin/app/templates/scopes/scope/scopes/index.hbs @@ -26,7 +26,7 @@ - {{#if (can 'create collection' @model.currentScope collection='scopes')}} + {{#if (can 'create model' @model.currentScope collection='scopes')}} {{#if @model.subScopes}} {{t 'titles.new'}} @@ -67,9 +67,7 @@ {{t 'resources.org.description'}} - {{#if - (can 'create collection' @model.currentScope collection='scopes') - }} + {{#if (can 'create model' @model.currentScope collection='scopes')}} {{t 'titles.new'}} @@ -88,9 +86,7 @@ {{t 'resources.project.description'}} - {{#if - (can 'create collection' @model.currentScope collection='scopes') - }} + {{#if (can 'create model' @model.currentScope collection='scopes')}} {{t 'titles.new'}} diff --git a/ui/admin/app/templates/scopes/scope/targets/index.hbs b/ui/admin/app/templates/scopes/scope/targets/index.hbs index 866e674a0..4705b4a2f 100644 --- a/ui/admin/app/templates/scopes/scope/targets/index.hbs +++ b/ui/admin/app/templates/scopes/scope/targets/index.hbs @@ -15,7 +15,7 @@ - {{#if (can 'create collection' this.scope collection='targets')}} + {{#if (can 'create model' this.scope collection='targets')}} {{#if @model}} {{t 'titles.new' @@ -81,12 +81,10 @@ > - {{#if (can 'list collection' this.scope collection='targets')}} + {{#if (can 'list model' this.scope collection='targets')}} {{! can list (at least): show default welcome message}} {{t 'resources.target.description'}} - {{else if (can - 'create collection' this.scope collection='targets' - )}} + {{else if (can 'create model' this.scope collection='targets')}} {{! can create (only): show create-but-not-list welcome message}} {{t 'descriptions.create-but-not-list' @@ -102,7 +100,7 @@ {{/if}} - {{#if (can 'create collection' this.scope collection='targets')}} + {{#if (can 'create model' this.scope collection='targets')}} {{t 'titles.new'}} diff --git a/ui/admin/app/templates/scopes/scope/users/index.hbs b/ui/admin/app/templates/scopes/scope/users/index.hbs index 2c78ceb2d..3b6259879 100644 --- a/ui/admin/app/templates/scopes/scope/users/index.hbs +++ b/ui/admin/app/templates/scopes/scope/users/index.hbs @@ -15,7 +15,7 @@ - {{#if (can 'create collection' this.scope collection='users')}} + {{#if (can 'create model' this.scope collection='users')}} {{#if @model}} {{t 'titles.new' @@ -73,10 +73,10 @@ as |message| > - {{#if (can 'list collection' this.scope collection='users')}} + {{#if (can 'list model' this.scope collection='users')}} {{! can list (at least): show default welcome message}} {{t 'resources.user.description'}} - {{else if (can 'create collection' this.scope collection='users')}} + {{else if (can 'create model' this.scope collection='users')}} {{! can create (only): show create-but-not-list welcome message}} {{t 'descriptions.create-but-not-list' @@ -90,7 +90,7 @@ }} {{/if}} - {{#if (can 'create collection' this.scope collection='users')}} + {{#if (can 'create model' this.scope collection='users')}} {{t 'titles.new'}} diff --git a/ui/admin/config/environment.js b/ui/admin/config/environment.js index dc951f583..f5d8c53b9 100644 --- a/ui/admin/config/environment.js +++ b/ui/admin/config/environment.js @@ -95,7 +95,6 @@ module.exports = function (environment) { 'oidc-account-crud': true, search: false, filter: true, - capabilities: true, 'credential-store': true, 'managed-groups': true, }, diff --git a/ui/admin/tests/unit/abilities/collection-test.js b/ui/admin/tests/unit/abilities/collection-test.js index 586eb52b4..889716e36 100644 --- a/ui/admin/tests/unit/abilities/collection-test.js +++ b/ui/admin/tests/unit/abilities/collection-test.js @@ -1,7 +1,7 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -module('Unit | Abilities | Collection', function (hooks) { +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) { @@ -11,19 +11,13 @@ module('Unit | Abilities | Collection', function (hooks) { authorized_collection_actions: { foobars: [] }, }; assert.notOk( - service.can('navigate collection', model, { collection: 'foobars' }) + service.can('navigate model', model, { collection: 'foobars' }) ); model.authorized_collection_actions.foobars = ['list']; - assert.ok( - service.can('navigate collection', model, { collection: 'foobars' }) - ); + assert.ok(service.can('navigate model', model, { collection: 'foobars' })); model.authorized_collection_actions.foobars = ['create']; - assert.ok( - service.can('navigate collection', model, { collection: 'foobars' }) - ); + assert.ok(service.can('navigate model', model, { collection: 'foobars' })); model.authorized_collection_actions.foobars = ['list', 'create']; - assert.ok( - service.can('navigate collection', model, { collection: 'foobars' }) - ); + assert.ok(service.can('navigate model', model, { collection: 'foobars' })); }); }); diff --git a/ui/desktop/app/abilities/collection.js b/ui/desktop/app/abilities/collection.js deleted file mode 100644 index 1da414d43..000000000 --- a/ui/desktop/app/abilities/collection.js +++ /dev/null @@ -1,30 +0,0 @@ -import CollectionAbility from 'api/abilities/collection'; -import { inject as service } from '@ember/service'; - -export default class OverrideCollectionAbility extends CollectionAbility { - // =services - - @service features; - - // =permissions - - /** - * Navigating to a resource is allowed if either list or create grants - * are present. - * @type {boolean} - */ - get canNavigate() { - return this.canList || this.canCreate; - } - - // =methods - - /** - * If the capabilities feature flag is disabled, actions are always - * authorized. This mimics pre-capabilities behavior. - */ - hasAuthorizedCollectionAction() { - if (!this.features.isEnabled('capabilities')) return true; - return super.hasAuthorizedCollectionAction(...arguments); - } -} diff --git a/ui/desktop/app/abilities/model.js b/ui/desktop/app/abilities/model.js index 0081f7d57..d7e2b4c70 100644 --- a/ui/desktop/app/abilities/model.js +++ b/ui/desktop/app/abilities/model.js @@ -1,19 +1,12 @@ import ModelAbility from 'api/abilities/model'; -import { inject as service } from '@ember/service'; export default class OverrideModelAbility extends ModelAbility { - // =services - - @service features; - - // =methods - /** - * If the capabilities feature flag is disabled, actions are always - * authorized. This mimics pre-capabilities behavior. + * Navigating to a resource is allowed if either list or create grants + * are present. + * @type {boolean} */ - hasAuthorizedAction() { - if (!this.features.isEnabled('capabilities')) return true; - return super.hasAuthorizedAction(...arguments); + get canNavigate() { + return this.canList || this.canCreate; } } diff --git a/ui/desktop/config/environment.js b/ui/desktop/config/environment.js index c2d5f9c19..ab199e29e 100644 --- a/ui/desktop/config/environment.js +++ b/ui/desktop/config/environment.js @@ -58,7 +58,6 @@ module.exports = function (environment) { oidc: true, search: false, filter: true, - capabilities: true, 'credential-store': false, }, }; diff --git a/ui/desktop/tests/unit/abilities/collection-test.js b/ui/desktop/tests/unit/abilities/collection-test.js index 586eb52b4..889716e36 100644 --- a/ui/desktop/tests/unit/abilities/collection-test.js +++ b/ui/desktop/tests/unit/abilities/collection-test.js @@ -1,7 +1,7 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -module('Unit | Abilities | Collection', function (hooks) { +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) { @@ -11,19 +11,13 @@ module('Unit | Abilities | Collection', function (hooks) { authorized_collection_actions: { foobars: [] }, }; assert.notOk( - service.can('navigate collection', model, { collection: 'foobars' }) + service.can('navigate model', model, { collection: 'foobars' }) ); model.authorized_collection_actions.foobars = ['list']; - assert.ok( - service.can('navigate collection', model, { collection: 'foobars' }) - ); + assert.ok(service.can('navigate model', model, { collection: 'foobars' })); model.authorized_collection_actions.foobars = ['create']; - assert.ok( - service.can('navigate collection', model, { collection: 'foobars' }) - ); + assert.ok(service.can('navigate model', model, { collection: 'foobars' })); model.authorized_collection_actions.foobars = ['list', 'create']; - assert.ok( - service.can('navigate collection', model, { collection: 'foobars' }) - ); + assert.ok(service.can('navigate model', model, { collection: 'foobars' })); }); });