From dd1d211d410acaa2a79074348daa56a1900729b6 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 2 Feb 2022 17:38:57 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20disallow=20catalog=20->?= =?UTF-8?q?=20host=20list=20for=20dynamic=20catalogs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/app/abilities/host-catalog.js | 17 +++++++++++++++++ .../host-catalogs/host-catalog/-navigation.hbs | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 ui/admin/app/abilities/host-catalog.js diff --git a/ui/admin/app/abilities/host-catalog.js b/ui/admin/app/abilities/host-catalog.js new file mode 100644 index 000000000..9c6805a8a --- /dev/null +++ b/ui/admin/app/abilities/host-catalog.js @@ -0,0 +1,17 @@ +import HostCatalogAbility from 'api/abilities/host-catalog'; + +export default class OverrideHostCatalogAbility extends HostCatalogAbility { + /** + * Navigating to a resource is allowed if either list or create grants + * are present, except in the following case. Navigating to hosts directly + * from a dynamic host catalog is not allowed, since this might present more + * hosts than is practical or useful. + * @type {boolean} + */ + get canNavigate() { + const { isPlugin } = this.model; + const isHostsCollection = this.collection === 'hosts'; + const isDynamicHostsNavigation = isPlugin && isHostsCollection; + return !isDynamicHostsNavigation && (this.canList || this.canCreate); + } +} diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/-navigation.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/-navigation.hbs index d16d10efb..8feffd7dd 100644 --- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/-navigation.hbs +++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/-navigation.hbs @@ -2,12 +2,12 @@ {{t 'titles.details'}} - {{#if (can 'navigate model' @model collection='hosts')}} + {{#if (can 'navigate host-catalog' @model collection='hosts')}} {{t 'resources.host.title_plural'}} {{/if}} - {{#if (can 'navigate model' @model collection='host-sets')}} + {{#if (can 'navigate host-catalog' @model collection='host-sets')}} {{t 'resources.host-set.title_plural'}}