feat: 🎸 Add links to Host Sets assigned to targets (#1434)
* feat: 🎸 Add links to Host Sets assigned to targets The target host sources view can now link to the host sets associated with that target ✅ Closes: ICU-6525 * test: 💍 Improve test assert for host sources links
This commit is contained in:
1 parent
dfe3aee450
commit
5e7e11fc6b
3 files changed
+57
-2
No files matched your search
@@ -3,7 +3,7 @@ import ModelAbility from './model';
|
||||
/**
|
||||
* Provides abilities for host sets.
|
||||
*/
|
||||
export default class UserAbility extends ModelAbility {
|
||||
export default class HostSetAbility extends ModelAbility {
|
||||
// =permissions
|
||||
|
||||
/**
|
||||
@@ -19,4 +19,11 @@ export default class UserAbility extends ModelAbility {
|
||||
get canRemoveHosts() {
|
||||
return this.hasAuthorizedAction('remove-hosts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
get canRead() {
|
||||
return !this.model.isUnknown && this.hasAuthorizedAction('read');
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,19 @@
|
||||
{{#each @model.hostSets as |hostSet|}}
|
||||
<body.row as |row|>
|
||||
<row.headerCell>
|
||||
{{hostSet.model.displayName}}
|
||||
{{#if (can 'read host-set' hostSet.model)}}
|
||||
<LinkTo
|
||||
@route='scopes.scope.host-catalogs.host-catalog.host-sets.host-set'
|
||||
@models={{array
|
||||
hostSet.model.host_catalog_id
|
||||
hostSet.model.id
|
||||
}}
|
||||
>
|
||||
{{hostSet.model.displayName}}
|
||||
</LinkTo>
|
||||
{{else}}
|
||||
{{hostSet.model.displayName}}
|
||||
{{/if}}
|
||||
<p>{{hostSet.model.description}}</p>
|
||||
</row.headerCell>
|
||||
<row.cell>
|
||||
|
||||
@@ -50,6 +50,16 @@ module('Acceptance | targets | host-sources', function (hooks) {
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
// creates "unknown" host-sets for target host sources
|
||||
instances.hostCatalogPlugin = this.server.create(
|
||||
'host-catalog',
|
||||
{
|
||||
type: 'plugin',
|
||||
plugin: { name: 'shh' },
|
||||
scope: instances.scopes.project,
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
instances.target = this.server.create('target', {
|
||||
scope: instances.scopes.project,
|
||||
hostSets: instances.hostCatalog.hostSets,
|
||||
@@ -62,6 +72,8 @@ module('Acceptance | targets | host-sources', function (hooks) {
|
||||
urls.target = `${urls.targets}/${instances.target.id}`;
|
||||
urls.targetHostSources = `${urls.target}/host-sources`;
|
||||
urls.targetAddHostSources = `${urls.target}/add-host-sources`;
|
||||
urls.hostSet = `${urls.projectScope}/host-catalogs/${instances.hostCatalog.id}/host-sets/${instances.hostCatalog.hostSetIds[0]}`;
|
||||
urls.unknownHostSet = `${urls.projectScope}/host-catalogs/${instances.hostCatalogPlugin.id}/host-sets/${instances.hostCatalogPlugin.hostSetIds[0]}`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
@@ -75,6 +87,30 @@ module('Acceptance | targets | host-sources', function (hooks) {
|
||||
assert.strictEqual(findAll('tbody tr').length, targetHostSetCount);
|
||||
});
|
||||
|
||||
test('can navigate to a known host set type', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.targetHostSources);
|
||||
await click(
|
||||
`main tbody .rose-table-header-cell:nth-child(1) a[href="${urls.hostSet}"]`
|
||||
);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.hostSet);
|
||||
});
|
||||
|
||||
test('cannot navigate to an unknown host set type', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.target.update({
|
||||
hostSets: instances.hostCatalogPlugin.hostSets,
|
||||
});
|
||||
|
||||
await visit(urls.targetHostSources);
|
||||
assert
|
||||
.dom(
|
||||
`main tbody .rose-table-header-cell:nth-child(1) a [href="${urls.unknownHostSet}"]`
|
||||
)
|
||||
.doesNotExist();
|
||||
});
|
||||
|
||||
test('can remove a host set', async function (assert) {
|
||||
assert.expect(2);
|
||||
const targetHostSetCount = instances.target.hostSets.length;
|
||||
|
||||
Reference in new issue
Block a user