Merge pull request #168 from hashicorp/ICU-549-add-address-to-static-host

Add address textfield to static host form
This commit is contained in:
Randall Morey authored and GitHub committed 2020-09-10 15:40:46 -04:00
commit 4dfd9dd658
10 files changed
+56 -7

No files matched your search

@@ -35,8 +35,4 @@ export default class GeneratedHostModel extends BaseModel {
})
version;
@attr('string', {
description: 'The address (DNS or IP name) used to reach the host'
}) address;
}
@@ -0,0 +1,9 @@
import Fragment from 'ember-data-model-fragments/fragment';
import { attr } from '@ember-data/model';
export default class FragmentHostAttributesModel extends Fragment {
@attr('string', {
description: 'The address (DNS or IP name) used to reach the host'
}) address;
}
+10 -1
View File
@@ -1,3 +1,12 @@
import GeneratedHostModel from '../generated/models/host';
import { fragment } from 'ember-data-model-fragments/attributes';
export default class HostModel extends GeneratedHostModel {}
export default class HostModel extends GeneratedHostModel {
/**
* Attributes of this resource, if any, represented as a JSON fragment.
* @type {FragmentHostAttributesModel}
*/
@fragment('fragment-host-attributes', { defaultValue: {} }) attributes;
}
@@ -0,0 +1 @@
export { default } from 'api/models/fragment-host-attributes';
+11
View File
@@ -10,4 +10,15 @@ module('Unit | Model | host', function(hooks) {
let model = store.createRecord('host', {});
assert.ok(model);
});
test('it contains attributes', function(assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('host', {
type: 'static',
attributes: {
address: '127.0.0.1'
}
});
assert.equal(model.attributes.address, '127.0.0.1');
});
});
@@ -41,7 +41,7 @@
onChange={{fn @toggleHost option.host}} />
</row.cell>
<row.cell>{{option.host.name}}</row.cell>
<row.cell>{{option.host.address}}</row.cell>
<row.cell>{{option.host.attributes.address}}</row.cell>
</body.row>
{{/each}}
</table.body>
@@ -47,6 +47,24 @@
{{/if}}
</form.textarea>
<form.input
@name="address"
@type="text"
@value={{@model.attributes.address}}
@label={{t "form.label.address"}}
@error={{@model.errors.name}}
readonly={{false}}
as |field|>
{{#if @model.errors.name}}
<field.errors as |errors|>
{{#each @model.errors.name as |error|}}
<errors.message>{{error.message}}</errors.message>
{{/each}}
</field.errors>
{{/if}}
</form.input>
<form.actions
@disabled={{if @model.cannotSave @model.cannotSave}}
@submitText={{t "actions.save"}}
@@ -13,6 +13,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostsHostR
const { id: scopeID } = this.modelFor('scopes.scope.projects.project');
const hostCatalogID = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog').id;
return this.store.findRecord('host', host_id, {
reload: true,
adapterOptions: { scopeID, hostCatalogID }
});
}
@@ -6,6 +6,7 @@
<row.headerCell>{{t "form.label.name"}}</row.headerCell>
<row.headerCell>{{t "form.label.type"}}</row.headerCell>
<row.headerCell>{{t "form.label.id"}}</row.headerCell>
<row.headerCell>{{t "form.label.address"}}</row.headerCell>
</header.row>
</table.header>
<table.body as |body|>
@@ -26,6 +27,9 @@
<row.cell>
<code>{{host.id}}</code>
</row.cell>
<row.cell>
<code>{{host.attributes.address}}</code>
</row.cell>
</body.row>
{{/each}}
</table.body>
+1 -1
View File
@@ -12,6 +12,6 @@ export default Factory.extend({
created_time: () => date.recent(),
updated_time: () => date.recent(),
version: () => random.number(),
address: () => internet.ipv6(),
attributes: () => { return { address: internet.ipv6() } },
});