From 2f1feab9d364cfe4a39e93840afaeed3ed869f96 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Tue, 9 Nov 2021 12:01:30 -0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Add=20managed=20groups?= =?UTF-8?q?=20delete=20CRUD=20operation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/mirage/config.js | 1 + .../auth-method/managed-groups.js | 24 +++++++++++++++++++ .../managed-groups/managed-group/-actions.hbs | 6 ++++- 3 files changed, 30 insertions(+), 1 deletion(-) 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'}}