Use id instead of name to disable (#3959)

This commit is contained in:
Erik Jan de Wit 2022-12-08 06:24:59 -05:00 committed by GitHub
parent ca03f50093
commit b0ce0bb181
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 9 deletions

View file

@ -119,7 +119,7 @@ export const Group = () => {
onClose={() => {
setOpen(false);
}}
filterGroups={selectedGroups.map(({ name }) => name!)}
filterGroups={selectedGroups}
/>
)}
<Button

View file

@ -13,10 +13,12 @@ import type { ComponentProps } from "./components";
import { HelpItem } from "../help-enabler/HelpItem";
import { GroupPickerDialog } from "../group/GroupPickerDialog";
import { convertToName } from "./DynamicComponents";
import GroupRepresentation from "libs/keycloak-admin-client/lib/defs/groupRepresentation";
export const GroupComponent = ({ name, label, helpText }: ComponentProps) => {
const { t } = useTranslation("dynamic");
const [open, setOpen] = useState(false);
const [groups, setGroups] = useState<GroupRepresentation[]>();
const { control } = useFormContext();
return (
@ -36,10 +38,11 @@ export const GroupComponent = ({ name, label, helpText }: ComponentProps) => {
}}
onConfirm={(groups) => {
onChange(groups?.[0].path);
setGroups(groups);
setOpen(false);
}}
onClose={() => setOpen(false)}
filterGroups={value}
filterGroups={groups}
/>
)}

View file

@ -25,7 +25,7 @@ import { GroupPath } from "./GroupPath";
export type GroupPickerDialogProps = {
id?: string;
type: "selectOne" | "selectMany";
filterGroups?: string[];
filterGroups?: GroupRepresentation[];
text: { title: string; ok: string };
canBrowse?: boolean;
onConfirm: (groups: GroupRepresentation[] | undefined) => void;
@ -103,9 +103,9 @@ export const GroupPickerDialog = ({
const isRowDisabled = (row?: GroupRepresentation) => {
return [
...joinedGroups.map((item) => item.name),
...(filterGroups || []),
].some((group) => group === row?.name);
...joinedGroups.map((item) => item.id),
...(filterGroups || []).map((group) => group.id),
].some((group) => group === row?.id);
};
const hasSubgroups = (group: GroupRepresentation) =>
@ -131,7 +131,7 @@ export const GroupPickerDialog = ({
<Modal
variant={ModalVariant.small}
title={t(text.title, {
group1: filterGroups?.[0],
group1: filterGroups?.[0]?.name,
group2: navigation.length ? currentGroup().name : t("root"),
})}
isOpen

View file

@ -71,7 +71,7 @@ export const MoveDialog = ({ source, onClose, refresh }: MoveDialogProps) => {
return (
<GroupPickerDialog
type="selectOne"
filterGroups={[source.name!]}
filterGroups={[source]}
text={{
title: "groups:moveToGroup",
ok: "groups:moveHere",

View file

@ -168,7 +168,7 @@ export const UserForm = ({
setOpen(false);
}}
onClose={() => setOpen(false)}
filterGroups={selectedGroups.map((group) => group.name!)}
filterGroups={selectedGroups}
/>
)}
{user?.id && (