parent
1e7fbd1312
commit
2c51b67b24
4 changed files with 11 additions and 8 deletions
|
@ -97,7 +97,7 @@ export const GroupTable = ({
|
|||
{rename && (
|
||||
<GroupsModal
|
||||
id={rename.id}
|
||||
rename={rename.name}
|
||||
rename={rename}
|
||||
refresh={() => {
|
||||
refresh();
|
||||
viewRefresh();
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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>,
|
||||
|
|
|
@ -56,7 +56,7 @@ const GroupTreeContextMenu = ({
|
|||
{renameOpen && (
|
||||
<GroupsModal
|
||||
id={group.id}
|
||||
rename={group.name}
|
||||
rename={group}
|
||||
refresh={() => {
|
||||
refresh();
|
||||
}}
|
||||
|
|
Loading…
Reference in a new issue