Skip to content

Commit 404f98b

Browse files
Merge pull request #19 from magento-commerce/imported-magento-magento2-page-builder-659
[Page Builder] Stories bundle
2 parents 036aaf8 + cab12c5 commit 404f98b

File tree

1,099 files changed

+9693
-1435
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,099 files changed

+9693
-1435
lines changed

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
@@ -197,6 +197,8 @@ public function getConfig()
197197
'can_use_inline_editing_on_stage' => $this->isWysiwygProvisionedForEditingOnStage(),
198198
'widgets' => $this->widgetInitializerConfig->getConfig(),
199199
'breakpoints' => $this->getCachedWidgetBreakpoints(),
200+
'viewports' => $this->getViewports($this->getCachedWidgetBreakpoints()),
201+
'defaultViewport' => $this->getDefaultViewport($this->getCachedWidgetBreakpoints()),
200202
'tinymce' => $this->getCachedTinyMceConfig(),
201203
'acl' => $this->getAcl()
202204
];
@@ -312,6 +314,8 @@ private function getCachedFlattenContentTypeData(string $name, array $contentTyp
312314
* @param array $contentType
313315
*
314316
* @return array
317+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
318+
* @SuppressWarnings(PHPMD.NPathComplexity)
315319
*/
316320
private function flattenContentTypeData(string $name, array $contentType)
317321
{
@@ -329,21 +333,60 @@ private function flattenContentTypeData(string $name, array $contentType)
329333
'master_component' => $contentType['master_component'] ?? self::DEFAULT_MASTER_COMPONENT,
330334
'allowed_parents' => $contentType['allowed_parents'] ?? [],
331335
'appearances' => $contentType['appearances'] ?? [],
336+
'breakpoints' => $contentType['breakpoints'] ?? [],
332337
'additional_data' => isset($contentType['additional_data'])
333338
? $this->additionalDataParser->toArray($contentType['additional_data'])
334339
: [],
335340
'is_system' => isset($contentType['is_system']) && $contentType['is_system'] === 'false' ? false : true
336341
];
337342

343+
$result['breakpoints'] = array_merge_recursive(
344+
$result['breakpoints'],
345+
$this->getBreakpointsFields($result['breakpoints'], 'default')
346+
);
347+
338348
foreach ($result['appearances'] as $key => $appearance) {
339349
if (isset($appearance['form'])) {
340350
$result['fields'][$key . '-appearance'] = $this->uiComponentConfig->getFields($appearance['form']);
341351
}
352+
if (isset($appearance['breakpoints'])) {
353+
$namespace = $key . '-appearance';
354+
if ($appearance['default']) {
355+
$namespace = 'default';
356+
foreach ($appearance['breakpoints'] as $name => $breakpoint) {
357+
if (isset($breakpoint['form'])) {
358+
$result['breakpoints'][$name]['form'] = $breakpoint['form'];
359+
}
360+
}
361+
}
362+
$result['breakpoints'] = array_replace_recursive(
363+
$result['breakpoints'],
364+
$this->getBreakpointsFields($appearance['breakpoints'], $namespace)
365+
);
366+
}
342367
}
343368

344369
return $result;
345370
}
346371

372+
/**
373+
* Get breakpoint fields.
374+
*
375+
* @param array $breakpoints
376+
* @param string $namespace
377+
* @return array
378+
*/
379+
private function getBreakpointsFields(array $breakpoints, string $namespace): array
380+
{
381+
$result = [];
382+
foreach ($breakpoints as $key => $breakpoint) {
383+
if (isset($breakpoint['form'])) {
384+
$result[$key]['fields'][$namespace] = $this->uiComponentConfig->getFields($breakpoint['form'], $key);
385+
}
386+
}
387+
return $result;
388+
}
389+
347390
/**
348391
* Determine if active editor is configured to support inline editing mode
349392
*
@@ -412,4 +455,35 @@ private function saveCache(array $data, string $cacheIdentifier): void
412455
{
413456
$this->cache->save($this->serializer->serialize($data), $cacheIdentifier);
414457
}
458+
459+
/**
460+
* Get viewports.
461+
*
462+
* @param array $breakpoints
463+
* @return array
464+
*/
465+
private function getViewports(array $breakpoints): array
466+
{
467+
$viewports = [];
468+
469+
foreach ($breakpoints as $name => $breakpoint) {
470+
if (isset($breakpoint['stage'])) {
471+
$viewports[$name] = $breakpoint;
472+
}
473+
}
474+
475+
return $viewports;
476+
}
477+
478+
/**
479+
* Get default viewport.
480+
*
481+
* @param array $breakpoints
482+
* @return string
483+
*/
484+
private function getDefaultViewport(array $breakpoints): string
485+
{
486+
$keyIndex = array_search(true, array_column($breakpoints, 'default'));
487+
return $keyIndex === false ? '' : array_keys($breakpoints)[$keyIndex];
488+
}
415489
}

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>

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
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="ValidateAdvancedConfigurationAllOptionsActionGroup">
1110
<annotations>
12-
<description value="Validates styles from Advanced configuration in content type settings"/>
11+
<description>Validates styles from Advanced Configuration in content type settings.</description>
1312
</annotations>
1413
<arguments>
1514
<argument name="page" defaultValue=""/>
1615
<argument name="alignment" defaultValue="PageBuilderAdvancedAlignmentPropertyDefault"/>
1716
<argument name="border" defaultValue="PageBuilderAdvancedBorderPropertyNone"/>
1817
<argument name="borderColor" defaultValue=""/>
19-
<argument name="borderWidth" defaultValue="PageBuilderAdvancedBorderWidthPropertyDefault"/>
20-
<argument name="borderRadius" defaultValue="PageBuilderAdvancedBorderRadiusDefaultProperty"/>
18+
<argument name="borderWidth" defaultValue="PageBuilderAdvancedBorderWidthProperty0"/>
19+
<argument name="borderRadius" defaultValue="PageBuilderAdvancedBorderRadiusProperty0"/>
2120
<argument name="cssClasses" defaultValue=""/>
22-
<argument name="margin" defaultValue="PageBuilderMarginsPropertyDefault"/>
23-
<argument name="padding" defaultValue="PageBuilderPaddingPropertyDefault"/>
21+
<argument name="margin" defaultValue="PageBuilderMarginsProperty0"/>
22+
<argument name="padding" defaultValue="PageBuilderPaddingProperty0"/>
2423
<argument name="index" defaultValue="1" type="string"/>
2524
</arguments>
2625
<waitForElementVisible selector="{{page.base(index)}}" stepKey="waitForElementVisible"/>

0 commit comments

Comments
 (0)