Use id instead of name to disable (#3959)
This commit is contained in:
parent
ca03f50093
commit
b0ce0bb181
5 changed files with 12 additions and 9 deletions
|
@ -119,7 +119,7 @@ export const Group = () => {
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
filterGroups={selectedGroups.map(({ name }) => name!)}
|
filterGroups={selectedGroups}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -13,10 +13,12 @@ import type { ComponentProps } from "./components";
|
||||||
import { HelpItem } from "../help-enabler/HelpItem";
|
import { HelpItem } from "../help-enabler/HelpItem";
|
||||||
import { GroupPickerDialog } from "../group/GroupPickerDialog";
|
import { GroupPickerDialog } from "../group/GroupPickerDialog";
|
||||||
import { convertToName } from "./DynamicComponents";
|
import { convertToName } from "./DynamicComponents";
|
||||||
|
import GroupRepresentation from "libs/keycloak-admin-client/lib/defs/groupRepresentation";
|
||||||
|
|
||||||
export const GroupComponent = ({ name, label, helpText }: ComponentProps) => {
|
export const GroupComponent = ({ name, label, helpText }: ComponentProps) => {
|
||||||
const { t } = useTranslation("dynamic");
|
const { t } = useTranslation("dynamic");
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
const [groups, setGroups] = useState<GroupRepresentation[]>();
|
||||||
const { control } = useFormContext();
|
const { control } = useFormContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -36,10 +38,11 @@ export const GroupComponent = ({ name, label, helpText }: ComponentProps) => {
|
||||||
}}
|
}}
|
||||||
onConfirm={(groups) => {
|
onConfirm={(groups) => {
|
||||||
onChange(groups?.[0].path);
|
onChange(groups?.[0].path);
|
||||||
|
setGroups(groups);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
onClose={() => setOpen(false)}
|
onClose={() => setOpen(false)}
|
||||||
filterGroups={value}
|
filterGroups={groups}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { GroupPath } from "./GroupPath";
|
||||||
export type GroupPickerDialogProps = {
|
export type GroupPickerDialogProps = {
|
||||||
id?: string;
|
id?: string;
|
||||||
type: "selectOne" | "selectMany";
|
type: "selectOne" | "selectMany";
|
||||||
filterGroups?: string[];
|
filterGroups?: GroupRepresentation[];
|
||||||
text: { title: string; ok: string };
|
text: { title: string; ok: string };
|
||||||
canBrowse?: boolean;
|
canBrowse?: boolean;
|
||||||
onConfirm: (groups: GroupRepresentation[] | undefined) => void;
|
onConfirm: (groups: GroupRepresentation[] | undefined) => void;
|
||||||
|
@ -103,9 +103,9 @@ export const GroupPickerDialog = ({
|
||||||
|
|
||||||
const isRowDisabled = (row?: GroupRepresentation) => {
|
const isRowDisabled = (row?: GroupRepresentation) => {
|
||||||
return [
|
return [
|
||||||
...joinedGroups.map((item) => item.name),
|
...joinedGroups.map((item) => item.id),
|
||||||
...(filterGroups || []),
|
...(filterGroups || []).map((group) => group.id),
|
||||||
].some((group) => group === row?.name);
|
].some((group) => group === row?.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasSubgroups = (group: GroupRepresentation) =>
|
const hasSubgroups = (group: GroupRepresentation) =>
|
||||||
|
@ -131,7 +131,7 @@ export const GroupPickerDialog = ({
|
||||||
<Modal
|
<Modal
|
||||||
variant={ModalVariant.small}
|
variant={ModalVariant.small}
|
||||||
title={t(text.title, {
|
title={t(text.title, {
|
||||||
group1: filterGroups?.[0],
|
group1: filterGroups?.[0]?.name,
|
||||||
group2: navigation.length ? currentGroup().name : t("root"),
|
group2: navigation.length ? currentGroup().name : t("root"),
|
||||||
})}
|
})}
|
||||||
isOpen
|
isOpen
|
||||||
|
|
|
@ -71,7 +71,7 @@ export const MoveDialog = ({ source, onClose, refresh }: MoveDialogProps) => {
|
||||||
return (
|
return (
|
||||||
<GroupPickerDialog
|
<GroupPickerDialog
|
||||||
type="selectOne"
|
type="selectOne"
|
||||||
filterGroups={[source.name!]}
|
filterGroups={[source]}
|
||||||
text={{
|
text={{
|
||||||
title: "groups:moveToGroup",
|
title: "groups:moveToGroup",
|
||||||
ok: "groups:moveHere",
|
ok: "groups:moveHere",
|
||||||
|
|
|
@ -168,7 +168,7 @@ export const UserForm = ({
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
onClose={() => setOpen(false)}
|
onClose={() => setOpen(false)}
|
||||||
filterGroups={selectedGroups.map((group) => group.name!)}
|
filterGroups={selectedGroups}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{user?.id && (
|
{user?.id && (
|
||||||
|
|
Loading…
Reference in a new issue