chore: Add new host set route

This commit is contained in:
Susmitha Girumala committed 2020-08-20 11:56:37 -04:00
1 parent b2aa10fd40
commit 7930d0e68c
12 files changed
+146 -31

No files matched your search

@@ -6,6 +6,12 @@
as |form|
>
<form.input
@value={{t (concat 'host-set.types.' @model.type)}}
@label={{t "form.label.type"}}
readonly={{true}}
@disabled={{true}} />
<form.input
@name="name"
@type="name"
+1
View File
@@ -53,6 +53,7 @@ Router.map(function () {
this.route('host-catalog', { path: ':host_catalog_id' }, function() {
this.route('host-sets', function() {
this.route('host-set', { path: ':host_set_id' }, function() {});
this.route('new');
});
});
});
@@ -28,7 +28,9 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRo
*/
@action
cancel(hostSet) {
const { isNew } = hostSet;
hostSet.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope.projects.project.host-catalogs.host-catalog.host-sets');
}
/**
@@ -39,9 +41,12 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRo
@action
async save(hostSet) {
try {
const { isNew } = hostSet;
await hostSet.save(this.adapterOptions());
this.refresh();
this.notify.success(this.intl.t('notify.save-success'));
this.notify.success(
this.intl.t(isNew ? 'notify.create-success' : 'notify.save-success')
);
this.transitionTo('scopes.scope.projects.project.host-catalogs.host-catalog.host-sets.host-set', hostSet);
} catch (error) {
// TODO: replace with translated strings
@@ -0,0 +1,46 @@
import Route from '@ember/routing/route';
export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsNewRoute extends Route {
// =methods
/**
* Creates a new unsaved host set in current host catalog scope.
* @return {HostCatalogModel}
*/
model() {
const scopeModel = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog');
return this.store.createRecord('host-set', {
type: 'static',
scopeModel
});
}
/**
* Renders new host-set specific templates for header, navigation, and action page sections.
* @override
* @param {object} controller
* @param {object} model
*/
renderTemplate(controller, model) {
this.render('scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/new');
this.render('scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/new/-header', {
into: 'scopes/scope/projects/project/host-catalogs/host-catalog',
outlet: 'header',
model: model
});
this.render('scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/new/-navigation', {
into: 'scopes/scope/projects/project/host-catalogs/host-catalog',
outlet: 'navigation',
model: model
});
this.render('scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/new/-actions', {
into: 'scopes/scope/projects/project/host-catalogs/host-catalog',
outlet: 'actions',
model: model
});
}
}
@@ -1,30 +1,50 @@
<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>
<LinkTo
@route="scopes.scope.projects.project.host-catalogs.host-catalog.host-sets.host-set"
@model={{hostSet}}
>
{{hostSet.displayName}}
</LinkTo>
<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>
{{#if @model}}
<Rose::LinkButton @style="ghost"
@iconLeft="plus-plain"
@route="scopes.scope.projects.project.host-catalogs.host-catalog.host-sets.new"
>
{{t "actions.add-host-set"}}
</Rose::LinkButton>
<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>
<LinkTo
@route="scopes.scope.projects.project.host-catalogs.host-catalog.host-sets.host-set"
@model={{hostSet}}
>
{{hostSet.displayName}}
</LinkTo>
<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>
{{else}}
<Rose::Layout::Centered>
<Rose::Message @title={{t "titles.host-sets-welcome"}} as |message|>
<message.description>
{{t "descriptions.host-sets-welcome"}}
</message.description>
<message.link @route="scopes.scope.projects.project.host-catalogs.host-catalog.host-sets.new">
<Rose::Icon @name="plus-circle-outline" />
{{t "titles.new"}}
</message.link>
</Rose::Message>
</Rose::Layout::Centered>
{{/if}}
@@ -0,0 +1,7 @@
{{title (t 'titles.new')}}
<Form::HostSet
@model={{@model}}
@submit={{route-action "save" @model}}
@cancel={{route-action "cancel" @model}}
/>
@@ -88,6 +88,18 @@ module('Acceptance | host sets', function (hooks) {
assert.expect(0);
});
test('can create new host set', async function (assert) {
assert.expect(0);
});
test('can cancel new host set creation', async function (assert) {
assert.expect(0);
});
test('saving a new host set with invalid fields displays error messages', async function (assert) {
assert.expect(0);
});
test('errors are displayed when save on auth method fails', async function (assert) {
assert.expect(0);
});
@@ -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/new', 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/new');
assert.ok(route);
});
});
+6
View File
@@ -15,6 +15,7 @@ actions:
delete-project: Delete project
delete-host-catalog: Delete host catalog
delete-host-set: Delete host set
add-host-set: Create Host Set
auth:
titles:
no-scopes: No Scopes Available
@@ -26,6 +27,9 @@ auth:
authenticating-with-org: "You're authenticating with {name}."
method-types:
password: Password
host-set:
types:
static: Static
resources:
user: User
users: Users
@@ -54,6 +58,7 @@ titles:
empty-set: No Items Yet
projects-welcome: Welcome to Projects
host-catalogs-welcome: Welcome to Host Catalogs
host-sets-welcome: Welcome to Host Sets
users-welcome: Welcome to Users
roles-welcome: Welcome to Roles
groups-welcome: Welcome to Groups
@@ -68,6 +73,7 @@ descriptions:
empty-set: There are no items to display yet. You may be able to add items or try back later.
projects-welcome: Projects allow you to create and manage host catalogs. To start, create a project.
host-catalogs-welcome: Host catalogs allow you to configure to collect and create hosts and host sets. To start, create a host catalog.
host-sets-welcome: Configure a static host set in this host catalog.
users-welcome: Users are authorized to access Boundary.
roles-welcome: Roles are collections of capabilities that can be granted to user and/or groups.
groups-welcome: Groups are collections of users.