mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32:05 -03:30
fixes: #38458 (cherry picked from commit 87dfdad4bf2a1a4c6b90456803da2c38f1a4a018) Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
2e1740b778
commit
61fbcae818
@ -2,7 +2,6 @@ import GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupR
|
||||
import {
|
||||
FormErrorText,
|
||||
HelpItem,
|
||||
SelectVariant,
|
||||
useFetch,
|
||||
} from "@keycloak/keycloak-ui-shared";
|
||||
import { Button, FormGroup } from "@patternfly/react-core";
|
||||
@ -16,7 +15,7 @@ import type { ComponentProps } from "../../components/dynamic/components";
|
||||
import { GroupPickerDialog } from "../../components/group/GroupPickerDialog";
|
||||
|
||||
type GroupSelectProps = Omit<ComponentProps, "convertToName"> & {
|
||||
variant?: `${SelectVariant}`;
|
||||
variant?: "typeahead" | "typeaheadMulti";
|
||||
isRequired?: boolean;
|
||||
};
|
||||
|
||||
@ -30,6 +29,7 @@ export const GroupSelect = ({
|
||||
defaultValue,
|
||||
isDisabled = false,
|
||||
isRequired,
|
||||
variant = "typeaheadMulti",
|
||||
}: GroupSelectProps) => {
|
||||
const { adminClient } = useAdminClient();
|
||||
const { t } = useTranslation();
|
||||
@ -58,6 +58,8 @@ export const GroupSelect = ({
|
||||
[],
|
||||
);
|
||||
|
||||
const selectOne = variant === "typeahead";
|
||||
|
||||
return (
|
||||
<FormGroup
|
||||
label={t(label!)}
|
||||
@ -78,17 +80,22 @@ export const GroupSelect = ({
|
||||
<>
|
||||
{open && (
|
||||
<GroupPickerDialog
|
||||
type="selectMany"
|
||||
type={selectOne ? "selectOne" : "selectMany"}
|
||||
text={{
|
||||
title: "addGroupsToGroupPolicy",
|
||||
ok: "add",
|
||||
}}
|
||||
onConfirm={(selectGroup) => {
|
||||
field.onChange([
|
||||
...(field.value || []),
|
||||
...convertGroups(selectGroup || []),
|
||||
]);
|
||||
setGroups([...groups, ...(selectGroup || [])]);
|
||||
if (selectOne) {
|
||||
field.onChange(convertGroups(selectGroup || []));
|
||||
setGroups(selectGroup || []);
|
||||
} else {
|
||||
field.onChange([
|
||||
...(field.value || []),
|
||||
...convertGroups(selectGroup || []),
|
||||
]);
|
||||
setGroups([...groups, ...(selectGroup || [])]);
|
||||
}
|
||||
setOpen(false);
|
||||
}}
|
||||
onClose={() => {
|
||||
|
||||
@ -95,8 +95,9 @@ export const ResourceType = ({
|
||||
resourceType: normalizedResourceType,
|
||||
})}
|
||||
defaultValue={[]}
|
||||
variant="typeaheadMulti"
|
||||
variant={withEnforceAccessTo ? "typeaheadMulti" : "typeahead"}
|
||||
isRequired={withEnforceAccessTo}
|
||||
isRadio={!withEnforceAccessTo}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user