diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index 99e1f3d16..90b3df16b 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -55,16 +55,16 @@ export default class TargetModel extends GeneratedTargetModel { } /** - * Delete host sets via the `delete-host-sets` method. + * Delete host sets via the `remove-host-sets` method. * See serializer and adapter for more information. * @param {[string]} hostSetIDs * @param {object} options * @param {object} options.adapterOptions * @return {Promise} */ - deleteHostSets(hostSetIDs, options={ adapterOptions: {} }) { + removeHostSets(hostSetIDs, options={ adapterOptions: {} }) { const defaultAdapterOptions = { - method: 'delete-host-sets', + method: 'remove-host-sets', hostSetIDs }; // There is no "deep merge" in ES. @@ -79,4 +79,14 @@ export default class TargetModel extends GeneratedTargetModel { }); } + /** + * Delete a single host set via the `remove-host-sets` method. + * @param {number} hostSetID + * @param {object} options + * @return {Promise} + */ + removeHostSet(hostSetID, options) { + return this.removeHostSets([hostSetID], options); + } + } diff --git a/addons/api/tests/unit/models/target-test.js b/addons/api/tests/unit/models/target-test.js index 7d3aab836..11f0d83a4 100644 --- a/addons/api/tests/unit/models/target-test.js +++ b/addons/api/tests/unit/models/target-test.js @@ -90,9 +90,9 @@ module('Unit | Model | target', function (hooks) { await model.addHostSets(['123_abc', 'foobar']); }); - test('it has a `deleteHostSets` method that targets a specific POST API endpoint and serialization', async function (assert) { + test('it has a `removeHostSets` method that targets a specific POST API endpoint and serialization', async function (assert) { assert.expect(1); - this.server.post('/v1/scopes/o_1/targets/123abc:delete-host-sets', (schema, request) => { + this.server.post('/v1/scopes/o_1/targets/123abc:remove-host-sets', (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { host_set_ids: ['1', '3'], @@ -120,6 +120,39 @@ module('Unit | Model | target', function (hooks) { } }); const model = store.peekRecord('target', '123abc'); - await model.deleteHostSets(['1', '3']); + await model.removeHostSets(['1', '3']); + }); + + test('it has a `removeHostSet` method that deletes a single host set using `removeHostSets` method', async function (assert) { + assert.expect(1); + this.server.post('/v1/scopes/o_1/targets/123abc:remove-host-sets', (schema, request) => { + const body = JSON.parse(request.requestBody); + assert.deepEqual(body, { + host_set_ids: ['3'], + version: 1 + }); + }); + const store = this.owner.lookup('service:store'); + store.push({ + data: { + id: '123abc', + type: 'target', + attributes: { + name: 'Target', + description: 'Description', + host_sets: [ + { host_set_id: '1', host_catalog_id: '2' }, + { host_set_id: '3', host_catalog_id: '4' } + ], + version: 1, + scope: { + scope_id: 'o_1', + type: 'scope' + } + } + } + }); + const model = store.peekRecord('target', '123abc'); + await model.removeHostSet('3'); }); }); diff --git a/addons/rose/addon/styles/rose/components/dropdown/_dropdown.scss b/addons/rose/addon/styles/rose/components/dropdown/_dropdown.scss index 0194a485c..3bbbdb292 100644 --- a/addons/rose/addon/styles/rose/components/dropdown/_dropdown.scss +++ b/addons/rose/addon/styles/rose/components/dropdown/_dropdown.scss @@ -34,7 +34,7 @@ $chevron: "data:image/svg+xml;utf-8, - + - + + + + - + + {{t 'actions.add-host-sets'}} diff --git a/ui/core/app/templates/scopes/scope/projects/project/targets/target/host-sets.hbs b/ui/core/app/templates/scopes/scope/projects/project/targets/target/host-sets.hbs index 3effb2b0d..58638e1a3 100644 --- a/ui/core/app/templates/scopes/scope/projects/project/targets/target/host-sets.hbs +++ b/ui/core/app/templates/scopes/scope/projects/project/targets/target/host-sets.hbs @@ -8,6 +8,7 @@ {{t "form.label.name"}} {{t "form.label.type"}} {{t "form.label.id"}} + {{t "form.label.actions"}} @@ -23,6 +24,16 @@ {{hostSet.model.id}} + + + + {{t "actions.remove"}} + + + {{/each}} diff --git a/ui/core/app/templates/scopes/scope/roles/role.hbs b/ui/core/app/templates/scopes/scope/roles/role.hbs index 397e9f504..3794941ce 100644 --- a/ui/core/app/templates/scopes/scope/roles/role.hbs +++ b/ui/core/app/templates/scopes/scope/roles/role.hbs @@ -11,7 +11,7 @@ - + - + { return !attrs.hostSetIds.includes(id); }); diff --git a/ui/core/tests/acceptance/targets-test.js b/ui/core/tests/acceptance/targets-test.js index 27f011324..734090704 100644 --- a/ui/core/tests/acceptance/targets-test.js +++ b/ui/core/tests/acceptance/targets-test.js @@ -63,6 +63,10 @@ module('Acceptance | targets', function (hooks) { assert.expect(0); }); + test('can delete a host sets', async function(assert) { + assert.expect(0); + }); + test('select and save host sets to add', async function (assert) { assert.expect(0); }); diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index 9974a7b70..f60803a09 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -2,8 +2,10 @@ actions: add: Add cancel: Cancel delete: Delete + remove: Remove dismiss: Dismiss save: Save + manage: Manage help: Need help? authenticate: Authenticate deauthenticate: Deauthenticate @@ -118,11 +120,11 @@ form: type: Type identification: Username password: Password - manage: Manage grant: Grant principal: Principal address: Address protocol: Protocol + actions: Actions errors: titles: unauthenticated-error: You are not signed in