chore: 🤖 disallow catalog -> host list for dynamic catalogs

This commit is contained in:
Randall Morey committed 2022-02-02 17:38:57 -05:00
1 parent a7bf8008a7
commit dd1d211d41
2 files changed
+19 -2

No files matched your search

+17
View File
@@ -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);
}
}
@@ -2,12 +2,12 @@
<nav.link @route='scopes.scope.host-catalogs.host-catalog.index'>
{{t 'titles.details'}}
</nav.link>
{{#if (can 'navigate model' @model collection='hosts')}}
{{#if (can 'navigate host-catalog' @model collection='hosts')}}
<nav.link @route='scopes.scope.host-catalogs.host-catalog.hosts'>
{{t 'resources.host.title_plural'}}
</nav.link>
{{/if}}
{{#if (can 'navigate model' @model collection='host-sets')}}
{{#if (can 'navigate host-catalog' @model collection='host-sets')}}
<nav.link @route='scopes.scope.host-catalogs.host-catalog.host-sets'>
{{t 'resources.host-set.title_plural'}}
</nav.link>