fixing issue 416

This commit is contained in:
Erik Jan de Wit 2021-06-01 15:27:39 +02:00
parent 04140f1737
commit 8a73291bc2
2 changed files with 40 additions and 36 deletions

View file

@ -156,7 +156,7 @@ export const AssociatedRolesTab = ({
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({ const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
titleKey: "roles:roleRemoveAssociatedRoleConfirm", titleKey: "roles:roleRemoveAssociatedRoleConfirm",
messageKey: t("roles:roleRemoveAssociatedText"), messageKey: t("roles:roleRemoveAssociatedText"),
continueButtonLabel: "common:delete", continueButtonLabel: "common:remove",
continueButtonVariant: ButtonVariant.danger, continueButtonVariant: ButtonVariant.danger,
onConfirm: async () => { onConfirm: async () => {
try { try {
@ -179,7 +179,7 @@ export const AssociatedRolesTab = ({
messageKey: t("roles:removeAllAssociatedRolesConfirmDialog", { messageKey: t("roles:removeAllAssociatedRolesConfirmDialog", {
name: parentRole?.name || t("createRole"), name: parentRole?.name || t("createRole"),
}), }),
continueButtonLabel: "common:delete", continueButtonLabel: "common:remove",
continueButtonVariant: ButtonVariant.danger, continueButtonVariant: ButtonVariant.danger,
onConfirm: async () => { onConfirm: async () => {
try { try {

View file

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