Skip to content

Commit f0f2c5d

Browse files
committed
Merge branch '1.0.0-release' into MC-4181
# Conflicts: # README.md
2 parents 5f36d5b + a1cd9af commit f0f2c5d

File tree

237 files changed

+6716
-5098
lines changed

Some content is hidden

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

237 files changed

+6716
-5098
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The PageBuilder Early Access Program (EAP) gives partners the following perks:
1515

1616
## Installation
1717

18-
We offer two methods for installing PageBuilder:
18+
We offer one method for installing PageBuilder:
1919

2020
* As a [Composer package] - use this option if you do not plan to contribute to the PageBuilder code repository.
2121
* Using the [GitHub repository] - use this option to install PageBuilder from the GitHub repository and contribute to the code.
@@ -95,4 +95,4 @@ For all other questions or requests, contact [Olena Tkacheva].
9595
[Slack]: https://magentocommeng.slack.com/
9696
[Olena Tkacheva]: https://magentocommeng.slack.com/messages/@UAFV915FB
9797

98-
<!-- {% endraw %} -->
98+
<!-- {% endraw %} -->

app/code/Magento/PageBuilder/Controller/Adminhtml/ContentType/Image/Upload.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
*/
66
namespace Magento\PageBuilder\Controller\Adminhtml\ContentType\Image;
77

8-
use Magento\Framework\Controller\ResultFactory;
8+
use Magento\Framework\App\Action\HttpPostActionInterface;
99

1010
/**
1111
* Class Upload
1212
*/
13-
class Upload extends \Magento\Backend\App\Action
13+
class Upload extends \Magento\Backend\App\Action implements HttpPostActionInterface
1414
{
1515
const UPLOAD_DIR = 'wysiwyg';
1616

@@ -94,7 +94,12 @@ public function execute()
9494
$fileUploader->setAllowRenameFiles(true);
9595
$fileUploader->setAllowedExtensions(['jpeg','jpg','png','gif']);
9696
$fileUploader->setAllowCreateFolders(true);
97+
9798
try {
99+
if (!$fileUploader->checkMimeType(['image/png', 'image/jpeg', 'image/gif'])) {
100+
throw new \Magento\Framework\Exception\LocalizedException(__('File validation failed.'));
101+
}
102+
98103
$result = $fileUploader->save($this->getUploadDir());
99104
$baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
100105
$result['id'] = $this->cmsWysiwygImages->idEncode($result['file']);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function __construct(array $config)
2828

2929
/**
3030
* Retrieves the component-ready configuration for the widget initializer
31+
*
3132
* @return array
3233
*/
3334
public function getConfig(): array
@@ -43,9 +44,9 @@ public function getConfig(): array
4344
$selector .= sprintf('[data-appearance="%s"]', $item['appearance']);
4445
}
4546
$componentConfig = isset($item['config']) ? $item['config'] : '{}';
46-
$resultConfig[$selector] = [$item['component'] => $componentConfig];
47+
$resultConfig[$selector][$item['component']] = $componentConfig;
4748
}
4849
}
4950
return $resultConfig;
5051
}
51-
}
52+
}

app/code/Magento/PageBuilder/Setup/DataConverter/Renderer/AdvancedSliderItem.php

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class AdvancedSliderItem implements RendererInterface
2626
*/
2727
private $eavAttributeLoader;
2828

