Skip to content

Commit 050383f

Browse files
committed
Merge remote-tracking branch 'mainline/1.1-develop' into PB-84
2 parents 9373a6a + 542f2db commit 050383f

File tree

60 files changed

+3322
-1271
lines changed

Some content is hidden

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

60 files changed

+3322
-1271
lines changed

app/code/Magento/PageBuilder/Block/WidgetInitializer.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,22 @@ public function __construct(
4747

4848
/**
4949
* Returns config for widgets initializer component.
50+
*
5051
* @return string
5152
* @api
5253
*/
5354
public function getConfig() : string
5455
{
5556
return $this->jsonSerializer->serialize($this->config->getConfig());
5657
}
58+
59+
/**
60+
* Returns breakpoints for widgets initializer component.
61+
*
62+
* @return string
63+
*/
64+
public function getBreakpoints() : string
65+
{
66+
return $this->jsonSerializer->serialize($this->config->getBreakpoints());
67+
}
5768
}

app/code/Magento/PageBuilder/Model/Filter/Template.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,13 @@ private function generateCssFromImages(string $elementClass, array $images) : st
272272
'background-image' => 'url(' . $images['desktop_image'] . ')',
273273
];
274274
}
275-
if (isset($images['mobile_image']) && $this->getMobileMediaQuery()) {
276-
$css[$this->getMobileMediaQuery()]['.' . $elementClass] = [
275+
if (isset($images['mobile_image']) && $this->getMediaQuery('mobile')) {
276+
$css[$this->getMediaQuery('mobile')]['.' . $elementClass] = [
277+
'background-image' => 'url(' . $images['mobile_image'] . ')',
278+
];
279+
}
280+
if (isset($images['mobile_image']) && $this->getMediaQuery('mobile-small')) {
281+
$css[$this->getMediaQuery('mobile-small')]['.' . $elementClass] = [
277282
'background-image' => 'url(' . $images['mobile_image'] . ')',
278283
];
279284
}
@@ -305,13 +310,14 @@ private function cssFromArray(array $css) : string
305310
/**
306311
* Generate the mobile media query from view configuration
307312
*
313+
* @param string $view
308314
* @return null|string
309315
*/
310-
private function getMobileMediaQuery() : ?string
316+
private function getMediaQuery(string $view) : ?string
311317
{
312318
$breakpoints = $this->viewConfig->getViewConfig()->getVarValue(
313319
'Magento_PageBuilder',
314-
'breakpoints/mobile/conditions'
320+
'breakpoints/' . $view . '/conditions'
315321
);
316322
if ($breakpoints && count($breakpoints) > 0) {
317323
$mobileBreakpoint = '@media only screen ';

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public function getConfig()
141141
'column_grid_max' => $this->scopeConfig->getValue(self::XML_PATH_COLUMN_GRID_MAX),
142142
'can_use_inline_editing_on_stage' => $this->isWysiwygProvisionedForEditingOnStage(),
143143
'widgets' => $this->widgetInitializerConfig->getConfig(),
144+
'breakpoints' => $this->widgetInitializerConfig->getBreakpoints()
144145
];
145146
}
146147

@@ -190,13 +191,15 @@ private function getContentTypes()
190191
*/
191192
private function flattenContentTypeData(string $name, array $contentType)
192193
{
193-
return [
194+
$result = [
194195
'name' => $name,
195196
'label' => $contentType['label'],
196197
'icon' => isset($contentType['icon']) ? $contentType['icon'] : '',
197198
'form' => isset($contentType['form']) ? $contentType['form'] : '',
198199
'menu_section' => $contentType['menu_section'] ?? 'general',
199-
'fields' => isset($contentType['form']) ? $this->uiComponentConfig->getFields($contentType['form']) : [],
200+
'fields' => isset($contentType['form'])
201+
? ['default' => $this->uiComponentConfig->getFields($contentType['form'])]
202+
: [],
200203
'component' => $contentType['component'],
201204
'preview_component' => $contentType['preview_component'] ?? self::DEFAULT_PREVIEW_COMPONENT,
202205
'master_component' => $contentType['master_component'] ?? self::DEFAULT_MASTER_COMPONENT,
@@ -207,6 +210,14 @@ private function flattenContentTypeData(string $name, array $contentType)
207210
: [],
208211
'is_system' => isset($contentType['is_system']) && $contentType['is_system'] === 'false' ? false : true
209212
];
213+
214+
foreach ($result['appearances'] as $key => $appearance) {
215+
if (isset($appearance['form'])) {
216+
$result['fields'][$key . '-appearance'] = $this->uiComponentConfig->getFields($appearance['form']);
217+
}
218+
}
219+
220+
return $result;
210221
}
211222

212223
/**

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public function getFields($componentName) : array
4848
$componentConfig,
4949
function ($item, $key) {
5050
// Determine if this item has a formElement key
51-
if (isset($item[Converter::DATA_ARGUMENTS_KEY]['data']['config']['formElement'])) {
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)
54+
) {
5255
$elementConfig = $item[Converter::DATA_ARGUMENTS_KEY]['data']['config'];
5356
// If the field has a dataScope use that for the key instead of the name
5457
if (isset($elementConfig['dataScope'])) {

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Magento\PageBuilder\Model;
1010

11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\View\ConfigInterface;
13+
1114
/**
1215
* Container for the configuration related to the widget initializer mechanism
1316
*/
@@ -18,12 +21,21 @@ class WidgetInitializerConfig
1821
*/
1922
private $config;
2023

24+
/**
25+
* @var ConfigInterface
26+
*/
27+
private $viewConfig;
28+
2129
/**
2230
* @param array $config
31+
* @param ConfigInterface|null $viewConfig
2332
*/
24-
public function __construct(array $config)
25-
{
33+
public function __construct(
34+
array $config,
35+
ConfigInterface $viewConfig = null
36+
) {
2637
$this->config = $config;
38+
$this->viewConfig = $viewConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class);
2739
}
2840

2941
/**
@@ -43,10 +55,23 @@ public function getConfig(): array
4355
if (isset($item['appearance'])) {
4456
$selector .= sprintf('[data-appearance="%s"]', $item['appearance']);
4557
}
46-
$componentConfig = isset($item['config']) ? $item['config'] : '{}';
58+
$componentConfig = isset($item['config']) ? $item['config'] : false;
4759
$resultConfig[$selector][$item['component']] = $componentConfig;
4860
}
4961
}
5062
return $resultConfig;
5163
}
64+
65+
/**
66+
* Returns breakpoint for widgets initializer component.
67+
*
68+
* @return array
69+
*/
70+
public function getBreakpoints(): array
71+
{
72+
return $this->viewConfig->getViewConfig()->getVarValue(
73+
'Magento_PageBuilder',
74+
'breakpoints'
75+
);
76+
}
5277
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
<waitForElement time="2" selector="{{EditPanelForm.panelFieldControl(property.section, property.fieldName)}}" stepKey="waitForElementVisible"/>
229229
<seeElement selector='//li[@name="{{property.value}}"]' stepKey="seeVisualSelect"/>
230230
<click selector='//div[@data-index="{{property.section}}"]//li[@name="{{property.value}}"]' stepKey="chooseVisualSelectOption"/>
231+
<waitForPageLoad stepKey="waitForPageLoad"/>
231232
</actionGroup>
232233
<actionGroup name="scrollToSlideOutPanelField">
233234
<arguments>

app/code/Magento/PageBuilder/Test/Mftf/Data/ProductsData.xml

Lines changed: 95 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,42 @@
1717
<data key="is_active">true</data>
1818
<data key="include_in_menu">true</data>
1919
</entity>
20+
<!-- Appearance -->
21+
<entity name="PageBuilderProductsProductGridAppearance" type="pagebuilder_products_appearance">
22+
<data key="name">Appearance</data>
23+
<data key="section">appearance_fieldset</data>
24+
<data key="fieldName">appearance</data>
25+
<data key="value">grid</data>
26+
</entity>
27+
<entity name="PageBuilderProductsProductCarouselAppearance" type="pagebuilder_products_appearance">
28+
<data key="name">Appearance</data>
29+
<data key="section">appearance_fieldset</data>
30+
<data key="fieldName">appearance</data>
31+
<data key="value">carousel</data>
32+
</entity>
2033
<!-- Select Products By -->
2134
<entity name="PageBuilderProductsSelectProductsByCategory" type="pagebuilder_select_products_by_types">
2235
<data key="name">Select Products By</data>
23-
<data key="section">general</data>
36+
<data key="section">appearance_fieldset</data>
2437
<data key="fieldName">condition_option</data>
2538
<data key="value">category_ids</data>
2639
</entity>
2740
<entity name="PageBuilderProductsSelectProductsBySKU" type="pagebuilder_select_products_by_types">
2841
<data key="name">Select Products By</data>
29-
<data key="section">general</data>
42+
<data key="section">appearance_fieldset</data>
3043
<data key="fieldName">condition_option</data>
3144
<data key="value">sku</data>
3245
</entity>
3346
<entity name="PageBuilderProductsSelectProductsByCondition" type="pagebuilder_select_products_by_types">
3447
<data key="name">Select Products By</data>
35-
<data key="section">general</data>
48+
<data key="section">appearance_fieldset</data>
3649
<data key="fieldName">condition_option</data>
3750
<data key="value">condition</data>
3851
</entity>
3952
<!-- Category -->
4053
<entity name="PageBuilderProductsSelectCategoryDropDown" type="pagebuilder_products_sorting_types">
4154
<data key="name">Category</data>
42-
<data key="section">general</data>
55+
<data key="section">appearance_fieldset</data>
4356
<data key="fieldName">category_ids</data>
4457
</entity>
4558
<!-- SKU -->
@@ -68,79 +81,144 @@
6881
<!-- Sort by -->
6982
<entity name="PageBuilderProductsSortByNewestTop" type="pagebuilder_products_sorting_types">
7083
<data key="name">Sort By</data>
71-
<data key="section">general</data>
84+
<data key="section">appearance_fieldset</data>
7285
<data key="fieldName">sort_order</data>
7386
<data key="value">date_newest_top</data>
7487
</entity>
7588
<entity name="PageBuilderProductsSortByOldestTop" type="pagebuilder_products_sorting_types">
7689
<data key="name">Sort By</data>
77-
<data key="section">general</data>
90+
<data key="section">appearance_fieldset</data>
7891
<data key="fieldName">sort_order</data>
7992
<data key="value">date_oldest_top</data>
8093
</entity>
8194
<entity name="PageBuilderProductsSortByPosition" type="pagebuilder_products_sorting_types">
8295
<data key="name">Sort By</data>
83-
<data key="section">general</data>
96+
<data key="section">appearance_fieldset</data>
8497
<data key="fieldName">sort_order</data>
8598
<data key="value">position</data>
8699
</entity>
87100
<entity name="PageBuilderProductsSortBySKUPosition" type="pagebuilder_products_sorting_types">
88101
<data key="name">Sort By</data>
89-
<data key="section">general</data>
102+
<data key="section">appearance_fieldset</data>
90103
<data key="fieldName">sort_order</data>
91104
<data key="value">position_by_sku</data>
92105
</entity>
93-
<!-- Number of Products to Display -->
106+
<!-- Number of Products to Display: Grid Appearance -->
94107
<entity name="PageBuilderProductsCountPropertyOne" type="pagebuilder_content_type">
95108
<data key="name">Number of Products to Display</data>
96-
<data key="section">general</data>
109+
<data key="section">appearance_fieldset</data>
97110
<data key="fieldName">products_count</data>
98111
<data key="value">1</data>
99112
</entity>
100113
<entity name="PageBuilderProductsCountPropertyTwo" type="pagebuilder_content_type">
101114
<data key="name">Number of Products to Display</data>
102-
<data key="section">general</data>
115+
<data key="section">appearance_fieldset</data>
103116
<data key="fieldName">products_count</data>
104117
<data key="value">2</data>
105118
</entity>
106119
<entity name="PageBuilderProductsCountPropertyFour" type="pagebuilder_content_type">
107120
<data key="name">Number of Products to Display</data>
108-
<data key="section">general</data>
121+
<data key="section">appearance_fieldset</data>
109122
<data key="fieldName">products_count</data>
110123
<data key="value">4</data>
111124
</entity>
125+
<entity name="PageBuilderProductsCountPropertyFive" type="pagebuilder_content_type">
126+
<data key="name">Number of Products to Display</data>
127+
<data key="section">appearance_fieldset</data>
128+
<data key="fieldName">products_count</data>
129+
<data key="value">5</data>
130+
</entity>
112131
<entity name="PageBuilderProductsCountPropertyMax" type="pagebuilder_content_type">
113132
<data key="name">Number of Products to Display</data>
114-
<data key="section">general</data>
133+
<data key="section">appearance_fieldset</data>
115134
<data key="fieldName">products_count</data>
116135
<data key="value">999</data>
117136
</entity>
118137
<entity name="PageBuilderProductsInvalidMinCountProperty" type="pagebuilder_content_type">
119138
<data key="name">Number of Products to Display</data>
120-
<data key="section">general</data>
139+
<data key="section">appearance_fieldset</data>
121140
<data key="fieldName">products_count</data>
122141
<data key="value">0</data>
123142
<data key="errorMessage">Please enter a value greater than or equal to 1.</data>
124143
</entity>
125144
<entity name="PageBuilderProductsInvalidMaxCountProperty" type="pagebuilder_content_type">
126145
<data key="name">Number of Products to Display</data>
127-
<data key="section">general</data>
146+
<data key="section">appearance_fieldset</data>
128147
<data key="fieldName">products_count</data>
129148
<data key="value">1000</data>
130149
<data key="errorMessage">Please enter a value less than or equal to 999.</data>
131150
</entity>
132151
<entity name="PageBuilderProductsInvalidTypeCountProperty" type="pagebuilder_content_type">
133152
<data key="name">Number of Products to Display</data>
134-
<data key="section">general</data>
153+
<data key="section">appearance_fieldset</data>
135154
<data key="fieldName">products_count</data>
136155
<data key="value">Invalid</data>
137156
<data key="errorMessage">Please enter a valid number in this field.</data>
138157
</entity>
139158
<entity name="PageBuilderProductsInvalidEmptyCountProperty" type="pagebuilder_content_type">
140159
<data key="name">Number of Products to Display</data>
141-
<data key="section">general</data>
160+
<data key="section">appearance_fieldset</data>
142161
<data key="fieldName">products_count</data>
143162
<data key="value"/>
144163
<data key="errorMessage">This is a required field.</data>
145164
</entity>
165+
<!-- Number of Products to Display: Carousel Appearance -->
166+
<entity name="PageBuilderProductsCarouselCountPropertyOne" type="pagebuilder_content_type">
167+
<data key="name">Number of Products to Display</data>
168+
<data key="section">appearance_fieldset</data>
169+
<data key="fieldName">carousel_products_count</data>
170+
<data key="value">1</data>
171+
</entity>
172+
<entity name="PageBuilderProductsCarouselCountPropertyTwo" type="pagebuilder_content_type">
173+
<data key="name">Number of Products to Display</data>
174+
<data key="section">appearance_fieldset</data>
175+
<data key="fieldName">carousel_products_count</data>
176+
<data key="value">2</data>
177+
</entity>
178+
<entity name="PageBuilderProductsCarouselCountPropertyFour" type="pagebuilder_content_type">
179+
<data key="name">Number of Products to Display</data>
180+
<data key="section">appearance_fieldset</data>
181+
<data key="fieldName">carousel_products_count</data>
182+
<data key="value">4</data>
183+
</entity>
184+
<entity name="PageBuilderProductsCarouselCountPropertyTwenty" type="pagebuilder_content_type">
185+
<data key="name">Number of Products to Display</data>
186+
<data key="section">appearance_fieldset</data>
187+
<data key="fieldName">carousel_products_count</data>
188+
<data key="value">20</data>
189+
</entity>
190+
<entity name="PageBuilderProductsCarouselCountPropertyMax" type="pagebuilder_content_type">
191+
<data key="name">Number of Products to Display</data>
192+
<data key="section">appearance_fieldset</data>
193+
<data key="fieldName">carousel_products_count</data>
194+
<data key="value">999</data>
195+
</entity>
196+
<entity name="PageBuilderProductsCarouselInvalidMinCountProperty" type="pagebuilder_content_type">
197+
<data key="name">Number of Products to Display</data>
198+
<data key="section">appearance_fieldset</data>
199+
<data key="fieldName">carousel_products_count</data>
200+
<data key="value">0</data>
201+
<data key="errorMessage">Please enter a value greater than or equal to 1.</data>
202+
</entity>
203+
<entity name="PageBuilderProductsCarouselInvalidMaxCountProperty" type="pagebuilder_content_type">
204+
<data key="name">Number of Products to Display</data>
205+
<data key="section">appearance_fieldset</data>
206+
<data key="fieldName">carousel_products_count</data>
207+
<data key="value">1000</data>
208+
<data key="errorMessage">Please enter a value less than or equal to 999.</data>
209+
</entity>
210+
<entity name="PageBuilderProductsCarouselInvalidTypeCountProperty" type="pagebuilder_content_type">
211+
<data key="name">Number of Products to Display</data>
212+
<data key="section">appearance_fieldset</data>
213+
<data key="fieldName">carousel_products_count</data>
214+
<data key="value">Invalid</data>
215+
<data key="errorMessage">Please enter a valid number in this field.</data>
216+
</entity>
217+
<entity name="PageBuilderProductsCarouselInvalidEmptyCountProperty" type="pagebuilder_content_type">
218+
<data key="name">Number of Products to Display</data>
219+
<data key="section">appearance_fieldset</data>
220+
<data key="fieldName">carousel_products_count</data>
221+
<data key="value"/>
222+
<data key="errorMessage">This is a required field.</data>
223+
</entity>
146224
</entities>

0 commit comments

Comments
 (0)