Added missing groups claim field (#2170)
This commit is contained in:
parent
01ab5b12e0
commit
e3c0bb82a1
3 changed files with 126 additions and 106 deletions
|
@ -2,7 +2,7 @@ import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useFormContext, Controller } from "react-hook-form";
|
import { useFormContext, Controller } from "react-hook-form";
|
||||||
import { MinusCircleIcon } from "@patternfly/react-icons";
|
import { MinusCircleIcon } from "@patternfly/react-icons";
|
||||||
import { FormGroup, Button, Checkbox } from "@patternfly/react-core";
|
import { FormGroup, Button, Checkbox, TextInput } from "@patternfly/react-core";
|
||||||
import {
|
import {
|
||||||
TableComposable,
|
TableComposable,
|
||||||
Thead,
|
Thead,
|
||||||
|
@ -24,7 +24,7 @@ export type GroupValue = {
|
||||||
|
|
||||||
export const Group = () => {
|
export const Group = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { control, getValues, setValue, errors } =
|
const { control, register, getValues, setValue, errors } =
|
||||||
useFormContext<{ groups?: GroupValue[] }>();
|
useFormContext<{ groups?: GroupValue[] }>();
|
||||||
const values = getValues("groups");
|
const values = getValues("groups");
|
||||||
|
|
||||||
|
@ -51,6 +51,25 @@ export const Group = () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
<FormGroup
|
||||||
|
label={t("groupsClaim")}
|
||||||
|
labelIcon={
|
||||||
|
<HelpItem
|
||||||
|
helpText="clients-help:groupsClaim"
|
||||||
|
fieldLabelId="clients:groupsClaim"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
fieldId="groups"
|
||||||
|
>
|
||||||
|
<TextInput
|
||||||
|
type="text"
|
||||||
|
id="groupsClaim"
|
||||||
|
name="groupsClaim"
|
||||||
|
data-testid="groupsClaim"
|
||||||
|
ref={register}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={t("groups")}
|
label={t("groups")}
|
||||||
labelIcon={
|
labelIcon={
|
||||||
|
@ -70,7 +89,7 @@ export const Group = () => {
|
||||||
defaultValue={[]}
|
defaultValue={[]}
|
||||||
rules={{
|
rules={{
|
||||||
validate: (value: GroupValue[]) =>
|
validate: (value: GroupValue[]) =>
|
||||||
value.filter((c) => c.id).length > 0,
|
value.filter(({ id }) => id).length > 0,
|
||||||
}}
|
}}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<>
|
<>
|
||||||
|
@ -82,17 +101,14 @@ export const Group = () => {
|
||||||
ok: "common:add",
|
ok: "common:add",
|
||||||
}}
|
}}
|
||||||
onConfirm={(groups) => {
|
onConfirm={(groups) => {
|
||||||
onChange([
|
onChange([...value, ...groups.map(({ id }) => ({ id }))]);
|
||||||
...value,
|
|
||||||
...groups.map((group) => ({ id: group.id })),
|
|
||||||
]);
|
|
||||||
setSelectedGroups([...selectedGroups, ...groups]);
|
setSelectedGroups([...selectedGroups, ...groups]);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
filterGroups={selectedGroups.map((g) => g.name!)}
|
filterGroups={selectedGroups.map(({ name }) => name!)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
|
@ -144,10 +160,10 @@ export const Group = () => {
|
||||||
icon={<MinusCircleIcon />}
|
icon={<MinusCircleIcon />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setValue("groups", [
|
setValue("groups", [
|
||||||
...(values || []).filter((s) => s.id !== group.id),
|
...(values || []).filter(({ id }) => id !== group.id),
|
||||||
]);
|
]);
|
||||||
setSelectedGroups([
|
setSelectedGroups([
|
||||||
...selectedGroups.filter((s) => s.id !== group.id),
|
...selectedGroups.filter(({ id }) => id !== group.id),
|
||||||
]);
|
]);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -158,5 +174,6 @@ export const Group = () => {
|
||||||
</TableComposable>
|
</TableComposable>
|
||||||
)}
|
)}
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -255,6 +255,8 @@ export default {
|
||||||
applyPolicy:
|
applyPolicy:
|
||||||
"Specifies all the policies that must be applied to the scopes defined by this policy or permission.",
|
"Specifies all the policies that must be applied to the scopes defined by this policy or permission.",
|
||||||
policyClient: "Specifies which client(s) are allowed by this policy.",
|
policyClient: "Specifies which client(s) are allowed by this policy.",
|
||||||
|
groupsClaim:
|
||||||
|
"If defined, the policy will fetch user's groups from the given claim within an access token or ID token representing the identity asking permissions. If not defined, user's groups are obtained from your realm configuration.",
|
||||||
policyGroups: "Specifies which user(s) are allowed by this policy.",
|
policyGroups: "Specifies which user(s) are allowed by this policy.",
|
||||||
targetClaim: "Specifies the target claim which the policy will fetch.",
|
targetClaim: "Specifies the target claim which the policy will fetch.",
|
||||||
regexPattern: "Specifies the regex pattern.",
|
regexPattern: "Specifies the regex pattern.",
|
||||||
|
|
|
@ -230,6 +230,7 @@ export default {
|
||||||
applyPolicy: "Apply policy",
|
applyPolicy: "Apply policy",
|
||||||
addClientScopes: "Add client scopes",
|
addClientScopes: "Add client scopes",
|
||||||
clientScope: "Client scope",
|
clientScope: "Client scope",
|
||||||
|
groupsClaim: "Groups claim",
|
||||||
addGroups: "Add groups",
|
addGroups: "Add groups",
|
||||||
groups: "Groups",
|
groups: "Groups",
|
||||||
users: "Users",
|
users: "Users",
|
||||||
|
|
Loading…
Reference in a new issue