chore: 🤖 add new host catalog flow
This commit is contained in:
6 files changed
+117
-19
No files matched your search
@@ -13,6 +13,7 @@ Router.map(function () {
|
||||
this.route('project', { path: ':project_id' }, function() {
|
||||
this.route('host-catalogs', function() {
|
||||
this.route('host-catalog', { path: ':host_catalog_id' }, function() {});
|
||||
this.route('new');
|
||||
});
|
||||
});
|
||||
this.route('new');
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class OrgsOrgProjectsProjectHostCatalogsNewRoute extends Route {
|
||||
// =services
|
||||
|
||||
@service notify;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Returns a new unsaved host catalog.
|
||||
* @return {Promise{HostCatalogModel}}
|
||||
*/
|
||||
model() {
|
||||
return this.store.createRecord('hostCatalog');
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
* Rollback changes on host catalog (which destroys unsaved instances)
|
||||
* and redirects to host catalogs index.
|
||||
* @param {HostCatalogModel} hostCatalog
|
||||
*/
|
||||
@action
|
||||
cancel(hostCatalog) {
|
||||
hostCatalog.rollbackAttributes();
|
||||
this.transitionTo('orgs.org.projects.project.host-catalogs');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle save host catalog.
|
||||
* @param {HostCatalogModel} hostCatalog
|
||||
* @param {Event} e
|
||||
*/
|
||||
@action
|
||||
async save(hostCatalog) {
|
||||
try {
|
||||
await hostCatalog.save();
|
||||
this.transitionTo('orgs.org.projects.project.host-catalogs.host-catalog', hostCatalog);
|
||||
// TODO: replace with translated strings
|
||||
this.notify.success('Host catalog created.');
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,30 @@
|
||||
<div class="projects-overview">
|
||||
<Rose::Layout::Page as |page|>
|
||||
|
||||
<h2>{{t "resources.host-catalogs"}}</h2>
|
||||
<page.header>
|
||||
<h2>{{t "resources.host-catalogs"}}</h2>
|
||||
</page.header>
|
||||
|
||||
<ul>
|
||||
{{#each @model as |hostCatalog|}}
|
||||
<li>
|
||||
<LinkTo
|
||||
@route="orgs.org.projects.project.host-catalogs.host-catalog"
|
||||
@model={{hostCatalog}}
|
||||
>
|
||||
{{hostCatalog.name}}
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
<page.actions>
|
||||
<LinkTo
|
||||
@route="orgs.org.projects.project.host-catalogs.new"
|
||||
>
|
||||
{{t 'titles.new'}}
|
||||
</LinkTo>
|
||||
</page.actions>
|
||||
|
||||
</div>
|
||||
<page.body>
|
||||
<ul>
|
||||
{{#each @model as |hostCatalog|}}
|
||||
<li>
|
||||
<LinkTo
|
||||
@route="orgs.org.projects.project.host-catalogs.host-catalog"
|
||||
@model={{hostCatalog}}
|
||||
>
|
||||
{{hostCatalog.name}}
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</page.body>
|
||||
|
||||
</Rose::Layout::Page>
|
||||
@@ -0,0 +1,14 @@
|
||||
<Rose::Layout::Page as |page|>
|
||||
|
||||
<page.header>
|
||||
<h2>{{t "titles.new"}}</h2>
|
||||
</page.header>
|
||||
|
||||
<page.body>
|
||||
<Form::HostCatalog
|
||||
@model={{@model}}
|
||||
@submit={{route-action "save" @model}}
|
||||
@cancel={{route-action "cancel" @model}} />
|
||||
</page.body>
|
||||
|
||||
</Rose::Layout::Page>
|
||||
@@ -1,13 +1,23 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
//import { render } from '@ember/test-helpers';
|
||||
//import { hbs } from 'ember-cli-htmlbars';
|
||||
import { render, find } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Component | form/host-catalog', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function(assert) {
|
||||
assert.expect(0);
|
||||
// TODO
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.set('myAction', function(val) { ... });
|
||||
this.submit = () => {};
|
||||
this.cancel = () => {};
|
||||
|
||||
await render(hbs`
|
||||
<Form::HostCatalog
|
||||
@submit={{this.submit}}
|
||||
@cancel={{this.cancel}}
|
||||
/>`);
|
||||
|
||||
assert.ok(find('form'));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | orgs/org/projects/project/host-catalogs/new', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:orgs/org/projects/project/host-catalogs/new');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user