29+
/**
30+
* @param StyleExtractorInterface $styleExtractor
31+
* @param EavAttributeLoaderInterface $eavAttributeLoader
32+
*/
2933
public function __construct(
3034
StyleExtractorInterface $styleExtractor,
3135
EavAttributeLoaderInterface $eavAttributeLoader
@@ -35,7 +39,7 @@ public function __construct(
3539
}
3640

3741
/**
38-
* {@inheritdoc}
42+
* @inheritdoc
3943
*
4044
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
4145
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -55,11 +59,23 @@ public function render(array $itemData, array $additionalData = []) : string
5559
];
5660

5761
$formData = $itemData['formData'] ?? [];
58-
$formData['background_image'] = '';
62+
$backgroundImages = '';
63+
$backgroundImagesAttr = '{}';
64+
5965
if (isset($eavData['background_image'])) {
60-
$formData['background_image'] = $eavData['background_image'];
66+
$backgroundImages = $eavData['background_image'];
6167
} elseif (isset($eavData['image'])) {
62-
$formData['background_image'] = $eavData['image'];
68+
$backgroundImages = $eavData['image'];
69+
}
70+
71+
if ($backgroundImages) {
72+
$backgroundImagesAttr = '{\&quot;'
73+
. 'desktop_image\&quot;:\&quot;'
74+
. '{{media url=wysiwyg'
75+
. $backgroundImages
76+
. '}}\&quot;,\&quot;'
77+
. 'mobile_image\&quot;:\&quot;'
78+
. '{}\&quot;}';
6379
}
6480

6581
$margin = $this->styleExtractor->extractStyle($formData, ['margin']);
@@ -68,8 +84,9 @@ public function render(array $itemData, array $additionalData = []) : string
6884
}
6985

7086
$wrapperDivElementAttributes = [
71-
'data-element' => 'mobile_image',
72-
'class' => 'pagebuilder-slide-wrapper pagebuilder-mobile-only'
87+
'data-element' => 'wrapper',
88+
'data-background-images' => $backgroundImagesAttr,
89+
'class' => 'pagebuilder-slide-wrapper'
7390
];
7491
$style = $this->styleExtractor->extractStyle($formData);
7592
if ($style) {
@@ -103,8 +120,8 @@ public function render(array $itemData, array $additionalData = []) : string
103120
}
104121

105122
// mobile wrapper div
106-
$rootElementHtml = '<div' . $this->printAttributes($rootElementAttributes) . '><a data-element="link"';
107-
$rootElementHtml .= isset($eavData['link_url']) ? ' href="' . $eavData['link_url'] . '">' : '>';
123+
$rootElementHtml = '<div' . $this->printAttributes($rootElementAttributes) . '><div data-element="link"';
124+
$rootElementHtml .= isset($eavData['link_url']) ? ' data-href="' . $eavData['link_url'] . '">' : '>';
108125
$rootElementHtml .= '<div'
109126
. $this->printAttributes($wrapperDivElementAttributes)
110127
. '><div'
@@ -118,23 +135,7 @@ public function render(array $itemData, array $additionalData = []) : string
118135
. $buttonElementHtml
119136
. '</div></div></div>';
120137

121-
// non-mobile wrapper div
122-
$wrapperDivElementAttributes['data-element'] = 'desktop_image';
123-
$wrapperDivElementAttributes['class'] = 'pagebuilder-slide-wrapper ' .
124-
'pagebuilder-mobile-hidden';
125-
$rootElementHtml .= '<div'
126-
. $this->printAttributes($wrapperDivElementAttributes)
127-
. '><div'
128-
. $this->printAttributes($overlayDivElementAttributes)
129-
. '><div class="pagebuilder-poster-content">'
130-
. '<div data-element="content"><h3>'
131-
. ($eavData['title'] ?? $eavData['title_tag'] ?? '')
132-
. '</h3>'
133-
. '<div>' . ($eavData['textarea'] ?? '') . '</div></div>'
134-
. $buttonElementHtml
135-
. '</div></div></div>';
136-
137-
$rootElementHtml .= '</a></div>';
138+
$rootElementHtml .= '</div></div>';
138139

139140
return $rootElementHtml;
140141
}

app/code/Magento/PageBuilder/Setup/DataConverter/Renderer/Driver.php

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ class Driver implements RendererInterface
3232
*/
3333
private $serializer;
3434

35+
/**
36+
* Driver constructor.
37+
* @param StyleExtractorInterface $styleExtractor
38+
* @param EavAttributeLoaderInterface $eavAttributeLoader
39+
* @param Json $serializer
40+
*/
3541
public function __construct(
3642
StyleExtractorInterface $styleExtractor,
3743
EavAttributeLoaderInterface $eavAttributeLoader,
@@ -43,7 +49,7 @@ public function __construct(
4349
}
4450

4551
/**
46-
* {@inheritdoc}
52+
* @inheritdoc
4753
*/
4854
public function render(array $itemData, array $additionalData = []) : string
4955
{
@@ -80,33 +86,26 @@ public function render(array $itemData, array $additionalData = []) : string
8086
$rootElementAttributes['style'] .= $margin;
8187
$linkAttributes = [
8288
'data-element' => 'link',
83-
'href' => $eavData['link_url'] ?? '',
84-
'target' => isset($eavData['target_blank']) && $eavData['target_blank'] ? '_blank' : '',
89+
'data-href' => $eavData['link_url'] ?? '',
90+
'data-target' => isset($eavData['target_blank']) && $eavData['target_blank'] ? '_blank' : '',
8591
];
92+
8693
$imageAttributes = [
87-
'data-element' => 'desktop_image',
88-
'style' => 'background-image: url('
89-
. "'{{media url=wysiwyg"
94+
'data-element' => 'wrapper',
95+
'data-background-images' => '{\&quot;'
96+
. 'desktop_image\&quot;:\&quot;'
97+
. '{{media url=wysiwyg'
9098
. $eavData['image']
91-
. "}}'); "
92-
. 'min-height: 300px; background-size: auto; background-repeat: no-repeat; '
93-
. 'background-attachment: scroll;'
99+
. '}}\&quot;,\&quot;'
100+
. 'mobile_image\&quot;:\&quot;'
101+
. '{{media url=wysiwyg'
102+
. $eavData['image']
103+
. '}}\&quot;}',
104+
'style' => 'min-height: 300px; background-size: auto; '
105+
. 'background-repeat: no-repeat; background-attachment: scroll;'
94106
. $textAlign,
95-
'class' => 'pagebuilder-banner-wrapper pagebuilder-mobile-hidden'
96-
];
97-
$mobileImageAttributes = [
98-
'data-element' => 'mobile_image',
99-
'style' => 'background-image: url('
100-
. "'{{media url=wysiwyg"
101-
. (isset($eavData['image']) ? $eavData['image'] : $eavData['mobile_image'])
102-
. "}}'); "
103-
. 'min-height: 300px; background-size: auto; background-repeat: no-repeat; '
104-
. 'background-attachment: scroll;'
105-
. $textAlign
107+
'class' => 'pagebuilder-banner-wrapper'
106108
];
107-
$mobileImageElementHtml = '<div'
108-
. $this->printAttributes($mobileImageAttributes)
109-
. ' class="pagebuilder-banner-wrapper pagebuilder-mobile-only">';
110109

111110
$imageElementHtml = '<div' . $this->printAttributes($imageAttributes) . '>';
112111
$overlayElementHtml = '<div '
@@ -123,19 +122,18 @@ public function render(array $itemData, array $additionalData = []) : string
123122

124123
return '<div'
125124
. $this->printAttributes($rootElementAttributes)
126-
. '><a'
125+
. '><div'
127126
. $this->printAttributes($linkAttributes)
128127
. '>'
129128
. $imageElementHtml
130129
. $overlayElementHtml
131130
. '<div class="pagebuilder-poster-content"><div data-element="content"></div>'
132131
. $buttonHtml
133132
. '</div></div></div>'
134-
. $mobileImageElementHtml
135133
. $overlayElementHtml
136134
. '<div class="pagebuilder-poster-content"><div data-element="content"></div>'
137135
. $buttonHtml
138-
. '</div></div></div></a></div>';
136+
. '</div></div></div></div></div>';
139137
}
140138

141139
/**

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
<waitForElementVisible selector="{{page.base(index)}}" stepKey="waitForElementVisible"/>
279279
<waitForElementVisible selector="{{page.noAlignment(index)}}" stepKey="waitForAlignmentVisible"/>
280280
<waitForElementVisible selector="{{page.border(index, border.value)}}" stepKey="waitForBorderVisible"/>
281-
<waitForElementVisible selector="{{page.borderColor(index, borderColor.rbg)}}" stepKey="waitForBorderColorVisible"/>
281+
<waitForElementVisible selector="{{page.borderColor(index, borderColor.rgb)}}" stepKey="waitForBorderColorVisible"/>
282282
<waitForElementVisible selector="{{page.borderWidth(index, borderWidth.value)}}" stepKey="waitForBorderWidthVisible"/>
283283
<waitForElementVisible selector="{{page.borderRadius(index, borderRadius.value)}}" stepKey="waitForBorderRadiusVisible"/>
284284
<waitForElementVisible selector="{{page.noCssClasses(index)}}" stepKey="waitForCSSClassesVisible"/>
@@ -399,7 +399,7 @@
399399
<waitForElementVisible selector="{{page.base(index)}}" stepKey="waitForElementVisible"/>
400400
<waitForElementVisible selector="{{page.alignment(index, alignment.value)}}" stepKey="waitForAlignmentVisible"/>
401401
<waitForElementVisible selector="{{page.border(index, border.value)}}" stepKey="waitForBorderVisible"/>
402-
<waitForElementVisible selector="{{page.borderColor(index, borderColor.rbg)}}" stepKey="waitForBorderColorVisible"/>
402+
<waitForElementVisible selector="{{page.borderColor(index, borderColor.rgb)}}" stepKey="waitForBorderColorVisible"/>
403403
<waitForElementVisible selector="{{page.borderWidth(index, borderWidth.value)}}" stepKey="waitForBorderWidthVisible"/>
404404
<waitForElementVisible selector="{{page.borderRadius(index, borderRadius.value)}}" stepKey="waitForBorderRadiusVisible"/>
405405
<waitForElementVisible selector="{{page.cssClasses(index, cssClasses.value)}}" stepKey="waitForCSSClassesVisible"/>
@@ -425,8 +425,8 @@
425425
<dontSeeElement selector="{{page.alignment(index, alignment.value)}}" stepKey="dontSeeAlignment"/>
426426
<waitForElement selector="{{page.border(index, border.value)}}" stepKey="waitForBorder"/>
427427
<dontSeeElement selector="{{page.border(index, border.value)}}" stepKey="dontSeeBorder"/>
428-
<waitForElement selector="{{page.borderColor(index, borderColor.rbg)}}" stepKey="waitForBorderColor"/>
429-
<dontSeeElement selector="{{page.borderColor(index, borderColor.rbg)}}" stepKey="dontSeeBorderColor"/>
428+
<waitForElement selector="{{page.borderColor(index, borderColor.rgb)}}" stepKey="waitForBorderColor"/>
429+
<dontSeeElement selector="{{page.borderColor(index, borderColor.rgb)}}" stepKey="dontSeeBorderColor"/>
430430
<waitForElement selector="{{page.borderWidth(index, borderWidth.value)}}" stepKey="waitForBorderWidth"/>
431431
<dontSeeElement selector="{{page.borderWidth(index, borderWidth.value)}}" stepKey="dontSeeBorderWidth"/>
432432
<waitForElement selector="{{page.borderRadius(index, borderRadius.value)}}" stepKey="waitForBorderRadius"/>

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,55 @@
3636
<seeElement selector="{{BlockOnStage.title(index,block.title)}}" stepKey="seeOptionMenuTitle"/>
3737
<see selector="{{BlockOnStage.content(index)}}" userInput="{{block.content}}" stepKey="seeBlockContentOnStage"/>
3838
</actionGroup>
39+
<actionGroup name="verifyVerticalAlignmentBottomInBlock">
40+
<arguments>
41+
<argument name="block" defaultValue="BlockOnStorefront"/>
42+
<argument name="container"/>
43+
<argument name="content"/>
44+
<argument name="minHeight"/>
45+
<argument name="padding"/>
46+
<argument name="index" defaultValue="1" type="string"/>
47+
<!-- Remove storefrontBugOffset when MC-5079 is resolved -->
48+
<argument name="storefrontBugOffset" defaultValue="0" type="string"/>
49+
</arguments>
50+
<executeJS function="return document.querySelectorAll('{{block.baseCSS}} {{container.baseCSS}}')[{{index}}-1].clientHeight;" stepKey="containerHeight"/>
51+
<executeJS function="return {$containerHeight}-{{storefrontBugOffset}}" stepKey="minusBugOffset"/>
52+
<assertGreaterThanOrEqual stepKey="assertContainerHeightGreaterThanOrEqualMinHeight">
53+
<expectedResult type="string">{{minHeight}}</expectedResult>
54+
<actualResult type="variable">minusBugOffset</actualResult>
55+
</assertGreaterThanOrEqual>
56+
<executeJS function="return document.querySelectorAll('{{block.baseCSS}} {{container.baseCSS}}')[{{index}}-1].getBoundingClientRect().bottom-{{padding.paddingBottom}}" stepKey="containerBottomPositionMinusPadding"/>
57+
<executeJS function="return document.querySelectorAll('{{block.baseCSS}} {{content.baseCSS}}')[{{index}}-1].getBoundingClientRect().bottom" stepKey="contentBottomPosition"/>
58+
<executeJS function="return Math.round(({$containerBottomPositionMinusPadding}/{$contentBottomPosition})*100)/100" stepKey="bottomPositionRatio"/>
59+
<assertEquals stepKey="assertBottomPositionRatio">
60+
<expectedResult type="int">1</expectedResult>
61+
<actualResult type="variable">bottomPositionRatio</actualResult>
62+
</assertEquals>
63+
</actionGroup>
64+
<actionGroup name="verifyAlignmentRightInBlock">
65+
<arguments>
66+
<argument name="block" defaultValue="BlockOnStorefront"/>
67+
<argument name="container" type="string"/>
68+
<argument name="content" type="string"/>
69+
<argument name="containerPadding"/>
70+
<argument name="index" defaultValue="1" type="string"/>
71+
</arguments>
72+
<!-- Verify container width is larger than content width -->
73+
<comment userInput="Verify container width is larger than content width" stepKey="commentVerifyWidth"/>
74+
<executeJS function="return document.querySelectorAll('{{block.baseCSS}} {{container}}')[{{index}}-1].clientWidth;" stepKey="containerWidth"/>
75+
<executeJS function="return document.querySelectorAll('{{block.baseCSS}} {{content}}')[{{index}}-1].clientWidth;" stepKey="contentWidth"/>
76+
<assertGreaterThan stepKey="assertContainerHeightIsGreater">
77+
<expectedResult type="variable">contentWidth</expectedResult>
78+
<actualResult type="variable">containerWidth</actualResult>
79+
</assertGreaterThan>
80+
<!-- Verify position right of container matches content -->
81+
<comment userInput="Verify position right of container matches content" stepKey="commentVerifyRightPosition"/>
82+
<executeJS function="return document.querySelectorAll('{{block.baseCSS}} {{container}}')[{{index}}-1].getBoundingClientRect().right-{{containerPadding.paddingRight}};" stepKey="containerRightMinusPadding"/>
83+
<executeJS function="return document.querySelectorAll('{{block.baseCSS}} {{content}}')[{{index}}-1].getBoundingClientRect().right;" stepKey="contentRight"/>
84+
<executeJS function="return Math.round(({$containerRightMinusPadding}/{$contentRight})*100)/100" stepKey="rightPositionRatio"/>
85+
<assertEquals stepKey="assertRightPositionRatio">
86+
<expectedResult type="int">1</expectedResult>
87+
<actualResult type="variable">rightPositionRatio</actualResult>
88+
</assertEquals>
89+
</actionGroup>
3990
</actionGroups>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
<waitForElementVisible selector="{{page.baseByTagName(headingType.value, index)}}" stepKey="waitForElementVisible"/>
136136
<waitForElementVisible selector="{{page.alignment(headingType.value, index, alignment.value)}}" stepKey="waitForAlignmentVisible"/>
137137
<waitForElementVisible selector="{{page.border(headingType.value, index, border.value)}}" stepKey="waitForBorderVisible"/>
138-
<waitForElementVisible selector="{{page.borderColor(headingType.value, index, borderColor.rbg)}}" stepKey="waitForBorderColorVisible"/>
138+
<waitForElementVisible selector="{{page.borderColor(headingType.value, index, borderColor.rgb)}}" stepKey="waitForBorderColorVisible"/>
139139
<waitForElementVisible selector="{{page.borderWidth(headingType.value, index, borderWidth.value)}}" stepKey="waitForBorderWidthVisible"/>
140140
<waitForElementVisible selector="{{page.borderRadius(headingType.value, index, borderRadius.value)}}" stepKey="waitForBorderRadiusVisible"/>
141141
<waitForElementVisible selector="{{page.cssClasses(headingType.value, index, cssClasses.value)}}" stepKey="waitForCSSClassesVisible"/>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<attachFile userInput="{{property.value}}" selector="{{ImageOnStage.attachImageBtn}}" stepKey="attachImageFileOnStage"/>
1616
<waitForPageLoad stepKey="waitForPageLoad"/>
1717
<waitForElementVisible selector="{{ImageOnStage.imagePreview}}" stepKey="waitForImagePreview"/>
18-
<waitForElementVisible selector="{{ImageOnStage.imageSourceOnStage(property.fileName)}}" stepKey="waitForImageSource"/>
18+
<waitForElementVisible selector="{{ImageOnStage.imageSource(property.fileName)}}" stepKey="waitForImageSource"/>
1919
</actionGroup>
2020
<actionGroup name="verifyImageOnSlideout">
2121
<arguments>

0 commit comments

Comments
 (0)