fixing issue 629 (#655)
* address some of the issues in 629 * made breadcrumb/page title same as other sections * fixed tests
This commit is contained in:
parent
5d71a4f049
commit
be94f1f9f0
7 changed files with 50 additions and 26 deletions
|
@ -9,6 +9,7 @@ import LoginPage from "../support/pages/LoginPage";
|
||||||
import ViewHeaderPage from "../support/pages/ViewHeaderPage";
|
import ViewHeaderPage from "../support/pages/ViewHeaderPage";
|
||||||
import AdminClient from "../support/util/AdminClient";
|
import AdminClient from "../support/util/AdminClient";
|
||||||
import { keycloakBefore } from "../support/util/keycloak_before";
|
import { keycloakBefore } from "../support/util/keycloak_before";
|
||||||
|
import ModalUtils from "../support/util/ModalUtils";
|
||||||
|
|
||||||
describe("Group test", () => {
|
describe("Group test", () => {
|
||||||
const loginPage = new LoginPage();
|
const loginPage = new LoginPage();
|
||||||
|
@ -19,6 +20,7 @@ describe("Group test", () => {
|
||||||
const groupModal = new GroupModal();
|
const groupModal = new GroupModal();
|
||||||
const searchGroupPage = new SearchGroupPage();
|
const searchGroupPage = new SearchGroupPage();
|
||||||
const moveGroupModal = new MoveGroupModal();
|
const moveGroupModal = new MoveGroupModal();
|
||||||
|
const modalUtils = new ModalUtils();
|
||||||
|
|
||||||
let groupName = "group";
|
let groupName = "group";
|
||||||
|
|
||||||
|
@ -53,6 +55,7 @@ describe("Group test", () => {
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
listingPage.deleteItem(groupName);
|
listingPage.deleteItem(groupName);
|
||||||
|
modalUtils.checkModalTitle("Delete group?").confirmModal();
|
||||||
masthead.checkNotificationMessage("Group deleted");
|
masthead.checkNotificationMessage("Group deleted");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -71,6 +74,7 @@ describe("Group test", () => {
|
||||||
sidebarPage.goToGroups();
|
sidebarPage.goToGroups();
|
||||||
listingPage.searchItem(newName, false).itemExist(newName);
|
listingPage.searchItem(newName, false).itemExist(newName);
|
||||||
listingPage.deleteItem(newName);
|
listingPage.deleteItem(newName);
|
||||||
|
modalUtils.checkModalTitle("Delete group?").confirmModal();
|
||||||
masthead.checkNotificationMessage("Group deleted");
|
masthead.checkNotificationMessage("Group deleted");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -95,6 +99,7 @@ describe("Group test", () => {
|
||||||
listingPage.itemExist(groupName);
|
listingPage.itemExist(groupName);
|
||||||
sidebarPage.goToGroups();
|
sidebarPage.goToGroups();
|
||||||
listingPage.deleteItem(targetGroupName);
|
listingPage.deleteItem(targetGroupName);
|
||||||
|
modalUtils.checkModalTitle("Delete group?").confirmModal();
|
||||||
masthead.checkNotificationMessage("Group deleted");
|
masthead.checkNotificationMessage("Group deleted");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -112,7 +117,9 @@ describe("Group test", () => {
|
||||||
|
|
||||||
new GroupDetailPage().checkListSubGroup(groups);
|
new GroupDetailPage().checkListSubGroup(groups);
|
||||||
listingPage.deleteItem(groups[0]);
|
listingPage.deleteItem(groups[0]);
|
||||||
|
modalUtils.checkModalTitle("Delete group?").confirmModal();
|
||||||
listingPage.deleteItem(groups[1]);
|
listingPage.deleteItem(groups[1]);
|
||||||
|
modalUtils.checkModalTitle("Delete group?").confirmModal();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Group search", () => {
|
it("Group search", () => {
|
||||||
|
|
|
@ -265,6 +265,7 @@ describe("User Fed LDAP mapper tests", () => {
|
||||||
it("Cleanup - delete group", () => {
|
it("Cleanup - delete group", () => {
|
||||||
sidebarPage.goToGroups();
|
sidebarPage.goToGroups();
|
||||||
listingPage.deleteItem(groupName);
|
listingPage.deleteItem(groupName);
|
||||||
|
modalUtils.confirmModal();
|
||||||
masthead.checkNotificationMessage("Group deleted");
|
masthead.checkNotificationMessage("Group deleted");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ export const GroupBreadCrumbs = () => {
|
||||||
{group.name}
|
{group.name}
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
{subGroups.length - 1 === i && <>{group.name}</>}
|
{subGroups.length - 1 === i && <>{t("groups:groupDetails")}</>}
|
||||||
</BreadcrumbItem>
|
</BreadcrumbItem>
|
||||||
))}
|
))}
|
||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
|
|
|
@ -129,7 +129,7 @@ exports[`Group BreadCrumbs tests couple of crumbs 1`] = `
|
||||||
</svg>
|
</svg>
|
||||||
</AngleRightIcon>
|
</AngleRightIcon>
|
||||||
</span>
|
</span>
|
||||||
active group
|
Group details
|
||||||
</li>
|
</li>
|
||||||
</BreadcrumbItem>
|
</BreadcrumbItem>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
|
@ -5,11 +5,13 @@ import _ from "lodash";
|
||||||
import {
|
import {
|
||||||
AlertVariant,
|
AlertVariant,
|
||||||
Button,
|
Button,
|
||||||
|
ButtonVariant,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
DropdownItem,
|
DropdownItem,
|
||||||
KebabToggle,
|
KebabToggle,
|
||||||
ToolbarItem,
|
ToolbarItem,
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
|
import { cellWidth } from "@patternfly/react-table";
|
||||||
import { UsersIcon } from "@patternfly/react-icons";
|
import { UsersIcon } from "@patternfly/react-icons";
|
||||||
|
|
||||||
import type GroupRepresentation from "keycloak-admin/lib/defs/groupRepresentation";
|
import type GroupRepresentation from "keycloak-admin/lib/defs/groupRepresentation";
|
||||||
|
@ -22,6 +24,7 @@ import { GroupsModal } from "./GroupsModal";
|
||||||
import { getLastId } from "./groupIdUtils";
|
import { getLastId } from "./groupIdUtils";
|
||||||
import { MoveGroupDialog } from "./MoveGroupDialog";
|
import { MoveGroupDialog } from "./MoveGroupDialog";
|
||||||
import { useSubGroups } from "./SubGroupsContext";
|
import { useSubGroups } from "./SubGroupsContext";
|
||||||
|
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
||||||
|
|
||||||
type GroupTableData = GroupRepresentation & {
|
type GroupTableData = GroupRepresentation & {
|
||||||
membersLength?: number;
|
membersLength?: number;
|
||||||
|
@ -71,27 +74,22 @@ export const GroupTable = () => {
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteGroup = async (group: GroupRepresentation) => {
|
const multiDelete = async () => {
|
||||||
try {
|
try {
|
||||||
|
for (const group of selectedRows) {
|
||||||
await adminClient.groups.del({
|
await adminClient.groups.del({
|
||||||
id: group.id!,
|
id: group.id!,
|
||||||
});
|
});
|
||||||
addAlert(t("groupDelete"), AlertVariant.success);
|
}
|
||||||
|
addAlert(
|
||||||
|
t("groupDeleted", { count: selectedRows.length }),
|
||||||
|
AlertVariant.success
|
||||||
|
);
|
||||||
|
setSelectedRows([]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
addAlert(t("groupDeleteError", { error }), AlertVariant.danger);
|
addAlert(t("groupDeleteError", { error }), AlertVariant.danger);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const multiDelete = async () => {
|
|
||||||
if (selectedRows!.length !== 0) {
|
|
||||||
const chainedPromises = selectedRows!.map((group) => deleteGroup(group));
|
|
||||||
|
|
||||||
await Promise.all(chainedPromises);
|
|
||||||
addAlert(t("groupsDeleted"), AlertVariant.success);
|
|
||||||
setSelectedRows([]);
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const GroupNameCell = (group: GroupTableData) => (
|
const GroupNameCell = (group: GroupTableData) => (
|
||||||
|
@ -120,8 +118,17 @@ export const GroupTable = () => {
|
||||||
setIsCreateModalOpen(!isCreateModalOpen);
|
setIsCreateModalOpen(!isCreateModalOpen);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
||||||
|
titleKey: t("deleteConfirmTitle", { count: selectedRows.length }),
|
||||||
|
messageKey: t("deleteConfirm", { count: selectedRows.length }),
|
||||||
|
continueButtonLabel: "common:delete",
|
||||||
|
continueButtonVariant: ButtonVariant.danger,
|
||||||
|
onConfirm: multiDelete,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<DeleteConfirm />
|
||||||
<KeycloakDataTable
|
<KeycloakDataTable
|
||||||
key={`${id}${key}`}
|
key={`${id}${key}`}
|
||||||
onSelect={(rows) => setSelectedRows([...rows])}
|
onSelect={(rows) => setSelectedRows([...rows])}
|
||||||
|
@ -143,7 +150,10 @@ export const GroupTable = () => {
|
||||||
<ToolbarItem>
|
<ToolbarItem>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
toggle={
|
toggle={
|
||||||
<KebabToggle onToggle={() => setIsKebabOpen(!isKebabOpen)} />
|
<KebabToggle
|
||||||
|
onToggle={() => setIsKebabOpen(!isKebabOpen)}
|
||||||
|
isDisabled={selectedRows!.length === 0}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
isOpen={isKebabOpen}
|
isOpen={isKebabOpen}
|
||||||
isPlain
|
isPlain
|
||||||
|
@ -152,7 +162,7 @@ export const GroupTable = () => {
|
||||||
key="action"
|
key="action"
|
||||||
component="button"
|
component="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
multiDelete();
|
toggleDeleteDialog();
|
||||||
setIsKebabOpen(false);
|
setIsKebabOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -174,8 +184,8 @@ export const GroupTable = () => {
|
||||||
{
|
{
|
||||||
title: t("common:delete"),
|
title: t("common:delete"),
|
||||||
onRowClick: async (group: GroupRepresentation) => {
|
onRowClick: async (group: GroupRepresentation) => {
|
||||||
await deleteGroup(group);
|
setSelectedRows([group]);
|
||||||
refresh();
|
toggleDeleteDialog();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -185,6 +195,7 @@ export const GroupTable = () => {
|
||||||
name: "name",
|
name: "name",
|
||||||
displayKey: "groups:groupName",
|
displayKey: "groups:groupName",
|
||||||
cellRenderer: GroupNameCell,
|
cellRenderer: GroupNameCell,
|
||||||
|
transforms: [cellWidth(15)],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "members",
|
name: "members",
|
||||||
|
|
|
@ -97,7 +97,7 @@ export const GroupsSection = () => {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<ViewHeader
|
<ViewHeader
|
||||||
titleKey="groups:groups"
|
titleKey={!id ? "groups:groups" : currentGroup()?.name!}
|
||||||
subKey={!id ? "groups:groupsDescription" : ""}
|
subKey={!id ? "groups:groupsDescription" : ""}
|
||||||
divider={!id}
|
divider={!id}
|
||||||
dropdownItems={
|
dropdownItems={
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"groups": {
|
"groups": {
|
||||||
"groups": "Groups",
|
"groups": "Groups",
|
||||||
|
"groupDetails": "Group details",
|
||||||
"childGroups": "Child groups",
|
"childGroups": "Child groups",
|
||||||
"createGroup": "Create group",
|
"createGroup": "Create group",
|
||||||
"groupName": "Group name",
|
"groupName": "Group name",
|
||||||
|
@ -48,8 +49,12 @@
|
||||||
"noGroupsInThisRealmInstructions": "You haven't created any groups in this realm. Create a group to get started.",
|
"noGroupsInThisRealmInstructions": "You haven't created any groups in this realm. Create a group to get started.",
|
||||||
"noGroupsInThisSubGroup": "No groups in this sub group",
|
"noGroupsInThisSubGroup": "No groups in this sub group",
|
||||||
"noGroupsInThisSubGroupInstructions": "You haven't created any groups in this sub group.",
|
"noGroupsInThisSubGroupInstructions": "You haven't created any groups in this sub group.",
|
||||||
"groupDelete": "Group deleted",
|
"deleteConfirmTitle": "Delete group?",
|
||||||
"groupsDeleted": "Groups deleted",
|
"deleteConfirmTitle_plural": "Delete groups?",
|
||||||
|
"deleteConfirm": "Are you sure you want to delete this group",
|
||||||
|
"deleteConfirm_plural": "Are you sure you want to delete this groups.",
|
||||||
|
"groupDeleted": "Group deleted",
|
||||||
|
"groupDeleted_plural": "Groups deleted",
|
||||||
"groupDeleteError": "Error deleting group {error}",
|
"groupDeleteError": "Error deleting group {error}",
|
||||||
"attributes": "Attributes",
|
"attributes": "Attributes",
|
||||||
"groupUpdated": "Group updated",
|
"groupUpdated": "Group updated",
|
||||||
|
|
Loading…
Reference in a new issue