Skip to content

Commit 6985fa3

Browse files
committed
MC-3653: Can Drag & Drop Child Content Types Into Hidden Content Types
- Block new content types being dropped into hidden content types - Block dragging existing content types into hidden content types - Fix display label z-index
1 parent 01063b5 commit 6985fa3

File tree

12 files changed

+96
-21
lines changed

12 files changed

+96
-21
lines changed

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/DragAndDropActionGroup.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="../../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="dragContentTypeToStage">
1212
<arguments>
1313
<argument name="contentType"/>
@@ -55,6 +55,22 @@
5555
<waitForElementVisible time="10" selector="{{PageBuilderStage.contentTypeInStageByIndex(contentType.role, contentTypeIndex)}}" stepKey="waitForContentTypeInStage" />
5656
<waitForPageLoad stepKey="waitForToolbarsToLoad" time="30"/>
5757
</actionGroup>
58+
<actionGroup name="dragContentTypeToHiddenContainer">
59+
<arguments>
60+
<argument name="contentType"/>
61+
<argument name="contentTypeIndex" defaultValue="1" type="string"/>
62+
<argument name="containerTargetType"/>
63+
<argument name="containerTargetIndex" defaultValue="1" type="string"/>
64+
<argument name="offsetXCoordinate" defaultValue="null" type="string"/>
65+
<argument name="offsetYCoordinate" defaultValue="null" type="string"/>
66+
</arguments>
67+
<click selector="{{PageBuilderPanel.searchPanel}}" stepKey="lostFocus"/>
68+
<waitForElementVisible time="30" selector="{{PageBuilderPanel.draggableContentTypeInPanel(contentType.name)}}" stepKey="waitForContentTypeInPanel"/>
69+
<dragAndDrop selector1="{{PageBuilderPanel.draggableContentTypeInPanel(contentType.name)}}" selector2="{{PageBuilderStage.contentTypeContainer(containerTargetType.role, containerTargetIndex)}}" x="{{offsetXCoordinate}}" y="{{offsetYCoordinate}}" stepKey="dropContentTypeIntoStage"/>
70+
<waitForPageLoad stepKey="waitForAnimation" time="30"/>
71+
<waitForElementNotVisible time="10" selector="{{PageBuilderStage.contentTypeInStageByIndex(contentType.role, contentTypeIndex)}}" stepKey="waitForContentTypeNotOnStage" />
72+
<dontSeeElementInDOM selector="{{PageBuilderStage.contentTypeInStageByIndex(contentType.role, contentTypeIndex)}}" stepKey="dontSeeElementInContainer" />
73+
</actionGroup>
5874
<actionGroup name="dragContentTypeToContainerAndExpectEditPanel">
5975
<arguments>
6076
<argument name="contentType"/>

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderRowTest.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,17 @@
17521752
<actionGroup ref="validateOnHoverNoOptionMenu" stepKey="verifyHeadingHasNoOptionMenuAfterSave">
17531753
<argument name="contentType" value="PageBuilderHeadingContentType"/>
17541754
</actionGroup>
1755+
<!-- Verify we cannot drop content types into hidden containers -->
1756+
<comment userInput="Verify we cannot drop content types into hidden containers" stepKey="commentDropIntoContainer"/>
1757+
<actionGroup ref="expandPageBuilderPanelGroup" stepKey="expandPageBuilderPanelGroup1">
1758+
<argument name="group" value="PageBuilderHeadingContentType"/>
1759+
</actionGroup>
1760+
<actionGroup ref="dragContentTypeToHiddenContainer" stepKey="dragHeaderToRow2">
1761+
<argument name="contentType" value="PageBuilderHeadingContentType"/>
1762+
<argument name="contentTypeIndex" value="2"/>
1763+
<argument name="containerTargetType" value="PageBuilderRowContentType"/>
1764+
<argument name="containerTargetIndex" value="1"/>
1765+
</actionGroup>
17551766
<!-- Validate store front -->
17561767
<comment userInput="Validate content type is disabled on storefront" stepKey="commentValidateHiddenStorefront"/>
17571768
<openNewTab stepKey="openNewTab" />

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderTabGroupTests.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,17 @@
896896
<actionGroup ref="validateOnHoverNoOptionMenu" stepKey="verifyHeadingHasNoOptionMenuAfterSave">
897897
<argument name="contentType" value="PageBuilderHeadingContentType"/>
898898
</actionGroup>
899+
<!-- Verify we cannot drop content types into hidden containers -->
900+
<comment userInput="Verify we cannot drop content types into hidden containers" stepKey="commentDropIntoContainer"/>
901+
<actionGroup ref="expandPageBuilderPanelGroup" stepKey="expandPageBuilderPanelGroup1">
902+
<argument name="group" value="PageBuilderHeadingContentType"/>
903+
</actionGroup>
904+
<actionGroup ref="dragContentTypeToHiddenContainer" stepKey="dragHeaderToTabs2">
905+
<argument name="contentType" value="PageBuilderHeadingContentType"/>
906+
<argument name="contentTypeIndex" value="2"/>
907+
<argument name="containerTargetType" value="PageBuilderTabsContentType"/>
908+
<argument name="containerTargetIndex" value="1"/>
909+
</actionGroup>
899910
<!-- Validate store front -->
900911
<comment userInput="Validate content type is disabled on storefront" stepKey="commentValidateHiddenStorefront"/>
901912
<openNewTab stepKey="openNewTab" />

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/_preview.less

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
transition: opacity 200ms, top 200ms, visibility 200ms;
175175
visibility: hidden;
176176
width: 100%;
177-
z-index: 11;
177+
z-index: 15;
178178
}
179179
}
180180

