From e4dc6490ba3249f40a3c75a4365ccc386efdd281 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Fri, 28 Aug 2020 11:20:07 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20backend=20custom=20meth?= =?UTF-8?q?od=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?