chore: add initial host catalogs index
This commit is contained in:
17 files changed
+228
-14
No files matched your search
@@ -14,7 +14,12 @@ Router.map(function () {
|
||||
this.route('method', { path: ':auth_method_id'});
|
||||
});
|
||||
this.route('projects', function() {
|
||||
this.route('project', { path: ':project_id' }, 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('new');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class ScopesScopeProjectsProjectHostCatalogsRoute extends Route {
|
||||
|
||||
// =services
|
||||
|
||||
@service notify;
|
||||
|
||||
// =methods
|
||||
|
||||
|
||||
/**
|
||||
* Loads all scopes under the current scope.
|
||||
* @return {Promise{[HostCatalogModel]}}
|
||||
*/
|
||||
async model() {
|
||||
const scopeID = this.modelFor('scopes.scope.projects.project').id;
|
||||
return this.store.findAll('host-catalog', { adapterOptions: { scopeID } });
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
* Rollback changes on project.
|
||||
* @param {HostCatalogModel} hostCatalog
|
||||
*/
|
||||
@action
|
||||
cancel(hostCatalog) {
|
||||
const { isNew } = hostCatalog;
|
||||
hostCatalog.rollbackAttributes();
|
||||
if (isNew) this.transitionTo('scopes.scope.projects.project.host-catalogs');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle save.
|
||||
* @param {HostCatalogModel} hostCatalog
|
||||
* @param {Event} e
|
||||
*/
|
||||
@action
|
||||
async save(hostCatalog) {
|
||||
try {
|
||||
await hostCatalog.save();
|
||||
this.refresh();
|
||||
// TODO: replace with translated strings
|
||||
this.notify.success('Save succeeded.');
|
||||
this.transitionTo('scopes.scope.projects.project.host-catalogs.host-catalog', hostCatalog);
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the host catalog and redirects to index.
|
||||
* @param {ProjectModel} project
|
||||
*/
|
||||
@action
|
||||
async delete(project) {
|
||||
try {
|
||||
await project.destroyRecord();
|
||||
this.refresh();
|
||||
this.transitionTo('scopes.scope.projects.project.host-catalogs');
|
||||
// TODO: replace with translated strings
|
||||
this.notify.success('Deleted host catalog succesfully.');
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogRoute extends Route {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogIndexRoute extends Route {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeProjectsProjectHostCatalogsIndexRoute extends Route {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeProjectsProjectHostCatalogsNewRoute extends Route {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{{title (t "resources.host-catalogs")}}
|
||||
|
||||
{{outlet}}
|
||||
@@ -0,0 +1 @@
|
||||
{{outlet}}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{{outlet}}
|
||||
@@ -0,0 +1,68 @@
|
||||
<Rose::Layout::Page as |page|>
|
||||
|
||||
<page.breadcrumbs>
|
||||
<BreadCrumbs />
|
||||
</page.breadcrumbs>
|
||||
|
||||
<page.header>
|
||||
<h2>{{t "resources.host-catalogs"}}</h2>
|
||||
<p>{{t "descriptions.host-catalogs"}}</p>
|
||||
</page.header>
|
||||
|
||||
<page.actions>
|
||||
{{#if @model}}
|
||||
<Rose::LinkButton @route="scopes.scope.projects.project.host-catalogs.new" @style="primary">
|
||||
{{t "titles.new"}}
|
||||
</Rose::LinkButton>
|
||||
{{/if}}
|
||||
</page.actions>
|
||||
|
||||
<page.body>
|
||||
|
||||
{{#if @model}}
|
||||
|
||||
<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.description"}}</row.cell>
|
||||
</header.row>
|
||||
</table.header>
|
||||
<table.body as |body|>
|
||||
{{#each @model as |hostCatalog|}}
|
||||
<body.row as |row|>
|
||||
<row.cell>
|
||||
<LinkTo
|
||||
@route="scopes.scope.projects.project.host-catalogs.host-catalog"
|
||||
@model={{hostCatalog}}
|
||||
>
|
||||
{{hostCatalog.name}}
|
||||
</LinkTo>
|
||||
</row.cell>
|
||||
<row.cell>{{hostCatalog.type}}</row.cell>
|
||||
<row.cell>{{hostCatalog.description}}</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
</table.body>
|
||||
</Rose::Table>
|
||||
|
||||
{{else}}
|
||||
|
||||
<Rose::Layout::Centered>
|
||||
<Rose::Message @title={{t "titles.host-catalogs-welcome"}} as |message|>
|
||||
<message.description>
|
||||
{{t "descriptions.host-catalogs-welcome"}}
|
||||
</message.description>
|
||||
<message.link @route="scopes.scope.projects.project.host-catalogs.new">
|
||||
<Rose::Icon @name="plus-circle-outline" />
|
||||
{{t "titles.new"}}
|
||||
</message.link>
|
||||
</Rose::Message>
|
||||
</Rose::Layout::Centered>
|
||||
|
||||
{{/if}}
|
||||
|
||||
</page.body>
|
||||
|
||||
</Rose::Layout::Page>
|
||||
@@ -0,0 +1 @@
|
||||
{{outlet}}
|
||||
@@ -7,20 +7,8 @@ export default function(server) {
|
||||
type: 'org',
|
||||
scope: { id: globalScope.id, type: globalScope.type }
|
||||
}, 'withChildren');
|
||||
|
||||
const scope = { id: orgScope.id, type: orgScope.type };
|
||||
|
||||
// Create additional scopes for authentication organization selection
|
||||
server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: globalScope.id, type: globalScope.type }
|
||||
}, 'withChildren');
|
||||
|
||||
server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: globalScope.id, type: globalScope.type }
|
||||
}, 'withChildren');
|
||||
|
||||
// Auth
|
||||
|
||||
// Auth methods exist both at the global scope and the org scope.
|
||||
@@ -38,6 +26,9 @@ export default function(server) {
|
||||
|
||||
// Other resources
|
||||
|
||||
server.createList('host-catalog', 6);
|
||||
server.db.scopes.where({type: 'project'}).forEach(projectScope => {
|
||||
const scope = { id: projectScope.id, type: projectScope.type };
|
||||
server.createList('host-catalog', 2, { scope });
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/projects/project/host-catalogs', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/project/host-catalogs');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
+11
@@ -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', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/project/host-catalogs/host-catalog');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
+11
@@ -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/index', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/project/host-catalogs/host-catalog/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/projects/project/host-catalogs/index', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/project/host-catalogs/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/projects/project/host-catalogs/new', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/project/host-catalogs/new');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user