From a2815c310bf48456cbcb5e8279a1f1c0751d6054 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 26 Aug 2020 17:41:52 -0400 Subject: [PATCH 1/8] feat: Delete host set association in a target --- .../project/targets/target/host-sets.js | 22 +++++++++++++++++++ .../project/targets/target/host-sets.hbs | 10 +++++++++ 2 files changed, 32 insertions(+) diff --git a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js index 34418acea..79547405a 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js +++ b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js @@ -1,7 +1,15 @@ import Route from '@ember/routing/route'; import { all, hash } from 'rsvp'; +import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; + export default class ScopesScopeProjectsProjectTargetsTargetHostSetsRoute extends Route { + // =services + + @service intl; + @service notify; + // =methods /** @@ -40,4 +48,18 @@ export default class ScopesScopeProjectsProjectTargetsTargetHostSetsRoute extend model() { return this.modelFor('scopes.scope.projects.project.targets.target'); } + + // =actions + @action + async delete(target, hostSet) { + try { + await target.deleteHostSets(hostSet); + this.refresh(); + this.notify.success(this.intl.t('notify.delete-success')); + this.transitionTo('scopes.scope.projects.project.targets.target.host-sets'); + } catch (error) { + // TODO: replace with translated strings + this.notify.error(error.message, { closeAfter: null }); + } + } } 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..c50bb079d 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 @@ -23,6 +23,16 @@ {{hostSet.model.id}} + + + + {{t "actions.delete"}} + + + {{/each}} From 54008c8977941c46925a277bedd2ffe0ad1c459b Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Thu, 27 Aug 2020 11:26:56 -0400 Subject: [PATCH 2/8] feat: Delete hostset from list of target hostsets --- .../scope/projects/project/targets/target/host-sets.js | 8 +++++++- .../scope/projects/project/targets/target/host-sets.hbs | 1 + ui/core/tests/acceptance/targets-test.js | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js index 79547405a..540638ebd 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js +++ b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js @@ -50,10 +50,16 @@ export default class ScopesScopeProjectsProjectTargetsTargetHostSetsRoute extend } // =actions + + /** + * Delete host set in current target scope and redirect to index. + * @param {TargetModel} target + * @param {HostSetModel} hostSet + */ @action async delete(target, hostSet) { try { - await target.deleteHostSets(hostSet); + await target.deleteHostSets([hostSet.id]); this.refresh(); this.notify.success(this.intl.t('notify.delete-success')); this.transitionTo('scopes.scope.projects.project.targets.target.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 c50bb079d..e54ba318c 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"}} + diff --git a/ui/core/tests/acceptance/targets-test.js b/ui/core/tests/acceptance/targets-test.js index 01f73d443..4d6ccb0ad 100644 --- a/ui/core/tests/acceptance/targets-test.js +++ b/ui/core/tests/acceptance/targets-test.js @@ -62,4 +62,8 @@ module('Acceptance | targets', function (hooks) { test('viewing target host sets', async function (assert) { assert.expect(0); }); + + test('can delete a host sets', async function(assert) { + assert.expect(0); + }); }); From f97eebe1b80b8a36483ed158ee85eeaccdbd013b Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Thu, 27 Aug 2020 12:59:26 -0400 Subject: [PATCH 3/8] feat: Add 'deleteHostSet' method to a target 'deleteHostSet' wraps a host set id in an array and uses 'deleteHostSets' method --- addons/api/addon/models/target.js | 10 ++++++ addons/api/tests/unit/models/target-test.js | 33 +++++++++++++++++++ .../project/targets/target/host-sets.js | 2 +- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index 99e1f3d16..db28c0afb 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -79,4 +79,14 @@ export default class TargetModel extends GeneratedTargetModel { }); } + /** + * Delete a single host set via the `delete-host-sets` method. + * @param {object} hostSet + * @param {object} options + * @return {Promise} + */ + deleteHostSet(hostSet, options) { + return this.deleteHostSets([hostSet.id], options); + } + } diff --git a/addons/api/tests/unit/models/target-test.js b/addons/api/tests/unit/models/target-test.js index 7d3aab836..80adb1274 100644 --- a/addons/api/tests/unit/models/target-test.js +++ b/addons/api/tests/unit/models/target-test.js @@ -122,4 +122,37 @@ module('Unit | Model | target', function (hooks) { const model = store.peekRecord('target', '123abc'); await model.deleteHostSets(['1', '3']); }); + + test('it has a `deleteHostSet` method that deletes a single host set using `deleteHostSets` method', async function (assert) { + assert.expect(1); + this.server.post('/v1/scopes/o_1/targets/123abc:delete-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.deleteHostSet({id: '3'}); + }); }); diff --git a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js index 540638ebd..9b4ec2ce8 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js +++ b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js @@ -59,7 +59,7 @@ export default class ScopesScopeProjectsProjectTargetsTargetHostSetsRoute extend @action async delete(target, hostSet) { try { - await target.deleteHostSets([hostSet.id]); + await target.deleteHostSet(hostSet); this.refresh(); this.notify.success(this.intl.t('notify.delete-success')); this.transitionTo('scopes.scope.projects.project.targets.target.host-sets'); From 9725362d05678970fef54e28945e568478925b87 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Thu, 27 Aug 2020 15:21:40 -0400 Subject: [PATCH 4/8] refactor: Update 'deleteHostSet' to use hostset's id --- addons/api/addon/models/target.js | 6 +++--- addons/api/tests/unit/models/target-test.js | 2 +- .../scope/projects/project/targets/target/host-sets.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index db28c0afb..e54053325 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -81,12 +81,12 @@ export default class TargetModel extends GeneratedTargetModel { /** * Delete a single host set via the `delete-host-sets` method. - * @param {object} hostSet + * @param {number} hostSetID * @param {object} options * @return {Promise} */ - deleteHostSet(hostSet, options) { - return this.deleteHostSets([hostSet.id], options); + deleteHostSet(hostSetID, options) { + return this.deleteHostSets([hostSetID], options); } } diff --git a/addons/api/tests/unit/models/target-test.js b/addons/api/tests/unit/models/target-test.js index 80adb1274..b476501b0 100644 --- a/addons/api/tests/unit/models/target-test.js +++ b/addons/api/tests/unit/models/target-test.js @@ -153,6 +153,6 @@ module('Unit | Model | target', function (hooks) { } }); const model = store.peekRecord('target', '123abc'); - await model.deleteHostSet({id: '3'}); + await model.deleteHostSet('3'); }); }); diff --git a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js index 9b4ec2ce8..4da383166 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js +++ b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js @@ -59,7 +59,7 @@ export default class ScopesScopeProjectsProjectTargetsTargetHostSetsRoute extend @action async delete(target, hostSet) { try { - await target.deleteHostSet(hostSet); + await target.deleteHostSet(hostSet.id); this.refresh(); this.notify.success(this.intl.t('notify.delete-success')); this.transitionTo('scopes.scope.projects.project.targets.target.host-sets'); From e4dc6490ba3249f40a3c75a4365ccc386efdd281 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Fri, 28 Aug 2020 11:20:07 -0400 Subject: [PATCH 5/8] =?UTF-8?q?chore:=20=F0=9F=A4=96=20backend=20custom=20?= =?UTF-8?q?method=20is=20remove;=20updated=20language=20too?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/models/target.js | 12 ++++++------ addons/api/tests/unit/models/target-test.js | 12 ++++++------ .../projects/project/targets/target/host-sets.js | 6 +++--- .../projects/project/targets/target/host-sets.hbs | 4 ++-- ui/core/mirage/config.js | 2 +- ui/core/translations/en-us.yaml | 1 + 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index e54053325..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. @@ -80,13 +80,13 @@ export default class TargetModel extends GeneratedTargetModel { } /** - * Delete a single host set via the `delete-host-sets` method. + * Delete a single host set via the `remove-host-sets` method. * @param {number} hostSetID * @param {object} options * @return {Promise} */ - deleteHostSet(hostSetID, options) { - return this.deleteHostSets([hostSetID], options); + 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 b476501b0..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,12 +120,12 @@ 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 `deleteHostSet` method that deletes a single host set using `deleteHostSets` method', async function (assert) { + 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: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: ['3'], @@ -153,6 +153,6 @@ module('Unit | Model | target', function (hooks) { } }); const model = store.peekRecord('target', '123abc'); - await model.deleteHostSet('3'); + await model.removeHostSet('3'); }); }); diff --git a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js index 4da383166..f2ca46232 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js +++ b/ui/core/app/routes/scopes/scope/projects/project/targets/target/host-sets.js @@ -52,14 +52,14 @@ export default class ScopesScopeProjectsProjectTargetsTargetHostSetsRoute extend // =actions /** - * Delete host set in current target scope and redirect to index. + * Removes a host set from the current target and redirects to index. * @param {TargetModel} target * @param {HostSetModel} hostSet */ @action - async delete(target, hostSet) { + async removeHostSet(target, hostSet) { try { - await target.deleteHostSet(hostSet.id); + await target.removeHostSet(hostSet.id); this.refresh(); this.notify.success(this.intl.t('notify.delete-success')); this.transitionTo('scopes.scope.projects.project.targets.target.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 e54ba318c..f7993306b 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 @@ -28,9 +28,9 @@ - {{t "actions.delete"}} + {{t "actions.remove"}} diff --git a/ui/core/mirage/config.js b/ui/core/mirage/config.js index f4bebd6cd..e54366fe3 100644 --- a/ui/core/mirage/config.js +++ b/ui/core/mirage/config.js @@ -148,7 +148,7 @@ export default function() { }); } // If deleting host sets, filter them out of the array - if (method === 'delete-host-sets') { + if (method === 'remove-host-sets') { updatedAttrs.hostSetIds = updatedAttrs.hostSetIds.filter(id => { return !attrs.hostSetIds.includes(id); }); diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index 8e2ffd179..c704ec365 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -2,6 +2,7 @@ actions: add: Add cancel: Cancel delete: Delete + remove: Remove dismiss: Dismiss save: Save help: Need help? From c1c65284eee3cdc6e3576dddd768b3f298bce6fb Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Fri, 28 Aug 2020 11:22:41 -0400 Subject: [PATCH 6/8] fix: Add a11y label to delete action --- .../scopes/scope/projects/project/targets/target/host-sets.hbs | 3 ++- ui/core/translations/en-us.yaml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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 e54ba318c..373cf71cc 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,7 +8,7 @@ {{t "form.label.name"}} {{t "form.label.type"}} {{t "form.label.id"}} - + {{t "form.label.actions"}} @@ -27,6 +27,7 @@ diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index 8e2ffd179..9120ff788 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -120,6 +120,7 @@ form: principal: Principal address: Address protocol: Protocol + actions: Actions errors: titles: unauthenticated-error: You are not signed in From e81ef69fd13152cd6aa34ae7a273bf39d3835b8a Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Mon, 31 Aug 2020 10:12:51 -0400 Subject: [PATCH 7/8] style: fix dropdown trigger hover state --- .../addon/styles/rose/components/dropdown/_dropdown.scss | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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, Date: Mon, 31 Aug 2020 10:19:54 -0400 Subject: [PATCH 8/8] =?UTF-8?q?chore:=20=F0=9F=A4=96=20tweak=20text=20labe?= =?UTF-8?q?ls=20for=20a11y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/scopes/scope/auth-methods/auth-method/index.hbs | 2 +- ui/core/app/templates/scopes/scope/groups/group/index.hbs | 2 +- .../projects/project/host-catalogs/host-catalog/-actions.hbs | 2 +- .../project/host-catalogs/host-catalog/host-sets/-actions.hbs | 2 +- .../project/host-catalogs/host-catalog/hosts/-actions.hbs | 2 +- ui/core/app/templates/scopes/scope/projects/project/index.hbs | 2 +- .../scopes/scope/projects/project/targets/target/-actions.hbs | 2 +- .../scopes/scope/projects/project/targets/target/host-sets.hbs | 3 +-- ui/core/app/templates/scopes/scope/roles/role.hbs | 2 +- ui/core/app/templates/scopes/scope/users/user/index.hbs | 2 +- ui/core/translations/en-us.yaml | 2 +- 11 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/index.hbs b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/index.hbs index 753e4fdf2..344a97929 100644 --- a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/index.hbs +++ b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/index.hbs @@ -19,7 +19,7 @@ - + - + + + + - + + {{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 3c6817584..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 @@ -25,9 +25,8 @@ {{hostSet.model.id}} - + 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 @@ - + - +