Skip to content

Commit 90d4894

Browse files
authored
Merge branch 'develop' into MC-38568
2 parents 70228cd + 404f98b commit 90d4894

File tree

1,100 files changed

+9694
-1437
lines changed

Some content is hidden

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

1,100 files changed

+9694
-1437
lines changed

app/code/Magento/AwsS3PageBuilder/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"description": "Aws S3 Page Builder module",
44
"require": {
55
"magento/framework": "*",
6-
"php": "~7.3.0||~7.4.0",
7-
"phpgt/dom": "2.1.6"
6+
"php": "~7.3.0||~7.4.0"
87
},
98
"suggest": {
109
"magento/module-page-builder": "*",

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
4545
* @param array $config
4646
* @param PageBuilderConfig|null $pageBuilderConfig
4747
* @param bool $overrideSnapshot
48-
* @param ViewConfigInterface $viewConfig
4948
* @param Repository $assetRepo
5049
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5150
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -64,10 +63,8 @@ public function __construct(
6463
array $config = [],
6564
PageBuilderConfig $pageBuilderConfig = null,
6665
bool $overrideSnapshot = false,
67-
ViewConfigInterface $viewConfig = null,
6866
Repository $assetRepo = null
6967
) {
70-
$viewConfig = $viewConfig ?: ObjectManager::getInstance()->get(ViewConfigInterface::class);
7168
$this->assetRepo = $assetRepo ?: ObjectManager::getInstance()->get(Repository::class);
7269
$wysiwygConfigData = isset($config['wysiwygConfigData']) ? $config['wysiwygConfigData'] : [];
7370

@@ -97,10 +94,6 @@ public function __construct(
9794
$wysiwygConfigData = $stageConfig->getConfig();
9895
$wysiwygConfigData['pagebuilder_button'] = true;
9996
$wysiwygConfigData['pagebuilder_content_snapshot'] = true;
100-
$wysiwygConfigData['viewports'] = $viewConfig->getViewConfig()->getVarValue(
101-
'Magento_PageBuilder',
102-
'breakpoints'
103-
);
10497
$wysiwygConfigData = $this->processBreakpointsIcons($wysiwygConfigData);
10598

10699
if ($overrideSnapshot) {

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

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function convert($source): array
5252
*
5353
* @param \DOMDocument $source
5454
* @return array
55+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5556
*/
5657
private function convertTypes(\DOMDocument $source): array
5758
{
@@ -83,6 +84,8 @@ private function convertTypes(\DOMDocument $source): array
8384
'defaultPolicy' => $this->getAttributeValue($childNode, 'default_policy'),
8485
'types' => $this->convertParentChildData($childNode, 'child')
8586
];
87+
} elseif ('breakpoints' === $childNode->nodeName) {
88+
$typesData[$name][$childNode->nodeName] = $this->convertBreakpoints($childNode);
8689
} else {
8790
$typesData[$name][$childNode->nodeName] = $childNode->nodeValue;
8891
}
@@ -99,6 +102,40 @@ private function convertTypes(\DOMDocument $source): array
99102
return array_merge_recursive($typesData, $allowedParents);
100103
}
101104

105+
/**
106+
* Convert breakpoints data
107+
*
108+
* @param \DOMElement $childNode
109+
* @return array
110+
* @throws \InvalidArgumentException
111+
*/
112+
private function convertBreakpoints(\DOMElement $childNode): array
113+
{
114+
$breakpointsData = [];
115+
foreach ($childNode->getElementsByTagName('breakpoint') as $breakpointNode) {
116+
$breakpointName = $breakpointNode->attributes->getNamedItem('name')->nodeValue;
117+
$breakpointsData[$breakpointName] = $this->convertBreakpointData($breakpointNode);
118+
}
119+
return $breakpointsData;
120+
}
121+
122+
/**
123+
* Convert breakpoint data
124+
*
125+
* @param \DOMElement $childNode
126+
* @return array
127+
* @throws \InvalidArgumentException
128+
*/
129+
private function convertBreakpointData(\DOMElement $childNode): array
130+
{
131+
$breakpointsData = [];
132+
$formNode = $childNode->getElementsByTagName('form')->item(0);
133+
if ($formNode && $formNode->nodeValue) {
134+
$breakpointsData['form'] = $formNode->nodeValue;
135+
}
136+
return $breakpointsData;
137+
}
138+
102139
/**
103140
* Convert appearances data
104141
*
@@ -139,10 +176,19 @@ private function convertAppearanceData(\DOMElement $appearanceNode): array
139176
$appearanceData['master_template'] = $this->getAttributeValue($appearanceNode, 'master_template');
140177
$appearanceData['reader'] = $this->getAttributeValue($appearanceNode, 'reader');
141178
$appearanceData['default'] = $this->getAttributeValue($appearanceNode, 'default');
142-
$formNode = $appearanceNode->getElementsByTagName('form')->item(0);
143-
if ($formNode && $formNode->nodeValue) {
179+
180+
foreach ($appearanceNode->childNodes as $node) {
181+
if ($node->nodeName === 'form') {
182+
$formNode = $node;
183+
}
184+
}
185+
if (isset($formNode) && $formNode->nodeValue) {
144186
$appearanceData['form'] = $formNode->nodeValue;
145187
}
188+
$breakpointsNode = $appearanceNode->getElementsByTagName('breakpoints')->item(0);
189+
if ($breakpointsNode && $breakpointsNode->nodeValue) {
190+
$appearanceData['breakpoints'] = $this->convertBreakpoints($breakpointsNode);
191+
}
146192
return $appearanceData;
147193
}
148194

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
1919
*/
2020
protected $_idAttributes = [
2121
self::TYPE_PATH => 'name',
22+
self::TYPE_PATH . '/breakpoints/breakpoint' => 'name',
2223
self::TYPE_PATH . '/parents/parent' => 'name',
2324
self::TYPE_PATH . '/children/child' => 'name',
2425
self::TYPE_PATH . '/appearances/appearance' => 'name',
26+
self::TYPE_PATH . '/appearances/appearance/breakpoints/breakpoint' => 'name',
2527
self::TYPE_PATH . '/appearances/appearance/data' => 'name',
2628
self::TYPE_PATH . '/appearances/appearance/elements/element' => 'name',
2729
self::TYPE_PATH . '/appearances/appearance/elements/element/style'

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

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ public function getConfig()
207207
'can_use_inline_editing_on_stage' => $this->isWysiwygProvisionedForEditingOnStage(),
208208
'widgets' => $this->widgetInitializerConfig->getConfig(),
209209
'breakpoints' => $this->getCachedWidgetBreakpoints(),
210+
'viewports' => $this->getViewports($this->getCachedWidgetBreakpoints()),
211+
'defaultViewport' => $this->getDefaultViewport($this->getCachedWidgetBreakpoints()),
210212
'tinymce' => $this->getCachedTinyMceConfig(),
211213
'acl' => $this->getAcl()
212214
];
@@ -322,6 +324,8 @@ private function getCachedFlattenContentTypeData(string $name, array $contentTyp
322324
* @param array $contentType
323325
*
324326
* @return array
327+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
328+
* @SuppressWarnings(PHPMD.NPathComplexity)
325329
*/
326330
private function flattenContentTypeData(string $name, array $contentType)
327331
{
@@ -339,21 +343,60 @@ private function flattenContentTypeData(string $name, array $contentType)
339343
'master_component' => $contentType['master_component'] ?? self::DEFAULT_MASTER_COMPONENT,
340344
'allowed_parents' => $contentType['allowed_parents'] ?? [],
341345
'appearances' => $contentType['appearances'] ?? [],
346+
'breakpoints' => $contentType['breakpoints'] ?? [],
342347
'additional_data' => isset($contentType['additional_data'])
343348
? $this->additionalDataParser->toArray($contentType['additional_data'])
344349
: [],
345350
'is_system' => isset($contentType['is_system']) && $contentType['is_system'] === 'false' ? false : true
346351
];
347352

353+
$result['breakpoints'] = array_merge_recursive(
354+
$result['breakpoints'],
355+
$this->getBreakpointsFields($result['breakpoints'], 'default')
356+
);
357+
348358
foreach ($result['appearances'] as $key => $appearance) {
349359
if (isset($appearance['form'])) {
350360
$result['fields'][$key . '-appearance'] = $this->uiComponentConfig->getFields($appearance['form']);
351361
}
362+
if (isset($appearance['breakpoints'])) {
363+
$namespace = $key . '-appearance';
364+
if ($appearance['default']) {
365+
$namespace = 'default';
366+
foreach ($appearance['breakpoints'] as $name => $breakpoint) {
367+
if (isset($breakpoint['form'])) {
368+
$result['breakpoints'][$name]['form'] = $breakpoint['form'];
369+
}
370+
}
371+
}
372+
$result['breakpoints'] = array_replace_recursive(
373+
$result['breakpoints'],
374+
$this->getBreakpointsFields($appearance['breakpoints'], $namespace)
375+
);
376+
}
352377
}
353378

354379
return $result;
355380
}
356381

382+
/**
383+
* Get breakpoint fields.
384+
*
385+
* @param array $breakpoints
386+
* @param string $namespace
387+
* @return array
388+
*/
389+
private function getBreakpointsFields(array $breakpoints, string $namespace): array
390+
{
391+
$result = [];
392+
foreach ($breakpoints as $key => $breakpoint) {
393+
if (isset($breakpoint['form'])) {
394+
$result[$key]['fields'][$namespace] = $this->uiComponentConfig->getFields($breakpoint['form'], $key);
395+
}
396+
}
397+
return $result;
398+
}
399+
357400
/**
358401
* Determine if active editor is configured to support inline editing mode
359402
*
@@ -428,4 +471,35 @@ private function saveCache(array $data, string $cacheIdentifier): void
428471
}
429472
$this->cache->save($this->serializer->serialize($data), $cacheIdentifier);
430473
}
474+
475+
/**
476+
* Get viewports.
477+
*
478+
* @param array $breakpoints
479+
* @return array
480+
*/
481+
private function getViewports(array $breakpoints): array
482+
{
483+
$viewports = [];
484+
485+
foreach ($breakpoints as $name => $breakpoint) {
486+
if (isset($breakpoint['stage'])) {
487+
$viewports[$name] = $breakpoint;
488+
}
489+
}
490+
491+
return $viewports;
492+
}
493+
494+
/**
495+
* Get default viewport.
496+
*
497+
* @param array $breakpoints
498+
* @return string
499+
*/
500+
private function getDefaultViewport(array $breakpoints): string
501+
{
502+
$keyIndex = array_search(true, array_column($breakpoints, 'default'));
503+
return $keyIndex === false ? '' : array_keys($breakpoints)[$keyIndex];
504+
}
431505
}

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,31 @@ public function __construct(
3535
* Retrieve fields for UI Component
3636
*
3737
* @param string $componentName
38+
* @param string|null $breakpoint
3839
*
3940
* @return array
41+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
4042
*/
41-
public function getFields($componentName) : array
43+
public function getFields($componentName, $breakpoint = null) : array
4244
{
4345
$componentConfig = $this->configFactory->create(
4446
['componentName' => $componentName]
4547
)->get($componentName);
4648

4749
$fields = $this->iterateComponents(
4850
$componentConfig,
49-
function ($item, $key) {
51+
function ($item, $key) use ($breakpoint) {
52+
$itemConfig = isset($item[Converter::DATA_ARGUMENTS_KEY]['data']['config']) ?
53+
$item[Converter::DATA_ARGUMENTS_KEY]['data']['config'] : [];
5054
// Determine if this item has a formElement key
51-
if (isset($item[Converter::DATA_ARGUMENTS_KEY]['data']['config']['formElement'])
52-
&& !(isset($item[Converter::DATA_ARGUMENTS_KEY]['data']['config']['componentDisabled'])
53-
&& $item[Converter::DATA_ARGUMENTS_KEY]['data']['config']['componentDisabled'] === true)
55+
if (isset($itemConfig['formElement'])
56+
&& !(isset($itemConfig['componentDisabled']) && $itemConfig['componentDisabled'] === true)
57+
&& (!$breakpoint || (
58+
$breakpoint &&
59+
isset($itemConfig['breakpoints']) &&
60+
isset($itemConfig['breakpoints'][$breakpoint]) &&
61+
$itemConfig['breakpoints'][$breakpoint]
62+
))
5463
) {
5564
$elementConfig = $item[Converter::DATA_ARGUMENTS_KEY]['data']['config'];
5665
// If the field has a dataScope use that for the key instead of the name

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<waitForElementVisible time="30" selector="{{editButtonSelector}}" stepKey="waitForEditButton"/>
2323
<click selector="{{editButtonSelector}}" stepKey="clickEditButton"/>
2424
<waitForPageLoad stepKey="waitForFullScreenAnimation"/>
25-
<!-- Wait for the first row to be added into the stage for it to be "ready" -->
2625
<waitForElementNotVisible selector="{{PageBuilderStage.stageLoading}}" stepKey="waitForStageLoadingGraphicNotVisible"/>
27-
<waitForElementVisible time="30" selector="{{RowOnStage.base(rowIndex)}}" stepKey="waitForPageBuilderRow"/>
26+
<waitForElementVisible time="30" selector="{{PageBuilderStage.rootContainer(rowIndex)}}" stepKey="waitForPageBuilderRootContainer"/>
27+
<comment userInput="removing deprecated element" stepKey="waitForPageBuilderRow"/>
2828
</actionGroup>
2929
</actionGroups>

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

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/AdvancedConfigurationActionGroup/SeeInMarginFieldsSlideOutPanelActionGroup.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
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="seeInMarginFieldsSlideOutPanel">
10+
<annotations>
11+
<description>Validates margin field contents.</description>
12+
</annotations>
1113
<arguments>
1214
<argument name="property" defaultValue=""/>
1315
</arguments>

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/AdvancedConfigurationActionGroup/SeeInPaddingFieldsSlideOutPanelActionGroup.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
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="seeInPaddingFieldsSlideOutPanel">
10+
<annotations>
11+
<description>Validates padding field contents.</description>
12+
</annotations>
1113
<arguments>
1214
<argument name="property" defaultValue=""/>
1315
</arguments>

0 commit comments

Comments
 (0)