diff --git a/ui/admin/app/controllers/scopes/scope/aliases/index.js b/ui/admin/app/controllers/scopes/scope/aliases/index.js index 15e64ac61..ef39cf83a 100644 --- a/ui/admin/app/controllers/scopes/scope/aliases/index.js +++ b/ui/admin/app/controllers/scopes/scope/aliases/index.js @@ -16,6 +16,7 @@ export default class ScopesScopeAliasesIndexController extends Controller { // =services @service can; + @service intl; @service router; // =attributes @@ -26,6 +27,31 @@ export default class ScopesScopeAliasesIndexController extends Controller { @tracked page = 1; @tracked pageSize = 10; + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.scope, { + collection: 'aliases', + }); + const canCreate = this.can.can('create model', this.scope, { + collection: 'aliases', + }); + const resource = this.intl.t('resources.alias.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.alias.messages.none.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** 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 8606dcdc5..69f90fd36 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 @@ -16,8 +16,36 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsIndexController ext // =services @service can; + @service intl; @service router; + // =attributes + + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.authMethod, { + collection: 'accounts', + }); + const canCreate = this.can.can('create model', this.authMethod, { + collection: 'accounts', + }); + const resource = this.intl.t('resources.account.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.account.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** 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 4b7491609..1361bca8b 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 @@ -16,8 +16,36 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsIndexControlle // =services @service can; + @service intl; @service router; + // =attributes + + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.authMethod, { + collection: 'managed-groups', + }); + const canCreate = this.can.can('create model', this.authMethod, { + collection: 'managed-groups', + }); + const resource = this.intl.t('resources.managed-group.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.managed-group.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** 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 4de6147f3..545cf6a6c 100644 --- a/ui/admin/app/controllers/scopes/scope/auth-methods/index.js +++ b/ui/admin/app/controllers/scopes/scope/auth-methods/index.js @@ -72,6 +72,31 @@ export default class ScopesScopeAuthMethodsIndexController extends Controller { }; } + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.scopeModel, { + collection: 'auth-methods', + }); + const canCreate = this.can.can('create model', this.scopeModel, { + collection: 'auth-methods', + }); + const resource = this.intl.t('resources.auth-method.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.auth-method.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** 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 2cd4083e2..6a1bad0b2 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 @@ -16,8 +16,36 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari // =services @service can; + @service intl; @service router; + // =attributes + + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.credentialStore, { + collection: 'credential-libraries', + }); + const canCreate = this.can.can('create model', this.credentialStore, { + collection: 'credential-libraries', + }); + const resource = this.intl.t('resources.credential-library.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.credential-library.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** 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 43a7242c7..49952fbce 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 @@ -16,8 +16,36 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsIndexC // =services @service can; + @service intl; @service router; + // =attributes + + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.credentialStore, { + collection: 'credentials', + }); + const canCreate = this.can.can('create model', this.credentialStore, { + collection: 'credentials', + }); + const resource = this.intl.t('resources.credential.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.credential.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** 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 ad9b2b874..0989443bc 100644 --- a/ui/admin/app/controllers/scopes/scope/credential-stores/index.js +++ b/ui/admin/app/controllers/scopes/scope/credential-stores/index.js @@ -43,6 +43,31 @@ export default class ScopesScopeCredentialStoresIndexController extends Controll }; } + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.scope, { + collection: 'credential-stores', + }); + const canCreate = this.can.can('create model', this.scope, { + collection: 'credential-stores', + }); + const resource = this.intl.t('resources.credential-store.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.credential-store.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** diff --git a/ui/admin/app/controllers/scopes/scope/groups/index.js b/ui/admin/app/controllers/scopes/scope/groups/index.js index 7c9c21508..a428848e0 100644 --- a/ui/admin/app/controllers/scopes/scope/groups/index.js +++ b/ui/admin/app/controllers/scopes/scope/groups/index.js @@ -14,7 +14,9 @@ import { debounce } from 'core/decorators/debounce'; export default class ScopesScopeGroupsIndexController extends Controller { // =services + @service can; + @service intl; @service router; // =attributes @@ -25,6 +27,31 @@ export default class ScopesScopeGroupsIndexController extends Controller { @tracked page = 1; @tracked pageSize = 10; + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.scope, { + collection: 'groups', + }); + const canCreate = this.can.can('create model', this.scope, { + collection: 'groups', + }); + const resource = this.intl.t('resources.group.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.group.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** 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 aab8235e7..862d5299e 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,8 +15,36 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsIndexController e // =services - @service router; @service can; + @service intl; + @service router; + + // =attributes + + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.hostCatalog, { + collection: 'host-sets', + }); + const canCreate = this.can.can('create model', this.hostCatalog, { + collection: 'host-sets', + }); + const resource = this.intl.t('resources.host-set.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.host-set.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } // =actions 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 6b1165dd5..e32f7e7ea 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 @@ -16,8 +16,36 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsIndexController exte // =services @service can; + @service intl; @service router; + // =attributes + + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.hostCatalog, { + collection: 'hosts', + }); + const canCreate = this.can.can('create model', this.hostCatalog, { + collection: 'hosts', + }); + const resource = this.intl.t('resources.host.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.host.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** 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 0e7a9bc6a..d14174c28 100644 --- a/ui/admin/app/controllers/scopes/scope/host-catalogs/index.js +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/index.js @@ -16,8 +16,9 @@ import { TYPE_STATIC_CREDENTIAL } from 'api/models/host-catalog'; export default class ScopesScopeHostCatalogsIndexController extends Controller { // =services - @service router; @service can; + @service intl; + @service router; // =attributes @@ -27,6 +28,31 @@ export default class ScopesScopeHostCatalogsIndexController extends Controller { @tracked page = 1; @tracked pageSize = 10; + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.scope, { + collection: 'host-catalogs', + }); + const canCreate = this.can.can('create model', this.scope, { + collection: 'host-catalogs', + }); + const resource = this.intl.t('resources.host-catalog.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.host-catalog.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** diff --git a/ui/admin/app/controllers/scopes/scope/policies/index.js b/ui/admin/app/controllers/scopes/scope/policies/index.js index d1f604e1f..e6d8a69fc 100644 --- a/ui/admin/app/controllers/scopes/scope/policies/index.js +++ b/ui/admin/app/controllers/scopes/scope/policies/index.js @@ -14,8 +14,36 @@ export default class ScopesScopePoliciesIndexController extends Controller { // =services @service can; + @service intl; @service router; + // =attributes + + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.scope, { + collection: 'policies', + }); + const canCreate = this.can.can('create model', this.scope, { + collection: 'policies', + }); + const resource = this.intl.t('resources.policy.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.policy.messages.none.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** diff --git a/ui/admin/app/controllers/scopes/scope/roles/index.js b/ui/admin/app/controllers/scopes/scope/roles/index.js index 03c526243..d569b670a 100644 --- a/ui/admin/app/controllers/scopes/scope/roles/index.js +++ b/ui/admin/app/controllers/scopes/scope/roles/index.js @@ -17,6 +17,7 @@ export default class ScopesScopeRolesIndexController extends Controller { // =services @service can; + @service intl; @service router; // =attributes @@ -29,6 +30,31 @@ export default class ScopesScopeRolesIndexController extends Controller { grantScopeThis = GRANT_SCOPE_THIS; + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.scope, { + collection: 'roles', + }); + const canCreate = this.can.can('create model', this.scope, { + collection: 'roles', + }); + const resource = this.intl.t('resources.role.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.role.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** 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 27ef58768..7c66efcb2 100644 --- a/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js +++ b/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js @@ -13,8 +13,37 @@ import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeStorageBucketsIndexController extends Controller { // =services + @service can; + @service intl; @service router; + // =attributes + + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list scope', this.scope, { + collection: 'storage-buckets', + }); + const canCreate = this.can.can('create scope', this.scope, { + collection: 'storage-buckets', + }); + const resource = this.intl.t('resources.storage-bucket.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.storage-bucket.messages.none.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** diff --git a/ui/admin/app/controllers/scopes/scope/targets/index.js b/ui/admin/app/controllers/scopes/scope/targets/index.js index c4b6a2fc5..e8b6a1903 100644 --- a/ui/admin/app/controllers/scopes/scope/targets/index.js +++ b/ui/admin/app/controllers/scopes/scope/targets/index.js @@ -72,6 +72,31 @@ export default class ScopesScopeTargetsIndexController extends Controller { })); } + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.scope, { + collection: 'targets', + }); + const canCreate = this.can.can('create model', this.scope, { + collection: 'targets', + }); + const resource = this.intl.t('resources.target.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.target.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =actions /** diff --git a/ui/admin/app/controllers/scopes/scope/users/index.js b/ui/admin/app/controllers/scopes/scope/users/index.js index b7fe9b731..38d5bb829 100644 --- a/ui/admin/app/controllers/scopes/scope/users/index.js +++ b/ui/admin/app/controllers/scopes/scope/users/index.js @@ -15,8 +15,9 @@ import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeUsersIndexController extends Controller { // =services - @service router; @service can; + @service intl; + @service router; // =attributes @@ -26,6 +27,31 @@ export default class ScopesScopeUsersIndexController extends Controller { @tracked page = 1; @tracked pageSize = 10; + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @type {string} + */ + get messageDescription() { + const canList = this.can.can('list model', this.scope, { + collection: 'users', + }); + const canCreate = this.can.can('create model', this.scope, { + collection: 'users', + }); + const resource = this.intl.t('resources.user.title_plural'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.user.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + // =methods /** diff --git a/ui/admin/app/controllers/scopes/scope/workers/index.js b/ui/admin/app/controllers/scopes/scope/workers/index.js index 23219bb41..6ba090f11 100644 --- a/ui/admin/app/controllers/scopes/scope/workers/index.js +++ b/ui/admin/app/controllers/scopes/scope/workers/index.js @@ -14,13 +14,39 @@ import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeWorkersIndexController extends Controller { // =services - @service router; @service can; + @service intl; + @service router; // =attributes @tracked selectedWorker; + /** + * If can list (at least): return default welcome message. + * If can create (only): return create-but-not-list welcome message. + * If can neither list nor create: return neither-list-nor-create welcome message + * @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, { + collection: 'workers', + }); + const resource = this.intl.t('titles.workers'); + let description = 'descriptions.neither-list-nor-create'; + + if (canList) { + description = 'resources.worker.description'; + } else if (canCreate) { + description = 'descriptions.create-but-not-list'; + } + + return this.intl.t(description, { resource }); + } + /** * Get the first 10 tags of the selected worker. * @type {object[]} diff --git a/ui/admin/app/templates/scopes/scope/aliases/index.hbs b/ui/admin/app/templates/scopes/scope/aliases/index.hbs index d4cc1d7a3..1b5c53fed 100644 --- a/ui/admin/app/templates/scopes/scope/aliases/index.hbs +++ b/ui/admin/app/templates/scopes/scope/aliases/index.hbs @@ -170,23 +170,7 @@ {{else}} - + {{#if (can 'create model' this.scope collection='aliases')}} - + {{#if (can 'create model' this.authMethod collection='accounts')}} - + {{#if (can 'create model' this.authMethod collection='managed-groups') }} diff --git a/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs b/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs index 4222f2cf2..363f58028 100644 --- a/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs +++ b/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs @@ -192,23 +192,7 @@ {{else}} - + {{/if}} 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 bfaead607..c89c1c78c 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 @@ -80,31 +80,7 @@ - + {{#if (can 'create model' diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials/index.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials/index.hbs index 3ae423b39..34bfab32e 100644 --- a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials/index.hbs +++ b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials/index.hbs @@ -75,25 +75,7 @@ - + {{#if (can 'create model' this.credentialStore collection='credentials') }} 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 01072888b..38ac24bcd 100644 --- a/ui/admin/app/templates/scopes/scope/credential-stores/index.hbs +++ b/ui/admin/app/templates/scopes/scope/credential-stores/index.hbs @@ -124,23 +124,7 @@ - + {{#if (can 'create model' this.scope collection='credential-stores')}} - + {{#if (can 'create model' this.scope collection='groups')}} - + {{#if (can 'create model' this.hostCatalog collection='host-sets')}} - + {{#if (can 'create model' this.hostCatalog collection='hosts')}} - + {{#if (can 'create model' this.scope collection='host-catalogs')}} - + {{#if (can 'create model' this.scope collection='policies')}} - + {{#if (can 'create model' this.scope collection='roles')}} - + {{#if (can 'create scope' this.scope collection='storage-buckets')}} - + {{#if (can 'create model' this.scope collection='targets')}} - + {{#if (can 'create model' this.scope collection='users')}} - + {{#if (can 'create worker led worker' this.scope collection='workers') }} diff --git a/ui/admin/tests/unit/controllers/scopes/scope/aliases/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/aliases/index-test.js index 4f6ae18fd..2bda6b349 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/aliases/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/aliases/index-test.js @@ -17,6 +17,7 @@ module('Unit | Controller | scopes/scope/aliases/index', function (hooks) { setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getAliasCount; @@ -35,6 +36,7 @@ module('Unit | Controller | scopes/scope/aliases/index', function (hooks) { hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/aliases/index'); @@ -103,4 +105,37 @@ module('Unit | Controller | scopes/scope/aliases/index', function (hooks) { assert.notOk(alias.destination_id); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.aliases); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.alias.messages.none.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.aliases = ['create']; + await visit(urls.aliases); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.alias.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.aliases = []; + await visit(urls.aliases); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.alias.title_plural'), + }), + ); + }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js index 91045df75..015457708 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js @@ -18,6 +18,7 @@ module( setupMirage(hooks); setupIntl(hooks, 'en-us'); + let intl; let controller; let store; let getAccountCount; @@ -36,6 +37,7 @@ module( hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); controller = this.owner.lookup( 'controller:scopes/scope/auth-methods/auth-method/accounts/index', ); @@ -94,5 +96,38 @@ module( assert.strictEqual(getAccountCount(), accountCount - 1); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.accounts); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.account.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.authMethod.authorized_collection_actions.accounts = ['create']; + await visit(urls.accounts); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.account.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.authMethod.authorized_collection_actions.accounts = []; + await visit(urls.accounts); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.account.title_plural'), + }), + ); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js index 29eda2aa7..aaa61b2db 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js @@ -18,6 +18,7 @@ module( setupMirage(hooks); setupIntl(hooks, 'en-us'); + let intl; let controller; let store; let getManagedGroupCount; @@ -36,6 +37,7 @@ module( hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); controller = this.owner.lookup( 'controller:scopes/scope/auth-methods/auth-method/managed-groups/index', ); @@ -117,5 +119,40 @@ module( assert.true(managedGroup.hasDirtyAttributes); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.managedGroups); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.managed-group.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.authMethod.authorized_collection_actions['managed-groups'] = [ + 'create', + ]; + await visit(urls.managedGroups); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.managed-group.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.authMethod.authorized_collection_actions['managed-groups'] = []; + await visit(urls.managedGroups); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.managed-group.title_plural'), + }), + ); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js index cce361fe1..cb8cd4955 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js @@ -23,6 +23,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getAuthMethodCount; @@ -34,8 +35,13 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { authMethod: null, }; + const urls = { + authMethods: null, + }; + hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/auth-methods/index', @@ -46,6 +52,8 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { scope: instances.scope.global, }); + urls.authMethods = '/scopes/global/auth-methods'; + getAuthMethodCount = () => this.server.schema.authMethods.all().models.length; }); @@ -92,7 +100,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { }); test('cancel action rolls-back changes on the specified model', async function (assert) { - await visit('/scopes/global/auth-methods'); + await visit(urls.authMethods); const authMethod = await store.findRecord( 'auth-method', instances.authMethod.id, @@ -107,7 +115,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { }); test('save action saves changes on the specified model', async function (assert) { - await visit('/scopes/global/auth-methods'); + await visit(urls.authMethods); const authMethod = await store.findRecord( 'auth-method', instances.authMethod.id, @@ -133,7 +141,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { }); test('makePrimary action updates scope with auth-method id', async function (assert) { - await visit('/scopes/global/auth-methods'); + await visit(urls.authMethods); const authMethod = await store.findRecord( 'auth-method', instances.authMethod.id, @@ -146,7 +154,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { }); test('removeAsPrimary action updates scope with null as auth-method id', async function (assert) { - await visit('/scopes/global/auth-methods'); + await visit(urls.authMethods); const authMethod = await store.findRecord( 'auth-method', instances.authMethod.id, @@ -230,4 +238,39 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { assert.strictEqual(authMethod.state, 'public'); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.authMethods); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.auth-method.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scope.global.authorized_collection_actions['auth-methods'] = [ + 'create', + ]; + await visit(urls.authMethods); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.auth-method.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scope.global.authorized_collection_actions['auth-methods'] = []; + await visit(urls.authMethods); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.auth-method.title_plural'), + }), + ); + }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js index bc0239be3..55996ed0c 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js @@ -10,6 +10,7 @@ import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupIntl } from 'ember-intl/test-support'; import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; import { authenticateSession } from 'ember-simple-auth/test-support'; +import { TYPE_CREDENTIAL_STORE_VAULT } from 'api/models/credential-store'; module( 'Unit | Controller | scopes/scope/credential-stores/credential-store/credential-libraries/index', @@ -19,6 +20,7 @@ module( setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getCredentialLibraryCount; @@ -39,6 +41,7 @@ module( hooks.beforeEach(async function () { await authenticateSession({}); + intl = intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/credential-store/credential-libraries/index', @@ -54,6 +57,7 @@ module( scope: { id: instances.scopes.org.id, type: 'org' }, }); instances.credentialStore = this.server.create('credential-store', { + type: TYPE_CREDENTIAL_STORE_VAULT, scope: instances.scopes.project, }); instances.credentialLibrary = this.server.create('credential-library', { @@ -127,5 +131,42 @@ module( assert.true(credentialLibrary.hasDirtyAttributes); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.credentialLibraries); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.credential-library.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.credentialStore.authorized_collection_actions[ + 'credential-libraries' + ] = ['create']; + await visit(urls.credentialLibraries); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.credential-library.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.credentialStore.authorized_collection_actions[ + 'credential-libraries' + ] = []; + await visit(urls.credentialLibraries); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.credential-library.title_plural'), + }), + ); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js index ae1481a7a..fca13fc6d 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js @@ -10,6 +10,7 @@ import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupIntl } from 'ember-intl/test-support'; import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; import { authenticateSession } from 'ember-simple-auth/test-support'; +import { TYPE_CREDENTIAL_STORE_STATIC } from 'api/models/credential-store'; module( 'Unit | Controller | scopes/scope/credential-stores/credential-store/credentials/index', @@ -19,6 +20,7 @@ module( setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getCredentialCount; @@ -39,6 +41,7 @@ module( hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/credential-store/credentials/index', @@ -54,6 +57,7 @@ module( scope: { id: instances.scopes.org.id, type: 'org' }, }); instances.credentialStore = this.server.create('credential-store', { + type: TYPE_CREDENTIAL_STORE_STATIC, scope: instances.scopes.project, }); instances.credential = this.server.create('credential', { @@ -111,5 +115,40 @@ module( assert.strictEqual(getCredentialCount(), credentialCount - 1); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.credentials); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.credential.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.credentialStore.authorized_collection_actions.credentials = [ + 'create', + ]; + await visit(urls.credentials); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.credential.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.credentialStore.authorized_collection_actions.credentials = []; + await visit(urls.credentials); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.credential.title_plural'), + }), + ); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js index f42706c7e..1c14e0390 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js @@ -23,6 +23,7 @@ module( setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let controller; let store; let getCredentialStoreCount; @@ -42,6 +43,7 @@ module( hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/index', ); @@ -138,5 +140,42 @@ module( assert.strictEqual(controller.page, 1); assert.deepEqual(controller.types, selectedItems); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.credentialStores); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.credential-store.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scopes.project.authorized_collection_actions[ + 'credential-stores' + ] = ['create']; + await visit(urls.credentialStores); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.credential-store.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scopes.project.authorized_collection_actions[ + 'credential-stores' + ] = []; + await visit(urls.credentialStores); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.credential-store.title_plural'), + }), + ); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js index f3124c6ab..4949a9689 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js @@ -17,6 +17,7 @@ module('Unit | Controller | scopes/scope/groups/index', function (hooks) { setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getGroupCount; @@ -35,6 +36,7 @@ module('Unit | Controller | scopes/scope/groups/index', function (hooks) { hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/groups/index'); @@ -105,4 +107,37 @@ module('Unit | Controller | scopes/scope/groups/index', function (hooks) { assert.deepEqual(group.member_ids, []); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.groups); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.group.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.groups = ['create']; + await visit(urls.groups); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.group.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.groups = []; + await visit(urls.groups); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.group.title_plural'), + }), + ); + }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js index 37c99ac83..aa6c626f5 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js @@ -19,6 +19,7 @@ module( setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getHostSetCount; @@ -39,6 +40,7 @@ module( hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/host-catalogs/host-catalog/host-sets/index', @@ -126,5 +128,40 @@ module( assert.deepEqual(hostSet.host_ids, []); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.hostSets); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.host-set.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.hostCatalog.authorized_collection_actions['host-sets'] = [ + 'create', + ]; + await visit(urls.hostSets); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.host-set.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.hostCatalog.authorized_collection_actions['host-sets'] = []; + await visit(urls.hostSets); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.host-set.title_plural'), + }), + ); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js index a7db77ac6..59fdce4d1 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js @@ -16,6 +16,7 @@ module( setupTest(hooks); setupMirage(hooks); + let intl; let store; let controller; let getHostCount; @@ -36,6 +37,7 @@ module( hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/host-catalogs/host-catalog/hosts/index', @@ -103,5 +105,38 @@ module( assert.strictEqual(getHostCount(), hostCount - 1); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.hosts); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.host.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.hostCatalog.authorized_collection_actions.hosts = ['create']; + await visit(urls.hosts); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.host.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.hostCatalog.authorized_collection_actions.hosts = []; + await visit(urls.hosts); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.host.title_plural'), + }), + ); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js index d7d69e7fa..527f74dd0 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js @@ -19,6 +19,7 @@ module( setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getHostCatalogCount; @@ -38,6 +39,7 @@ module( hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/host-catalogs/index', @@ -114,5 +116,40 @@ module( assert.strictEqual(getHostCatalogCount(), hostCatalogCount - 1); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.hostCatalogs); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.host-catalog.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scopes.project.authorized_collection_actions['host-catalogs'] = + ['create']; + await visit(urls.hostCatalogs); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.host-catalog.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scopes.project.authorized_collection_actions['host-catalogs'] = + []; + await visit(urls.hostCatalogs); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.host-catalog.title_plural'), + }), + ); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js index c38075ab9..96d37eb3c 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js @@ -17,6 +17,7 @@ module('Unit | Controller | scopes/scope/policies/index', function (hooks) { setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getPolicyCount; @@ -34,6 +35,7 @@ module('Unit | Controller | scopes/scope/policies/index', function (hooks) { hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/policies/index'); @@ -84,4 +86,37 @@ module('Unit | Controller | scopes/scope/policies/index', function (hooks) { assert.strictEqual(getPolicyCount(), policyCount - 1); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.policies); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.policy.messages.none.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.policies = ['create']; + await visit(urls.policies); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.policy.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.policies = []; + await visit(urls.policies); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.policy.title_plural'), + }), + ); + }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js index efe1ee8df..cd7779dd6 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js @@ -17,6 +17,7 @@ module('Unit | Controller | scopes/scope/roles/index', function (hooks) { setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getRoleCount; @@ -36,6 +37,7 @@ module('Unit | Controller | scopes/scope/roles/index', function (hooks) { hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/roles/index'); @@ -110,4 +112,37 @@ module('Unit | Controller | scopes/scope/roles/index', function (hooks) { assert.deepEqual(role.principals, []); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.roles); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.role.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.roles = ['create']; + await visit(urls.roles); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.role.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.roles = []; + await visit(urls.roles); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.role.title_plural'), + }), + ); + }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js index 3efab4286..b50fc06c6 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js @@ -19,6 +19,8 @@ module( setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; + let features; let store; let controller; let getStorageBucketCount; @@ -36,6 +38,8 @@ module( hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); + features = this.owner.lookup('service:features'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/storage-buckets/index', @@ -95,5 +99,43 @@ module( assert.strictEqual(getStorageBucketCount(), storageBucketCount - 1); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + features.enable('ssh-session-recording'); + await visit(urls.storageBuckets); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.storage-bucket.messages.none.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + features.enable('ssh-session-recording'); + instances.scopes.global.authorized_collection_actions['storage-buckets'] = + ['create']; + await visit(urls.storageBuckets); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.storage-bucket.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + features.enable('ssh-session-recording'); + instances.scopes.global.authorized_collection_actions['storage-buckets'] = + []; + await visit(urls.storageBuckets); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.storage-bucket.title_plural'), + }), + ); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/index-test.js index 00405f6d8..2a8100d39 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/index-test.js @@ -18,6 +18,7 @@ module('Unit | Controller | scopes/scope/targets/index', function (hooks) { setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getTargetCount; @@ -44,6 +45,7 @@ module('Unit | Controller | scopes/scope/targets/index', function (hooks) { hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/targets/index'); @@ -286,4 +288,37 @@ module('Unit | Controller | scopes/scope/targets/index', function (hooks) { assert.strictEqual(target.egress_worker_filter, 'test'); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.targets); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.target.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scopes.project.authorized_collection_actions.targets = ['create']; + await visit(urls.targets); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.target.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scopes.project.authorized_collection_actions.targets = []; + await visit(urls.targets); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.target.title_plural'), + }), + ); + }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js index 507e186ad..5e47440da 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js @@ -17,6 +17,7 @@ module('Unit | Controller | scopes/scope/users/index', function (hooks) { setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getUserCount; @@ -35,6 +36,7 @@ module('Unit | Controller | scopes/scope/users/index', function (hooks) { hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/users/index'); @@ -105,4 +107,37 @@ module('Unit | Controller | scopes/scope/users/index', function (hooks) { assert.deepEqual(user.account_ids, []); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.users); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.user.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.users = ['create']; + await visit(urls.users); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('resources.user.title_plural'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.users = []; + await visit(urls.users); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('resources.user.title_plural'), + }), + ); + }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/workers/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/workers/index-test.js index c8d27d06b..8c445a160 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/workers/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/workers/index-test.js @@ -15,6 +15,7 @@ module('Unit | Controller | scopes/scope/workers/index', function (hooks) { setupMirage(hooks); setupIntl(hooks, 'en-us'); + let intl; let store; let controller; let getWorkerCount; @@ -33,6 +34,7 @@ module('Unit | Controller | scopes/scope/workers/index', function (hooks) { hooks.beforeEach(async function () { await authenticateSession({}); + intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/workers/index'); @@ -109,4 +111,39 @@ module('Unit | Controller | scopes/scope/workers/index', function (hooks) { assert.deepEqual(route.tags, []); }); + + test('messageDescription returns correct translation with list authorization', async function (assert) { + await visit(urls.workers); + + assert.strictEqual( + controller.messageDescription, + intl.t('resources.worker.description'), + ); + }); + + test('messageDescription returns correct translation with create authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.workers = [ + 'create:worker-led', + ]; + await visit(urls.workers); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.create-but-not-list', { + resource: intl.t('titles.workers'), + }), + ); + }); + + test('messageDescription returns correct translation with no authorization', async function (assert) { + instances.scopes.global.authorized_collection_actions.workers = []; + await visit(urls.workers); + + assert.strictEqual( + controller.messageDescription, + intl.t('descriptions.neither-list-nor-create', { + resource: intl.t('titles.workers'), + }), + ); + }); });