diff --git a/public/resources/en/common.json b/public/resources/en/common.json index 8b6bac750c..f3a7ac188c 100644 --- a/public/resources/en/common.json +++ b/public/resources/en/common.json @@ -201,5 +201,7 @@ "password": "Password", "passwordConfirmation": "Password confirmation", "temporaryPassword": "Temporary", - "temporaryPasswordHelpText": "If enabled, the user must change the password on next login" + "temporaryPasswordHelpText": "If enabled, the user must change the password on next login", + "forbidden_one": "Forbidden, permission needed:", + "forbidden_other": "Forbidden, permissions needed:" } diff --git a/src/App.tsx b/src/App.tsx index b4e093320f..000fdcb37f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -71,7 +71,7 @@ const SecuredRoute = ({ route }: SecuredRouteProps) => { ); - return ; + return ; }; export const App = ({ adminClient }: AdminClientProps) => { diff --git a/src/ForbiddenSection.tsx b/src/ForbiddenSection.tsx index a3d4b6f13a..aaa2037536 100644 --- a/src/ForbiddenSection.tsx +++ b/src/ForbiddenSection.tsx @@ -1,5 +1,22 @@ import React from "react"; +import { useTranslation } from "react-i18next"; +import { PageSection } from "@patternfly/react-core"; -export const ForbiddenSection = () => { - return <>Forbidden; +import type { AccessType } from "@keycloak/keycloak-admin-client/lib/defs/whoAmIRepresentation"; + +type ForbiddenSectionProps = { + permissionNeeded: AccessType | AccessType[]; +}; + +export const ForbiddenSection = ({ + permissionNeeded, +}: ForbiddenSectionProps) => { + const { t } = useTranslation("common"); + const count = Array.isArray(permissionNeeded) ? permissionNeeded.length : 1; + + return ( + + {t("forbidden", { count })} {permissionNeeded} + + ); };