diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 8c62edd5e..f71eba2cc 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -522,6 +522,7 @@ export default function () { } ); this.get('/managed-groups/:id'); + this.del('/managed-groups/:id'); /* Uncomment the following line and the Response import above * Then change the response code to simulate error responses. diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups.js b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups.js index f1c4acac5..e1f0d9435 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups.js @@ -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(); + } } diff --git a/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/-actions.hbs b/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/-actions.hbs index 240e83e8e..98a51d476 100644 --- a/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/-actions.hbs +++ b/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/-actions.hbs @@ -4,7 +4,11 @@ @dropdownRight={{true}} as |dropdown| > - + {{t 'resources.managed-group.actions.delete'}}