can't move groups to the root level (#485)

* can't move groups to the root level

disabled "Move" button on root level

* can now move groups to root

* added move to root test
This commit is contained in:
Erik Jan de Wit 2021-04-07 19:58:29 +02:00 committed by GitHub
parent 408caf6d0f
commit 5142d1b4bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 13 deletions

View file

@ -94,6 +94,21 @@ describe("Group test", () => {
sidebarPage.goToGroups(); sidebarPage.goToGroups();
listingPage.deleteItem(targetGroupName); listingPage.deleteItem(targetGroupName);
}); });
it("Should move group to root", async () => {
const groups = ["group1", "group2"];
await new AdminClient().createSubGroups(groups);
sidebarPage.goToGroups();
listingPage.goToItemDetails(groups[0]);
cy.wait(2000);
listingPage.clickRowDetails(groups[1]).clickDetailMenu("Move to");
moveGroupModal.clickRoot().clickMove();
sidebarPage.goToGroups();
new GroupDetailPage().checkListSubGroup(groups);
listingPage.deleteItem(groups[0]);
});
}); });
describe("Group details", () => { describe("Group details", () => {

View file

@ -10,7 +10,7 @@ export default class ListingPage {
constructor() { constructor() {
this.searchInput = '.pf-c-toolbar__item [type="search"]'; this.searchInput = '.pf-c-toolbar__item [type="search"]';
this.itemsRows = ".pf-c-page__main-section table"; this.itemsRows = "table";
this.itemRowDrpDwn = ".pf-c-dropdown > button"; this.itemRowDrpDwn = ".pf-c-dropdown > button";
this.exportBtn = '[role="menuitem"]:nth-child(1)'; this.exportBtn = '[role="menuitem"]:nth-child(1)';
this.deleteBtn = '[role="menuitem"]:nth-child(2)'; this.deleteBtn = '[role="menuitem"]:nth-child(2)';

View file

@ -7,6 +7,11 @@ export default class MoveGroupModal {
return this; return this;
} }
clickRoot() {
cy.get(".pf-c-breadcrumb__item > button").click();
return this;
}
checkTitle(title: string) { checkTitle(title: string) {
cy.get(this.title).should("have.text", title); cy.get(this.title).should("have.text", title);
return this; return this;

View file

@ -171,7 +171,9 @@ export const GroupTable = () => {
{ {
title: t("common:delete"), title: t("common:delete"),
onRowClick: async (group: GroupRepresentation) => { onRowClick: async (group: GroupRepresentation) => {
return deleteGroup(group); await deleteGroup(group);
refresh();
return true;
}, },
}, },
]} ]}
@ -214,7 +216,11 @@ export const GroupTable = () => {
delete move.membersLength; delete move.membersLength;
try { try {
try { try {
await adminClient.groups.setOrCreateChild({ id }, move); if (id) {
await adminClient.groups.setOrCreateChild({ id }, move);
} else {
await adminClient.groups.create(move);
}
} catch (error) { } catch (error) {
if (error.response) { if (error.response) {
throw error; throw error;

View file

@ -29,7 +29,7 @@ import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
type MoveGroupDialogProps = { type MoveGroupDialogProps = {
group: GroupRepresentation; group: GroupRepresentation;
onClose: () => void; onClose: () => void;
onMove: (groupId: string) => void; onMove: (groupId: string | undefined) => void;
}; };
export const MoveGroupDialog = ({ export const MoveGroupDialog = ({
@ -73,14 +73,10 @@ export const MoveGroupDialog = ({
return ( return (
<Modal <Modal
variant={ModalVariant.large} variant={ModalVariant.large}
title={ title={t("moveToGroup", {
currentGroup() group1: group.name,
? t("moveToGroup", { group2: currentGroup() ? currentGroup().name : t("root"),
group1: group.name, })}
group2: currentGroup().name,
})
: t("moveTo")
}
isOpen={true} isOpen={true}
onClose={onClose} onClose={onClose}
actions={[ actions={[
@ -89,7 +85,7 @@ export const MoveGroupDialog = ({
key="confirm" key="confirm"
variant="primary" variant="primary"
form="group-form" form="group-form"
onClick={() => onMove(currentGroup().id!)} onClick={() => onMove(currentGroup()?.id)}
> >
{t("moveHere")} {t("moveHere")}
</Button>, </Button>,

View file

@ -24,6 +24,7 @@
"path": "Path", "path": "Path",
"moveTo": "Move to", "moveTo": "Move to",
"moveToGroup": "Move {{group1}} to {{group2}}", "moveToGroup": "Move {{group1}} to {{group2}}",
"root": "Root",
"moveHere": "Move here", "moveHere": "Move here",
"moveGroupEmpty": "No sub groups", "moveGroupEmpty": "No sub groups",
"moveGroupEmptyInstructions": "There are no sub groups, select 'Move here' to move the selected group as a subgroup of this group", "moveGroupEmptyInstructions": "There are no sub groups, select 'Move here' to move the selected group as a subgroup of this group",