Merge pull request #141 from hashicorp/chore-remove
chore: 🤖 backend custom method is remove; updated language too
This commit is contained in:
6 files changed
+19
-18
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
@@ -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');
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
<dropdown.button
|
||||
name={{t "actions.delete"}}
|
||||
@style="danger"
|
||||
{{on "click" (route-action "delete" @model hostSet.model)}}
|
||||
{{on "click" (route-action "removeHostSet" @model hostSet.model)}}
|
||||
>
|
||||
{{t "actions.delete"}}
|
||||
{{t "actions.remove"}}
|
||||
</dropdown.button>
|
||||
</Rose::Dropdown>
|
||||
</row.cell>
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ actions:
|
||||
add: Add
|
||||
cancel: Cancel
|
||||
delete: Delete
|
||||
remove: Remove
|
||||
dismiss: Dismiss
|
||||
save: Save
|
||||
help: Need help?
|
||||
|
||||
Reference in new issue
Block a user