Merge pull request #660 from edewit/issue-416

fixing issue 416
This commit is contained in:
mfrances17 2021-06-14 09:18:16 -04:00 committed by GitHub
commit 861d382621
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 36 deletions

View file

@ -155,8 +155,11 @@ export const AssociatedRolesTab = ({
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
titleKey: "roles:roleRemoveAssociatedRoleConfirm",
messageKey: t("roles:roleRemoveAssociatedText"),
continueButtonLabel: "common:delete",
messageKey: t("roles:roleRemoveAssociatedText", {
role: selectedRows.map((r) => r.name),
roleName: parentRole.name,
}),
continueButtonLabel: "common:remove",
continueButtonVariant: ButtonVariant.danger,
onConfirm: async () => {
try {
@ -179,11 +182,11 @@ export const AssociatedRolesTab = ({
messageKey: t("roles:removeAllAssociatedRolesConfirmDialog", {
name: parentRole?.name || t("createRole"),
}),
continueButtonLabel: "common:delete",
continueButtonLabel: "common:remove",
continueButtonVariant: ButtonVariant.danger,
onConfirm: async () => {
try {
if (selectedRows.length === allRoles.length) {
if (selectedRows.length >= allRoles.length) {
onRemove(selectedRows);
const loc = url.replace(/\/AssociatedRoles/g, "/details");
history.push(loc);

View file

@ -93,8 +93,6 @@ export const RealmRoleTabs = () => {
name: "attributes",
});
//useEffect(() => append({ key: "", value: "" }), [append, role]);
const save = async () => {
try {
const role = form.getValues();
@ -206,8 +204,7 @@ export const RealmRoleTabs = () => {
});
}
addAlert(t("roleDeletedSuccess"), AlertVariant.success);
const loc = url.replace(/\/attributes/g, "");
history.replace(`${loc.substr(0, loc.lastIndexOf("/"))}`);
history.push(url.substr(0, url.indexOf("/roles") + "/roles".length));
} catch (error) {
addAlert(`${t("roleDeleteError")} ${error}`, AlertVariant.danger);
}
@ -259,6 +256,7 @@ export const RealmRoleTabs = () => {
badgeIsRead={true}
subKey={id ? "" : "roles:roleCreateExplain"}
actionsDropdownId="roles-actions-dropdown"
divider={!id}
dropdownItems={
url.includes("AssociatedRoles")
? [
@ -298,43 +296,51 @@ export const RealmRoleTabs = () => {
: undefined
}
/>
<PageSection variant="light">
<PageSection variant="light" className="pf-u-p-0">
{id && (
<KeycloakTabs isBox>
<Tab
eventKey="details"
title={<TabTitleText>{t("details")}</TabTitleText>}
>
<PageSection variant="light">
<RealmRoleForm
reset={() => form.reset(role)}
form={form}
save={save}
editMode={true}
/>
</PageSection>
</Tab>
{additionalRoles.length > 0 ? (
{additionalRoles.length > 0 && (
<Tab
eventKey="AssociatedRoles"
title={<TabTitleText>{t("associatedRolesText")}</TabTitleText>}
>
<PageSection variant="light">
{role && (
<AssociatedRolesTab
additionalRoles={additionalRoles}
addComposites={addComposites}
parentRole={role!}
parentRole={role}
onRemove={() => refresh()}
/>
)}
</PageSection>
</Tab>
) : null}
)}
<Tab
eventKey="attributes"
title={<TabTitleText>{t("common:attributes")}</TabTitleText>}
>
<PageSection variant="light">
<AttributesForm
form={form}
save={save}
array={{ fields, append, remove }}
reset={() => form.reset(role)}
/>
</PageSection>
</Tab>
<Tab
eventKey="users-in-role"
@ -345,12 +351,14 @@ export const RealmRoleTabs = () => {
</KeycloakTabs>
)}
{!id && (
<PageSection variant="light">
<RealmRoleForm
reset={() => form.reset()}
form={form}
save={save}
editMode={false}
/>
</PageSection>
)}
</PageSection>
</>

View file

@ -44,7 +44,7 @@
"removeRoles": "Remove roles",
"removeAllAssociatedRolesConfirmDialog": "This action will remove the associated roles of {{name}}. Users who have permission to {{name}} will no longer have access to these roles.",
"roleRemoveAssociatedRoleConfirm": "Remove associated role?",
"roleRemoveAssociatedText": "This action will remove {{role}} from {{roleName}. All the associated roles of {{role}} will also be removed.",
"roleRemoveAssociatedText": "This action will remove {{role}} from {{roleName}}. All the associated roles of {{role}} will also be removed.",
"compositeRoleOff": "Composite role turned off",
"associatedRolesRemoved": "Associated roles have been removed",
"compositesRemovedAlertDescription": "All the associated roles have been removed",