From ccdd762d6d9a46b1427e18fb9d4aa9d05beef113 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Wed, 11 May 2022 10:33:11 +0200 Subject: [PATCH] Added delete action (#2600) --- src/identity-providers/add/AddMapper.tsx | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/identity-providers/add/AddMapper.tsx b/src/identity-providers/add/AddMapper.tsx index 64f0762200..328b019202 100644 --- a/src/identity-providers/add/AddMapper.tsx +++ b/src/identity-providers/add/AddMapper.tsx @@ -6,6 +6,8 @@ import { ActionGroup, AlertVariant, Button, + ButtonVariant, + DropdownItem, FormGroup, PageSection, ValidatedOptions, @@ -32,6 +34,7 @@ import { DynamicComponents } from "../../components/dynamic/DynamicComponents"; import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner"; import type { AttributeForm } from "../../components/key-value-form/AttributeForm"; import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput"; +import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog"; export type IdPMapperRepresentationWithAttributes = IdentityProviderMapperRepresentation & AttributeForm; @@ -115,6 +118,29 @@ export default function AddMapper() { } }; + const [toggleDeleteMapperDialog, DeleteMapperConfirm] = useConfirmDialog({ + titleKey: "identity-providers:deleteProviderMapper", + messageKey: t("identity-providers:deleteMapperConfirm", { + mapper: currentMapper?.name, + }), + continueButtonLabel: "common:delete", + continueButtonVariant: ButtonVariant.danger, + onConfirm: async () => { + try { + await adminClient.identityProviders.delMapper({ + alias: alias, + id: id!, + }); + addAlert(t("deleteMapperSuccess"), AlertVariant.success); + history.push( + toIdentityProvider({ providerId, alias, tab: "mappers", realm }) + ); + } catch (error) { + addError("identity-providers:deleteErrorError", error); + } + }, + }); + useFetch( () => Promise.all([ @@ -147,6 +173,7 @@ export default function AddMapper() { return ( + + {t("common:delete")} + , + ] + : undefined + } divider />