Skip to content

Commit

Permalink
refactor: 💡 pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lisbet-alvarez committed Dec 17, 2024
1 parent 43eabbc commit ee9b67f
Show file tree
Hide file tree
Showing 17 changed files with 221 additions and 214 deletions.
23 changes: 13 additions & 10 deletions ui/admin/app/controllers/scopes/scope/aliases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 13 additions & 16 deletions ui/admin/app/controllers/scopes/scope/auth-methods/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 13 additions & 16 deletions ui/admin/app/controllers/scopes/scope/credential-stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 13 additions & 10 deletions ui/admin/app/controllers/scopes/scope/groups/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit ee9b67f

Please sign in to comment.