PR review fix

This commit is contained in:
Erik Jan de Wit 2021-06-14 09:34:37 +02:00
parent 8a73291bc2
commit 3e4a73ebfb
3 changed files with 18 additions and 11 deletions

View file

@ -155,7 +155,10 @@ 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", {
role: selectedRows.map((r) => r.name),
roleName: parentRole.name,
}),
continueButtonLabel: "common:remove", continueButtonLabel: "common:remove",
continueButtonVariant: ButtonVariant.danger, continueButtonVariant: ButtonVariant.danger,
onConfirm: async () => { onConfirm: async () => {
@ -183,7 +186,7 @@ export const AssociatedRolesTab = ({
continueButtonVariant: ButtonVariant.danger, continueButtonVariant: ButtonVariant.danger,
onConfirm: async () => { onConfirm: async () => {
try { try {
if (selectedRows.length === allRoles.length) { if (selectedRows.length >= allRoles.length) {
onRemove(selectedRows); onRemove(selectedRows);
const loc = url.replace(/\/AssociatedRoles/g, "/details"); const loc = url.replace(/\/AssociatedRoles/g, "/details");
history.push(loc); history.push(loc);

View file

@ -154,7 +154,9 @@ export const RealmRoleTabs = () => {
}); });
} }
setRole(convert(createdRole)); setRole(convert(createdRole));
history.push(`/${realm}/roles/${createdRole.id}`); history.push(
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) {
@ -202,7 +204,7 @@ export const RealmRoleTabs = () => {
}); });
} }
addAlert(t("roleDeletedSuccess"), AlertVariant.success); addAlert(t("roleDeletedSuccess"), AlertVariant.success);
history.replace(`/${realm}/roles`); history.push(url.substr(0, url.indexOf("/roles") + "/roles".length));
} catch (error) { } catch (error) {
addAlert(`${t("roleDeleteError")} ${error}`, AlertVariant.danger); addAlert(`${t("roleDeleteError")} ${error}`, AlertVariant.danger);
} }
@ -316,12 +318,14 @@ export const RealmRoleTabs = () => {
title={<TabTitleText>{t("associatedRolesText")}</TabTitleText>} title={<TabTitleText>{t("associatedRolesText")}</TabTitleText>}
> >
<PageSection variant="light"> <PageSection variant="light">
<AssociatedRolesTab {role && (
additionalRoles={additionalRoles} <AssociatedRolesTab
addComposites={addComposites} additionalRoles={additionalRoles}
parentRole={role!} addComposites={addComposites}
onRemove={() => refresh()} parentRole={role}
/> onRemove={() => refresh()}
/>
)}
</PageSection> </PageSection>
</Tab> </Tab>
)} )}

View file

@ -44,7 +44,7 @@
"removeRoles": "Remove roles", "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.", "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?", "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", "compositeRoleOff": "Composite role turned off",
"associatedRolesRemoved": "Associated roles have been removed", "associatedRolesRemoved": "Associated roles have been removed",
"compositesRemovedAlertDescription": "All the associated roles have been removed", "compositesRemovedAlertDescription": "All the associated roles have been removed",