feat: 🎸 Add managed groups delete CRUD operation

This commit is contained in:
Carlos Alcaide Corvo committed 2021-11-10 07:49:50 -08:00
1 parent f3d8db6aaf
commit 2f1feab9d3
3 files changed
+30 -1

No files matched your search

@@ -1,7 +1,14 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { confirm } from 'core/decorators/confirm';
import loading from 'ember-loading/decorator';
import { notifySuccess, notifyError } from 'core/decorators/notify';
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends Route {
// =services
@service notify;
/**
*
* @returns {Promise{[ManagedGroupsModel]}}
@@ -25,4 +32,21 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends
this.transitionTo('scopes.scope.auth-methods.auth-method.managed-groups');
}
}
/**
* Delete a managed group in current scope and redirect to index
* @param {ManagedGroupModel} managed group
*/
@action
@loading
@confirm('questions.delete-confirm')
@notifyError(({ message }) => message, { catch: true })
@notifySuccess('notifications.delete-success')
async deleteManagedGroup(managedGroup) {
await managedGroup.destroyRecord();
await this.replaceWith(
'scopes.scope.auth-methods.auth-method.managed-groups'
);
this.refresh();
}
}