diff --git a/ui/admin/app/controllers/scopes/scope/aliases/index.js b/ui/admin/app/controllers/scopes/scope/aliases/index.js index 5e739db7d7..ef39cf83af 100644 --- a/ui/admin/app/controllers/scopes/scope/aliases/index.js +++ b/ui/admin/app/controllers/scopes/scope/aliases/index.js @@ -34,19 +34,22 @@ export default class ScopesScopeAliasesIndexController extends Controller { * @type {string} */ get messageDescription() { - let description; - if (this.can.can('list model', this.scope, { collection: 'aliases' })) { + 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 ( - this.can.can('create model', this.scope, { collection: 'aliases' }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.alias.title_plural'), - }); + + 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 f3ab237b1c..69f90fd36a 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 @@ -28,21 +28,22 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsIndexController ext * @type {string} */ get messageDescription() { - let description; - if ( - this.can.can('list model', this.authMethod, { collection: 'accounts' }) - ) { + 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 ( - this.can.can('create model', this.authMethod, { collection: 'accounts' }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.account.title_plural'), - }); + + 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 bd93dd06c2..1361bca8b4 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 @@ -28,25 +28,22 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsIndexControlle * @type {string} */ get messageDescription() { - let description; - if ( - this.can.can('list model', this.authMethod, { - collection: 'managed-groups', - }) - ) { + 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 ( - this.can.can('create model', this.authMethod, { - collection: 'managed-groups', - }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.managed-group.title_plural'), - }); + + 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 18a59dc268..545cf6a6ca 100644 --- a/ui/admin/app/controllers/scopes/scope/auth-methods/index.js +++ b/ui/admin/app/controllers/scopes/scope/auth-methods/index.js @@ -79,25 +79,22 @@ export default class ScopesScopeAuthMethodsIndexController extends Controller { * @type {string} */ get messageDescription() { - let description; - if ( - this.can.can('list model', this.scopeModel, { - collection: 'auth-methods', - }) - ) { + 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 ( - this.can.can('create model', this.scopeModel, { - collection: 'auth-methods', - }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.auth-method.title_plural'), - }); + + 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 b12e17f486..6a1bad0b2d 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 @@ -28,25 +28,22 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari * @type {string} */ get messageDescription() { - let description; - if ( - this.can.can('list model', this.credentialStore, { - collection: 'credential-libraries', - }) - ) { + 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 ( - this.can.can('create model', this.credentialStore, { - collection: 'credential-libraries', - }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.credential-library.title_plural'), - }); + + 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 17b0c7251c..49952fbcee 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 @@ -28,25 +28,22 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsIndexC * @type {string} */ get messageDescription() { - let description; - if ( - this.can.can('list model', this.credentialStore, { - collection: 'credentials', - }) - ) { + 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 ( - this.can.can('create model', this.credentialStore, { - collection: 'credentials', - }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.credential.title_plural'), - }); + + 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 3998b7a685..0989443bc9 100644 --- a/ui/admin/app/controllers/scopes/scope/credential-stores/index.js +++ b/ui/admin/app/controllers/scopes/scope/credential-stores/index.js @@ -50,25 +50,22 @@ export default class ScopesScopeCredentialStoresIndexController extends Controll * @type {string} */ get messageDescription() { - let description; - if ( - this.can.can('list model', this.scope, { - collection: 'credential-stores', - }) - ) { + 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 ( - this.can.can('create model', this.scope, { - collection: 'credential-stores', - }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.credential-store.title_plural'), - }); + + 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 e4e875a80c..a428848e07 100644 --- a/ui/admin/app/controllers/scopes/scope/groups/index.js +++ b/ui/admin/app/controllers/scopes/scope/groups/index.js @@ -34,19 +34,22 @@ export default class ScopesScopeGroupsIndexController extends Controller { * @type {string} */ get messageDescription() { - let description; - if (this.can.can('list model', this.scope, { collection: 'groups' })) { + 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 ( - this.can.can('create model', this.scope, { collection: 'groups' }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.group.title_plural'), - }); + + 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 fb1415be17..862d5299ee 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 @@ -28,23 +28,22 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsIndexController e * @type {string} */ get messageDescription() { - let description; - if ( - this.can.can('list model', this.hostCatalog, { collection: 'host-sets' }) - ) { + 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 ( - this.can.can('create model', this.hostCatalog, { - collection: 'host-sets', - }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.host-set.title_plural'), - }); + + 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 a39b354fdd..e32f7e7ea4 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 @@ -28,19 +28,22 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsIndexController exte * @type {string} */ get messageDescription() { - let description; - if (this.can.can('list model', this.hostCatalog, { collection: 'hosts' })) { + 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 ( - this.can.can('create model', this.hostCatalog, { collection: 'hosts' }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.host.title_plural'), - }); + + 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 2760de6009..d14174c288 100644 --- a/ui/admin/app/controllers/scopes/scope/host-catalogs/index.js +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/index.js @@ -35,21 +35,22 @@ export default class ScopesScopeHostCatalogsIndexController extends Controller { * @type {string} */ get messageDescription() { - let description; - if ( - this.can.can('list model', this.scope, { collection: 'host-catalogs' }) - ) { + 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 ( - this.can.can('create model', this.scope, { collection: 'host-catalogs' }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.host-catalog.title_plural'), - }); + + 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 f48a7f3e6e..e6d8a69fc5 100644 --- a/ui/admin/app/controllers/scopes/scope/policies/index.js +++ b/ui/admin/app/controllers/scopes/scope/policies/index.js @@ -26,19 +26,22 @@ export default class ScopesScopePoliciesIndexController extends Controller { * @type {string} */ get messageDescription() { - let description; - if (this.can.can('list model', this.scope, { collection: 'policies' })) { + 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 ( - this.can.can('create model', this.scope, { collection: 'policies' }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.policy.title_plural'), - }); + + 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 352f399849..d569b670a5 100644 --- a/ui/admin/app/controllers/scopes/scope/roles/index.js +++ b/ui/admin/app/controllers/scopes/scope/roles/index.js @@ -37,19 +37,22 @@ export default class ScopesScopeRolesIndexController extends Controller { * @type {string} */ get messageDescription() { - let description; - if (this.can.can('list model', this.scope, { collection: 'roles' })) { + 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 ( - this.can.can('create model', this.scope, { collection: 'roles' }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.role.title_plural'), - }); + + 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 5601508480..7c66efcb2e 100644 --- a/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js +++ b/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js @@ -26,23 +26,22 @@ export default class ScopesScopeStorageBucketsIndexController extends Controller * @type {string} */ get messageDescription() { - let description; - if ( - this.can.can('list scope', this.scope, { collection: 'storage-buckets' }) - ) { + 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 ( - this.can.can('create scope', this.scope, { - collection: 'storage-buckets', - }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.storage-bucket.title_plural'), - }); + + 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 1ece1864fb..e8b6a1903d 100644 --- a/ui/admin/app/controllers/scopes/scope/targets/index.js +++ b/ui/admin/app/controllers/scopes/scope/targets/index.js @@ -79,19 +79,22 @@ export default class ScopesScopeTargetsIndexController extends Controller { * @type {string} */ get messageDescription() { - let description; - if (this.can.can('list model', this.scope, { collection: 'targets' })) { + 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 ( - this.can.can('create model', this.scope, { collection: 'targets' }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.target.title_plural'), - }); + + 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 bfb62d2672..38d5bb8292 100644 --- a/ui/admin/app/controllers/scopes/scope/users/index.js +++ b/ui/admin/app/controllers/scopes/scope/users/index.js @@ -34,19 +34,22 @@ export default class ScopesScopeUsersIndexController extends Controller { * @type {string} */ get messageDescription() { - let description; - if (this.can.can('list model', this.scope, { collection: 'users' })) { + 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 ( - this.can.can('create model', this.scope, { collection: 'users' }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('resources.user.title_plural'), - }); + + 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 7ddbd47ce0..6ba090f11a 100644 --- a/ui/admin/app/controllers/scopes/scope/workers/index.js +++ b/ui/admin/app/controllers/scopes/scope/workers/index.js @@ -29,21 +29,22 @@ export default class ScopesScopeWorkersIndexController extends Controller { * @type {string} */ get messageDescription() { - let description; - if (this.can.can('list worker', this.scope, { collection: 'workers' })) { + 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 ( - this.can.can('create worker led worker', this.scope, { - collection: 'workers', - }) - ) { + } else if (canCreate) { description = 'descriptions.create-but-not-list'; - } else { - description = 'descriptions.neither-list-nor-create'; } - return this.intl.t(description, { - resource: this.intl.t('titles.workers'), - }); + + return this.intl.t(description, { resource }); } /**