From 8a73291bc2c258abcb7605c501d7c7f22873f447 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 1 Jun 2021 15:27:39 +0200 Subject: [PATCH] fixing issue 416 --- src/realm-roles/AssociatedRolesTab.tsx | 4 +- src/realm-roles/RealmRoleTabs.tsx | 72 ++++++++++++++------------ 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/realm-roles/AssociatedRolesTab.tsx b/src/realm-roles/AssociatedRolesTab.tsx index 944ecdf648..7deb2e42cb 100644 --- a/src/realm-roles/AssociatedRolesTab.tsx +++ b/src/realm-roles/AssociatedRolesTab.tsx @@ -156,7 +156,7 @@ export const AssociatedRolesTab = ({ const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({ titleKey: "roles:roleRemoveAssociatedRoleConfirm", messageKey: t("roles:roleRemoveAssociatedText"), - continueButtonLabel: "common:delete", + continueButtonLabel: "common:remove", continueButtonVariant: ButtonVariant.danger, onConfirm: async () => { try { @@ -179,7 +179,7 @@ export const AssociatedRolesTab = ({ messageKey: t("roles:removeAllAssociatedRolesConfirmDialog", { name: parentRole?.name || t("createRole"), }), - continueButtonLabel: "common:delete", + continueButtonLabel: "common:remove", continueButtonVariant: ButtonVariant.danger, onConfirm: async () => { try { diff --git a/src/realm-roles/RealmRoleTabs.tsx b/src/realm-roles/RealmRoleTabs.tsx index 24adf17ca0..2fb283d84e 100644 --- a/src/realm-roles/RealmRoleTabs.tsx +++ b/src/realm-roles/RealmRoleTabs.tsx @@ -93,8 +93,6 @@ export const RealmRoleTabs = () => { name: "attributes", }); - //useEffect(() => append({ key: "", value: "" }), [append, role]); - const save = async () => { try { const role = form.getValues(); @@ -156,9 +154,7 @@ export const RealmRoleTabs = () => { }); } setRole(convert(createdRole)); - history.push( - url.substr(0, url.lastIndexOf("/") + 1) + createdRole.id + "/details" - ); + history.push(`/${realm}/roles/${createdRole.id}`); } addAlert(t(id ? "roleSaveSuccess" : "roleCreated"), AlertVariant.success); } catch (error) { @@ -206,8 +202,7 @@ export const RealmRoleTabs = () => { }); } addAlert(t("roleDeletedSuccess"), AlertVariant.success); - const loc = url.replace(/\/attributes/g, ""); - history.replace(`${loc.substr(0, loc.lastIndexOf("/"))}`); + history.replace(`/${realm}/roles`); } catch (error) { addAlert(`${t("roleDeleteError")} ${error}`, AlertVariant.danger); } @@ -259,6 +254,7 @@ export const RealmRoleTabs = () => { badgeIsRead={true} subKey={id ? "" : "roles:roleCreateExplain"} actionsDropdownId="roles-actions-dropdown" + divider={!id} dropdownItems={ url.includes("AssociatedRoles") ? [ @@ -298,43 +294,49 @@ export const RealmRoleTabs = () => { : undefined } /> - + {id && ( {t("details")}} > - form.reset(role)} - form={form} - save={save} - editMode={true} - /> + + form.reset(role)} + form={form} + save={save} + editMode={true} + /> + - {additionalRoles.length > 0 ? ( + {additionalRoles.length > 0 && ( {t("associatedRolesText")}} > - refresh()} - /> + + refresh()} + /> + - ) : null} + )} {t("common:attributes")}} > - form.reset(role)} - /> + + form.reset(role)} + /> + { )} {!id && ( - form.reset()} - form={form} - save={save} - editMode={false} - /> + + form.reset()} + form={form} + save={save} + editMode={false} + /> + )}