delete functionality and do not display current role in modal (#1543)
This commit is contained in:
parent
2c9a8657df
commit
0b95598411
2 changed files with 49 additions and 54 deletions
|
@ -68,7 +68,9 @@ export const AssociatedRolesModal = ({
|
||||||
params.search = searchParam;
|
params.search = searchParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
return adminClient.roles.find(params);
|
return (await adminClient.roles.find(params)).filter(
|
||||||
|
(item) => item.name !== name
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const AliasRenderer = ({ id, name, clientId }: Role) => {
|
const AliasRenderer = ({ id, name, clientId }: Role) => {
|
||||||
|
@ -91,10 +93,12 @@ export const AssociatedRolesModal = ({
|
||||||
clients.map(async (client) => {
|
clients.map(async (client) => {
|
||||||
const roles = await adminClient.clients.listRoles({ id: client.id! });
|
const roles = await adminClient.clients.listRoles({ id: client.id! });
|
||||||
|
|
||||||
return roles.map<Role>((role) => ({
|
return roles
|
||||||
|
.map<Role>((role) => ({
|
||||||
...role,
|
...role,
|
||||||
clientId: client.clientId,
|
clientId: client.clientId,
|
||||||
}));
|
}))
|
||||||
|
.filter((item) => item.name !== name);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -115,7 +119,7 @@ export const AssociatedRolesModal = ({
|
||||||
return { role, compositeRoles };
|
return { role, compositeRoles };
|
||||||
},
|
},
|
||||||
({ role, compositeRoles }) => {
|
({ role, compositeRoles }) => {
|
||||||
setName(role ? role.name! : t("createRole"));
|
setName(role?.name!);
|
||||||
setCompositeRoles(compositeRoles);
|
setCompositeRoles(compositeRoles);
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
|
@ -142,7 +146,9 @@ export const AssociatedRolesModal = ({
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
data-testid="addAssociatedRole"
|
data-testid="addAssociatedRole"
|
||||||
title={t("roles:associatedRolesModalTitle", { name })}
|
title={
|
||||||
|
name ? t("roles:associatedRolesModalTitle", { name }) : t("addRole")
|
||||||
|
}
|
||||||
isOpen
|
isOpen
|
||||||
onClose={toggleDialog}
|
onClose={toggleDialog}
|
||||||
variant={ModalVariant.large}
|
variant={ModalVariant.large}
|
||||||
|
|
|
@ -204,8 +204,7 @@ export default function RealmRoleTabs() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const dropdownItems =
|
const dropdownItems = url.includes("associated-roles")
|
||||||
url.includes("associated-roles") && !realm?.defaultRole
|
|
||||||
? [
|
? [
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
key="delete-all-associated"
|
key="delete-all-associated"
|
||||||
|
@ -224,16 +223,6 @@ export default function RealmRoleTabs() {
|
||||||
{t("deleteRole")}
|
{t("deleteRole")}
|
||||||
</DropdownItem>,
|
</DropdownItem>,
|
||||||
]
|
]
|
||||||
: id && realm?.defaultRole && url.includes("associated-roles")
|
|
||||||
? [
|
|
||||||
<DropdownItem
|
|
||||||
key="delete-all-associated"
|
|
||||||
component="button"
|
|
||||||
onClick={() => toggleDeleteAllAssociatedRolesDialog()}
|
|
||||||
>
|
|
||||||
{t("roles:removeAllAssociatedRoles")}
|
|
||||||
</DropdownItem>,
|
|
||||||
]
|
|
||||||
: [
|
: [
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
key="toggle-modal"
|
key="toggle-modal"
|
||||||
|
|
Loading…
Reference in a new issue