use group instead of name (#21475)

fixes: #21438
This commit is contained in:
Erik Jan de Wit 2023-07-11 13:05:31 +02:00 committed by GitHub
parent 1e7fbd1312
commit 2c51b67b24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 8 deletions

View file

@ -97,7 +97,7 @@ export const GroupTable = ({
{rename && (
<GroupsModal
id={rename.id}
rename={rename.name}
rename={rename}
refresh={() => {
refresh();
viewRefresh();

View file

@ -18,7 +18,7 @@ import { KeycloakTextInput } from "../components/keycloak-text-input/KeycloakTex
type GroupsModalProps = {
id?: string;
rename?: string;
rename?: GroupRepresentation;
handleModalToggle: () => void;
refresh: (group?: GroupRepresentation) => void;
};
@ -36,7 +36,7 @@ export const GroupsModal = ({
handleSubmit,
formState: { errors },
} = useForm({
defaultValues: { name: rename },
defaultValues: { name: rename?.name },
});
const submitForm = async (group: GroupRepresentation) => {
@ -46,14 +46,17 @@ export const GroupsModal = ({
if (!id) {
await adminClient.groups.create(group);
} else if (rename) {
await adminClient.groups.update({ id }, group);
await adminClient.groups.update(
{ id },
{ ...rename, name: group.name }
);
} else {
await (group.id
? adminClient.groups.updateChildGroup({ id }, group)
: adminClient.groups.createChildGroup({ id }, group));
}
refresh(rename ? group : undefined);
refresh(rename ? { ...rename, name: group.name } : undefined);
handleModalToggle();
addAlert(
t(rename ? "groupUpdated" : "groupCreated"),

View file

@ -46,7 +46,7 @@ export default function GroupsSection() {
const { subGroups, setSubGroups, currentGroup } = useSubGroups();
const { realm } = useRealm();
const [rename, setRename] = useState<string>();
const [rename, setRename] = useState<GroupRepresentation>();
const [deleteOpen, toggleDeleteOpen] = useToggle();
const navigate = useNavigate();
@ -140,7 +140,7 @@ export default function GroupsSection() {
<DropdownItem
data-testid="renameGroupAction"
key="renameGroup"
onClick={() => setRename(currentGroup()?.name)}
onClick={() => setRename(currentGroup())}
>
{t("renameGroup")}
</DropdownItem>,

View file

@ -56,7 +56,7 @@ const GroupTreeContextMenu = ({
{renameOpen && (
<GroupsModal
id={group.id}
rename={group.name}
rename={group}
refresh={() => {
refresh();
}}