chore: List host-sets for a host-catalog

This commit is contained in:
Susmitha Girumala committed 2020-08-17 15:15:12 -04:00
1 parent 55a59559ff
commit c856d8cf72
8 files changed
+170 -38

No files matched your search

+3 -1
View File
@@ -31,7 +31,9 @@ Router.map(function () {
this.route('project', { path: ':project_id' }, function() {
this.route('host-catalogs', function() {
this.route('new');
this.route('host-catalog', { path: ':host_catalog_id' }, function() {});
this.route('host-catalog', { path: ':host_catalog_id' }, function() {
this.route('host-sets');
});
});
});
this.route('new');
@@ -0,0 +1,13 @@
import Route from '@ember/routing/route';
export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRoute extends Route {
/**
* Loads all host-sets under the current scope and host catalog.
* @return {Promise{[HostSetModel]}}
*/
async model() {
const scopeID = this.modelFor('scopes.scope.projects.project').id;
const hostCatalogID = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog').id;
return this.store.findAll('host-set', { adapterOptions: { scopeID, hostCatalogID } });
}
}
@@ -1,3 +1,26 @@
{{title @model.displayName}}
<Rose::Layout::Page as |page|>
{{outlet}}
<page.breadcrumbs>
<BreadCrumbs />
</page.breadcrumbs>
<page.header>
<h2>{{t "resources.host-catalog"}}</h2>
</page.header>
<page.navigation>
<Rose::Nav::Tabs as |nav|>
<nav.link @route='scopes.scope.projects.project.host-catalogs.host-catalog.index'>
{{t 'titles.details'}}
</nav.link>
<nav.link @route='scopes.scope.projects.project.host-catalogs.host-catalog.host-sets'>
{{t 'titles.host-sets'}}
</nav.link>
</Rose::Nav::Tabs>
</page.navigation>
<page.body>
{{outlet}}
</page.body>
</Rose::Layout::Page>
@@ -0,0 +1,25 @@
<Rose::Table as |table|>
<table.header as |header|>
<header.row as |row|>
<row.cell>{{t "form.label.name"}}</row.cell>
<row.cell>{{t "form.label.type"}}</row.cell>
<row.cell>{{t "form.label.id"}}</row.cell>
</header.row>
</table.header>
<table.body as |body|>
{{#each @model as |hostSet|}}
<body.row as |row|>
<row.cell>
{{hostSet.displayName}}
<p>{{hostSet.description}}</p>
</row.cell>
<row.cell>
<Rose::Badge @style="outline">{{hostSet.type}}</Rose::Badge>
</row.cell>
<row.cell>
<code>{{hostSet.id}}</code>
</row.cell>
</body.row>
{{/each}}
</table.body>
</Rose::Table>
@@ -1,35 +1,13 @@
<Rose::Layout::Page as |page|>
<page.breadcrumbs>
<BreadCrumbs />
</page.breadcrumbs>
<page.header>
<h2>{{t "resources.host-catalog"}}</h2>
</page.header>
<page.navigation>
<Rose::Nav::Tabs as |nav|>
<nav.link @route='scopes.scope.projects.project.host-catalogs.host-catalog'>
{{t 'titles.details'}}
</nav.link>
</Rose::Nav::Tabs>
</page.navigation>
<page.body>
<Form::HostCatalog
@model={{@model}}
@submit={{route-action "save" @model}}
@cancel={{route-action "cancel" @model}}
/>
<Rose::Separator />
<Rose::Button
@style="warning"
@disabled={{@model.canSave}}
{{on "click" (route-action "delete" @model)}}
>
{{t 'actions.delete'}}
</Rose::Button>
</page.body>
</Rose::Layout::Page>
<Form::HostCatalog
@model={{@model}}
@submit={{route-action "save" @model}}
@cancel={{route-action "cancel" @model}}
/>
<Rose::Separator />
<Rose::Button
@style="warning"
@disabled={{@model.canSave}}
{{on "click" (route-action "delete" @model)}}
>
{{t 'actions.delete'}}
</Rose::Button>
@@ -0,0 +1,78 @@
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import a11yAudit from 'ember-a11y-testing/test-support/audit';
import {
authenticateSession,
// These are left here intentionally for future reference.
//currentSession,
//invalidateSession,
} from 'ember-simple-auth/test-support';
module('Acceptance | host sets', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
const instances = {
scopes: {
global: null,
org: null,
project: null,
hostCatalog: null
},
hostSet: null
};
const urls = {
orgScope: null,
projects: null,
project: null,
hostCatalogs: null,
hostCatalog: null,
hostSets: null
};
hooks.beforeEach(function () {
// Setup Mirage mock resources for this test
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', { type: 'org',
scope: { id: instances.scopes.global.id, type: instances.scopes.global.type }
});
instances.scopes.project = this.server.create('scope', { type: 'project',
scope: { id: instances.scopes.org.id, type: instances.scopes.org.type }
});
instances.scopes.hostCatalog = this.server.create('host-catalog', {
scope: {
id: instances.scopes.project.id,
type: instances.scopes.project.type
}
});
instances.hostSet = this.server.create('host-set', {
scope: {
id: instances.scopes.project.id,
type: instances.scopes.project.type
},
hostCatalog: {
id: instances.scopes.hostCatalog.id,
type: instances.scopes.hostCatalog.type
}
});
// Generate route URLs for resources
urls.orgScope = `/scopes/${instances.scopes.org.id}`;
urls.projects = `${urls.orgScope}/projects`;
urls.project = `${urls.projects}/${instances.scopes.hostCatalog.scope.id}`;
urls.hostCatalogs = `${urls.project}/host-catalogs`;
urls.hostCatalog = `${urls.hostCatalogs}/${instances.scopes.hostCatalog.id}`;
urls.hostSets = `${urls.hostCatalog}/host-sets`;
});
test('visiting host sets', async function (assert) {
assert.expect(1);
authenticateSession();
await visit(urls.hostSets);
await a11yAudit();
assert.equal(currentURL(), urls.hostSets);
});
});
@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Route | scopes/scope/projects/project/host-catalogs/host-catalog/host-sets', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
let route = this.owner.lookup('route:scopes/scope/projects/project/host-catalogs/host-catalog/host-sets');
assert.ok(route);
});
});
+2
View File
@@ -33,6 +33,7 @@ resources:
host-catalogs: Host Catalogs
auth-method: Auth Method
auth-methods: Auth Methods
host-sets: Host Sets
titles:
iam: IAM
new: New
@@ -51,6 +52,7 @@ titles:
grants: Permissions
new-grant: New Grant
principals: Principals
host-sets: Host Sets
descriptions:
host-catalogs: Overview of collections of hosts and host sets.
empty-set: There are no items to display yet. You may be able to add items or try back later.