diff --git a/src/client-scopes/ClientScopesSection.tsx b/src/client-scopes/ClientScopesSection.tsx index 3cffd374da..0dc07a6cb5 100644 --- a/src/client-scopes/ClientScopesSection.tsx +++ b/src/client-scopes/ClientScopesSection.tsx @@ -1,11 +1,12 @@ import React from "react"; import { useTranslation } from "react-i18next"; import { Link, useHistory, useRouteMatch } from "react-router-dom"; -import { Button, PageSection } from "@patternfly/react-core"; +import { AlertVariant, Button, PageSection } from "@patternfly/react-core"; import ClientScopeRepresentation from "keycloak-admin/lib/defs/clientScopeRepresentation"; import { useAdminClient } from "../context/auth/AdminClient"; import { ViewHeader } from "../components/view-header/ViewHeader"; +import { useAlerts } from "../components/alert/Alerts"; import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable"; export const ClientScopesSection = () => { @@ -14,6 +15,7 @@ export const ClientScopesSection = () => { const { url } = useRouteMatch(); const adminClient = useAdminClient(); + const { addAlert } = useAlerts(); const loader = async () => await adminClient.clientScopes.find(); @@ -47,7 +49,21 @@ export const ClientScopesSection = () => { }, { title: t("common:delete"), - onRowClick: () => {}, + onRowClick: async (clientScope) => { + try { + await adminClient.clientScopes.del({ id: clientScope.id! }); + addAlert(t("deletedSuccess"), AlertVariant.success); + return true; + } catch (error) { + addAlert( + t("deleteError", { + error: error.response.data?.errorMessage || error, + }), + AlertVariant.danger + ); + return false; + } + }, }, ]} columns={[ diff --git a/src/client-scopes/messages.json b/src/client-scopes/messages.json index 8759e168d9..ea712c290b 100644 --- a/src/client-scopes/messages.json +++ b/src/client-scopes/messages.json @@ -11,6 +11,8 @@ "type": "Type", "priority": "Priority", "protocol": "Protocol", + "deletedSuccess": "The client scope has been deleted", + "deleteError": "Could not delete client scope: {{error}}", "includeInTokenScope": "Include in token scope", "mappingDetails": "Mapper details", "mappingCreatedSuccess": "Mapping successfully created",