added delete client scope functionality (#272)
* added delete client scope functionality * use error message from the response
This commit is contained in:
parent
e6fa093925
commit
1763ee1a50
2 changed files with 20 additions and 2 deletions
|
@ -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={[
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue