Issue 2618 (#2623)

This commit is contained in:
Erik Jan de Wit 2022-05-12 10:09:15 +02:00 committed by GitHub
parent 18c610d12e
commit bb853874d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View file

@ -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:"
}

View file

@ -71,7 +71,7 @@ const SecuredRoute = ({ route }: SecuredRouteProps) => {
</Suspense>
);
return <ForbiddenSection />;
return <ForbiddenSection permissionNeeded={route.access} />;
};
export const App = ({ adminClient }: AdminClientProps) => {

View file

@ -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 (
<PageSection>
{t("forbidden", { count })} {permissionNeeded}
</PageSection>
);
};