Skip to content

Commit 674bd06

Browse files
committed
Merge branch 'develop' of github.com:magento-epam/magento2-page-builder into MC-35104
2 parents 8ade9e3 + 9721eab commit 674bd06

File tree

718 files changed

+2660
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

718 files changed

+2660
-252
lines changed

app/code/Magento/PageBuilder/Component/Form/Element/Wysiwyg.php

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77

88
namespace Magento\PageBuilder\Component\Form\Element;
99

10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Data\FormFactory;
1112
use Magento\Framework\View\Element\UiComponent\ContextInterface;
13+
use Magento\PageBuilder\Model\View\File\Collector\PageBuilder;
1214
use Magento\Ui\Component\Wysiwyg\ConfigInterface;
1315
use Magento\Catalog\Api\CategoryAttributeRepositoryInterface;
1416
use Magento\Framework\Exception\NoSuchEntityException;
17+
use Magento\PageBuilder\Model\Config as PageBuilderConfig;
1518
use Magento\PageBuilder\Model\State as PageBuilderState;
16-
use \Magento\PageBuilder\Model\Stage\Config as Config;
19+
use Magento\PageBuilder\Model\Stage\Config as Config;
1720

1821
/**
1922
* Updates wysiwyg element with Page Builder specific config
@@ -23,7 +26,7 @@
2326
class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
2427
{
2528
/**
26-
* Wysiwyg constructor.
29+
* WYSIWYG Constructor
2730
*
2831
* @param ContextInterface $context
2932
* @param FormFactory $formFactory
@@ -34,6 +37,11 @@ class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
3437
* @param array $components
3538
* @param array $data
3639
* @param array $config
40+
* @param PageBuilderConfig|null $pageBuilderConfig
41+
* @param bool $overrideSnapshot
42+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
43+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
44+
* @throws \Magento\Framework\Exception\NoSuchEntityException
3745
*/
3846
public function __construct(
3947
ContextInterface $context,
@@ -44,20 +52,25 @@ public function __construct(
4452
Config $stageConfig,
4553
array $components = [],
4654
array $data = [],
47-
array $config = []
55+
array $config = [],
56+
PageBuilderConfig $pageBuilderConfig = null,
57+
bool $overrideSnapshot = false
4858
) {
4959
$wysiwygConfigData = isset($config['wysiwygConfigData']) ? $config['wysiwygConfigData'] : [];
60+
5061
// If a dataType is present we're dealing with an attribute
5162
if (isset($config['dataType'])) {
5263
try {
5364
$attribute = $attrRepository->get($data['name']);
65+
5466
if ($attribute) {
5567
$config['wysiwyg'] = (bool)$attribute->getIsWysiwygEnabled();
5668
}
5769
} catch (NoSuchEntityException $e) {
58-
// This model is used by non product attributes
70+
$config['wysiwyg'] = true;
5971
}
6072
}
73+
6174
$isEnablePageBuilder = isset($wysiwygConfigData['is_pagebuilder_enabled'])
6275
&& !$wysiwygConfigData['is_pagebuilder_enabled']
6376
|| false;
@@ -66,15 +79,27 @@ public function __construct(
6679
$data['config']['component'] = 'Magento_PageBuilder/js/form/element/wysiwyg';
6780

6881
// Override the templates to include our KnockoutJS code
69-
$data['config']['template'] = 'Magento_PageBuilder/form/element/wysiwyg';
82+
$data['config']['template'] = 'ui/form/field';
7083
$data['config']['elementTmpl'] = 'Magento_PageBuilder/form/element/wysiwyg';
7184
$wysiwygConfigData = $stageConfig->getConfig();
85+
86+
if ($overrideSnapshot) {
87+
$pageBuilderConfig = $pageBuilderConfig ?: ObjectManager::getInstance()->get(PageBuilderConfig::class);
88+
$wysiwygConfigData['pagebuilder_content_snapshot'] = $pageBuilderConfig->isContentPreviewEnabled();
89+
}
90+
91+
// Add Classes for Page Builder Stage
92+
if (isset($wysiwygConfigData['pagebuilder_content_snapshot'])
93+
&& $wysiwygConfigData['pagebuilder_content_snapshot']) {
94+
$data['config']['additionalClasses'] = 'admin__field-wide admin__field-page-builder';
95+
}
96+
7297
$data['config']['wysiwygConfigData'] = isset($config['wysiwygConfigData']) ?
7398
array_replace_recursive($config['wysiwygConfigData'], $wysiwygConfigData) :
7499
$wysiwygConfigData;
75100
$wysiwygConfigData['activeEditorPath'] = 'Magento_PageBuilder/pageBuilderAdapter';
101+
76102
$config['wysiwygConfigData'] = $wysiwygConfigData;
77-
$wysiwygConfigData['activeEditorPath'] = 'Magento_PageBuilder/pageBuilderAdapter';
78103
}
79104

80105
parent::__construct($context, $formFactory, $wysiwygConfig, $components, $data, $config);

app/code/Magento/PageBuilder/Model/Config.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class Config extends \Magento\Framework\Config\Data implements \Magento\PageBuil
1717
{
1818
const IS_PAGEBUILDER_ENABLED = 'cms/pagebuilder/enabled';
1919

20+
private const IS_PAGEBUILDER_CONTENT_PREVIEW_ENABLED = 'cms/pagebuilder/enable_content_preview';
21+
2022
/**
2123
* @var ScopeConfigInterface
2224
*/
@@ -66,7 +68,19 @@ public function getContentTypes(): array
6668
public function isEnabled(): bool
6769
{
6870
return (bool)$this->scopeConfig->getValue(
69-
\Magento\PageBuilder\Model\Config::IS_PAGEBUILDER_ENABLED
71+
self::IS_PAGEBUILDER_ENABLED
72+
);
73+
}
74+
75+
/**
76+
* Returns Configuration Setting for Page Builder Content Preview
77+
*
78+
* @return bool
79+
*/
80+
public function isContentPreviewEnabled(): bool
81+
{
82+
return (bool) $this->scopeConfig->getValue(
83+
self::IS_PAGEBUILDER_CONTENT_PREVIEW_ENABLED
7084
);
7185
}
7286
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types = 1);
8+
9+
namespace Magento\PageBuilder\Plugin\Catalog\Ui\DataProvider\Product\Form\Modifier;
10+
11+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
12+
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav as EavModifier;
13+
use Magento\Framework\Stdlib\ArrayManager;
14+
use Magento\PageBuilder\Model\Config;
15+
16+
/**
17+
* Data Provider for EAV Attributes on Product Page
18+
*/
19+
class EavPlugin
20+
{
21+
public const META_ATTRIBUTE_CONFIG_PATH = 'arguments/data/config';
22+
23+
/**
24+
* @var ArrayManager
25+
*/
26+
private $arrayManager;
27+
28+
/**
29+
* @var Config
30+
*/
31+
private $config;
32+
33+
/**
34+
* @param ArrayManager $arrayManager
35+
* @param Config $config
36+
*/
37+
public function __construct(
38+
ArrayManager $arrayManager,
39+
Config $config
40+
) {
41+
$this->arrayManager = $arrayManager;
42+
$this->config = $config;
43+
}
44+
45+
/**
46+
* Setup Attribute Meta
47+
*
48+
* @param EavModifier $subject
49+
* @param array $result
50+
* @param ProductAttributeInterface $attribute
51+
* @param string $groupCode
52+
* @param int $sortOrder
53+
* @return array
54+
*
55+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
56+
*/
57+
public function afterSetupAttributeMeta(
58+
EavModifier $subject,
59+
$result,
60+
ProductAttributeInterface $attribute,
61+
$groupCode,
62+
$sortOrder
63+
) {
64+
$meta = $result;
65+
66+
if ($this->config->isContentPreviewEnabled() && $attribute->getData('is_pagebuilder_enabled')) {
67+
$meta = $this->arrayManager->merge(
68+
static::META_ATTRIBUTE_CONFIG_PATH,
69+
$result,
70+
[
71+
'additionalClasses' => 'admin__field-wide admin__field-page-builder'
72+
]
73+
);
74+
}
75+
76+
return $meta;
77+
}
78+
79+
/**
80+
* Setup Attribute Container Meta
81+
*
82+
* @param EavModifier $subject
83+
* @param array $result
84+
* @param ProductAttributeInterface $attribute
85+
* @return array
86+
*
87+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
88+
*/
89+
public function afterSetupAttributeContainerMeta(
90+
EavModifier $subject,
91+
$result,
92+
ProductAttributeInterface $attribute
93+
) {
94+
$containerMeta = $result;
95+
96+
if ($this->config->isContentPreviewEnabled() && $attribute->getData('is_pagebuilder_enabled')) {
97+
$containerMeta = $this->arrayManager->merge(
98+
static::META_ATTRIBUTE_CONFIG_PATH,
99+
$result,
100+
[
101+
'additionalFieldsetClasses' => [
102+
'admin__field-wide' => true,
103+
'admin__fieldset-page-builder' => true
104+
],
105+
'template' => 'Magento_PageBuilder/form/components/group/group'
106+
]
107+
);
108+
}
109+
110+
return $containerMeta;
111+
}
112+
}

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/AdminActionGroup/SwitchToPageBuilderStageActionGroup.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@
1111
<arguments>
1212
<argument name="sectionSelector" defaultValue="{{CmsNewPagePageContentSection.header}}" type="string"/>
1313
<argument name="sectionDependentSelector" defaultValue="{{CmsNewPagePageContentSection.header}}._show" type="string"/>
14+
<argument name="snapshotSelector" defaultValue="{{PageBuilderStage.snapshot}}" type="string"/>
15+
<argument name="editButtonSelector" defaultValue="{{PageBuilderStage.editButtonSelector}}" type="string"/>
1416
<argument name="rowIndex" defaultValue="1" type="string"/>
1517
</arguments>
1618
<waitForElementVisible time="30" selector="{{sectionSelector}}" stepKey="waitForSection"/>
1719
<conditionalClick selector="{{sectionSelector}}" dependentSelector="{{sectionDependentSelector}}" visible="false" stepKey="expandSection"/>
1820
<waitForPageLoad time="30" stepKey="waitForStageToLoad"/>
21+
<waitForElementVisible time="30" selector="{{snapshotSelector}}" stepKey="waitForSnapshot"/>
22+
<waitForElementVisible time="30" selector="{{editButtonSelector}}" stepKey="waitForEditButton"/>
23+
<click selector="{{editButtonSelector}}" stepKey="clickEditButton"/>
24+
<waitForPageLoad stepKey="waitForFullScreenAnimation"/>
1925
<!-- Wait for the first row to be added into the stage for it to be "ready" -->
2026
<waitForElementNotVisible selector="{{PageBuilderStage.stageLoading}}" stepKey="waitForStageLoadingGraphicNotVisible"/>
2127
<waitForElementVisible time="30" selector="{{RowOnStage.base(rowIndex)}}" stepKey="waitForPageBuilderRow"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="switchToPageBuilderStage">
11+
<arguments>
12+
<argument name="sectionSelector" defaultValue="{{CmsNewPagePageContentSection.header}}" type="string"/>
13+
<argument name="sectionDependentSelector" defaultValue="{{CmsNewPagePageContentSection.header}}._show" type="string"/>
14+
<argument name="rowIndex" defaultValue="1" type="string"/>
15+
</arguments>
16+
<waitForElementVisible time="30" selector="{{sectionSelector}}" stepKey="waitForSection"/>
17+
<conditionalClick selector="{{sectionSelector}}" dependentSelector="{{sectionDependentSelector}}" visible="false" stepKey="expandSection"/>
18+
<waitForPageLoad time="30" stepKey="waitForStageToLoad"/>
19+
<!-- Wait for the first row to be added into the stage for it to be "ready" -->
20+
<waitForElementNotVisible selector="{{PageBuilderStage.stageLoading}}" stepKey="waitForStageLoadingGraphicNotVisible"/>
21+
<waitForElementVisible time="30" selector="{{RowOnStage.base(rowIndex)}}" stepKey="waitForPageBuilderRow"/>
22+
</actionGroup>
23+
</actionGroups>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
9+
<actionGroup name="AdminSetPageBuilderContentPreviewActionGroup">
10+
<annotations>
11+
<description>Sets "Enable Page Builder Content Preview" flag value.</description>
12+
</annotations>
13+
<arguments>
14+
<argument name="enablePageBuilderContentPreview" defaultValue="1" type="string"/>
15+
</arguments>
16+
<magentoCLI command="config:set cms/pagebuilder/enable_content_preview {{enablePageBuilderContentPreview}}" stepKey="setConfig"/>
17+
<magentoCLI command="cache:clean config" stepKey="flushCache"/>
18+
</actionGroup>
19+
</actionGroups>

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/BackgroundConfigurationActionGroup/ValidateParallaxVideoBackgroundWithAllAttributesActionGroup.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
<annotations>
1212
<description>Validates all video background attributes when all attributes are configured and parallax is enabled. Extends: validateVideoBackgroundWithAllAttributes</description>
1313
</annotations>
14+
<arguments>
15+
<argument name="expectedPosition" defaultValue="position: fixed;" type="string"/>
16+
</arguments>
1417
<assertStringContainsString stepKey="assertVideoPosition">
15-
<expectedResult type="string">position: fixed;</expectedResult>
18+
<expectedResult type="string">{{expectedPosition}}</expectedResult>
1619
<actualResult type="variable">$videoStyle</actualResult>
1720
</assertStringContainsString>
1821
<assertStringContainsString stepKey="assertImagePosition">
19-
<expectedResult type="string">position: fixed;</expectedResult>
22+
<expectedResult type="string">{{expectedPosition}}</expectedResult>
2023
<actualResult type="variable">$fallbackImageStyle</actualResult>
2124
</assertStringContainsString>
2225
</actionGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenPageBuilderFromContentPreviewOverlayActionGroup">
11+
<annotations>
12+
<description>Click Page Builder preview overlay to open Page Builder stage.</description>
13+
</annotations>
14+
<waitForElementVisible selector="{{PageBuilderStage.stageOverlay}}" stepKey="waitForStageOverlay"/>
15+
<click selector="{{PageBuilderStage.stageOverlay}}" stepKey="clickOnStageOverlayOnStage"/>
16+
<waitForPageLoad stepKey="waitForPageLoadPageBuilder"/>
17+
<waitForElementVisible selector="{{PageBuilderPanel.layoutMenuSection}}" stepKey="waitForPageBuilderLayoutMenu"/>
18+
<waitForElementVisible selector="{{PageBuilderStage.stageWrapperFullScreen}}" stepKey="waitForPageBuilderFullScreen"/>
19+
</actionGroup>
20+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
9+
<actionGroup name="ClickEditWithPageBuilderButtonActionGroup">
10+
<annotations>
11+
<description>Validates that Page Builder opens (full screen) using the "Edit with Page Builder" button.</description>
12+
</annotations>
13+
<waitForElementVisible selector="{{PageBuilderStage.editWithPageBuilderButton}}" stepKey="waitForEditWithPageBuilderButton"/>
14+
<click selector="{{PageBuilderStage.editWithPageBuilderButton}}" stepKey="clickEditWithPageBuilderButton"/>
15+
<waitForPageLoad stepKey="waitForFullScreenAnimation"/>
16+
<seeElement selector="{{PageBuilderStage.stageWrapperFullScreen}}" stepKey="seeStageFullScreen"/>
17+
<seeElement selector="{{PageBuilderStage.exitFullScreen}}" stepKey="seeExitFullScreenButton"/>
18+
</actionGroup>
19+
</actionGroups>

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/StageActionGroup/OpenPageBuilderFullScreenActionGroup.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
109
<actionGroup name="openPageBuilderFullScreen">
1110
<waitForElementVisible selector="{{PageBuilderStage.openFullScreen}}" stepKey="waitForFullScreenButton"/>
1211
<click selector="{{PageBuilderStage.openFullScreen}}" stepKey="clickFullScreenButton"/>

0 commit comments

Comments
 (0)