@@ -596,4 +596,9 @@
596596
opacity: 1;
597597
visibility: visible;
598598
}
599+
.pagebuilder-drop-indicator,
600+
.pagebuilder-content-type.type-container.empty-container > .content-type-container:before {
601+
opacity: 0 !important;
602+
visibility: hidden !important;
603+
}
599604
}

app/code/Magento/PageBuilder/view/adminhtml/web/js/collection.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type-collection.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/column-group/preview.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/drag-drop/sortable.js

Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/collection.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
*/
55

66
import ko from "knockout";
7+
import ContentTypeCollectionInterface from "./content-type-collection.d";
8+
import ContentTypeInterface from "./content-type.d";
79
import { moveArrayItemIntoArray, removeArrayItem } from "./utils/array";
810

11+
912
/**
1013
* @api
1114
*/
@@ -19,9 +22,9 @@ export default class Collection {
1922
/**
2023
* Return the children of the current element
2124
*
22-
* @returns {KnockoutObservableArray<ContentTypeInterface>}
25+
* @returns {KnockoutObservableArray<ContentTypeInterface | ContentTypeCollectionInterface>}
2326
*/
24-
public getChildren(): KnockoutObservableArray<any> {
27+
public getChildren(): KnockoutObservableArray<ContentTypeInterface | ContentTypeCollectionInterface> {
2528
return this.children;
2629
}
2730

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type-collection.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ export default class ContentTypeCollection extends ContentType implements Conten
3434
/**
3535
* Return the children of the current element
3636
*
37-
* @returns {KnockoutObservableArray<ContentTypeInterface>}
37+
* @returns {KnockoutObservableArray<ContentTypeInterface | ContentTypeCollectionInterface>}
3838
*/
39-
public getChildren(): KnockoutObservableArray<ContentTypeInterface> {
39+
public getChildren(): KnockoutObservableArray<ContentTypeInterface | ContentTypeCollectionInterface> {
4040
return this.collection.getChildren();
4141
}
4242

4343
/**
4444
* Add a child into the observable array
4545
*
46-
* @param child
47-
* @param index
46+
* @param {ContentTypeInterface | ContentTypeCollectionInterface} child
47+
* @param {number} index
4848
*/
49-
public addChild(child: ContentTypeInterface, index?: number): void {
49+
public addChild(child: ContentTypeInterface | ContentTypeCollectionInterface, index?: number): void {
5050
child.parent = this;
5151
this.collection.addChild(child, index);
5252

@@ -71,11 +71,11 @@ export default class ContentTypeCollection extends ContentType implements Conten
7171
*
7272
* @param children
7373
*/
74-
public setChildren(children: KnockoutObservableArray<ContentTypeInterface>) {
74+
public setChildren(children: KnockoutObservableArray<ContentTypeInterface | ContentTypeCollectionInterface>) {
7575
this.collection.setChildren(children);
7676
}
7777

78-
get children() {
78+
get children(): KnockoutObservableArray<ContentTypeInterface | ContentTypeCollectionInterface> {
7979
return this.collection.getChildren();
8080
}
8181
}

0 commit comments

Comments
 (0)