Skip to content

Commit 9e329d6

Browse files
author
Hwashiang Yu
committed
MC-5810: Improve naming of the critical variables/parameters in the code and configuration
- Renamed panel groups to menu sections in configuration, tests, docs, and readers
1 parent d2f1ad0 commit 9e329d6

File tree

131 files changed

+1740
-1740
lines changed

Some content is hidden

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

131 files changed

+1740
-1740
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public function __construct(
3838
/**
3939
* @return array
4040
*/
41-
public function getGroups() : array
41+
public function getMenuSections() : array
4242
{
43-
return $this->get('groups');
43+
return $this->get('menu_sections');
4444
}
4545

4646
/**

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

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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\Model\Config\MenuSection;
10+
11+
class Converter implements \Magento\Framework\Config\ConverterInterface
12+
{
13+
/**
14+
* Convert XML structure into output array
15+
*
16+
* @param \DOMDocument $source
17+
* @return array
18+
* @throws \InvalidArgumentException
19+
*/
20+
public function convert($source): array
21+
{
22+
return [
23+
'menu_sections' => $this->convertMenuSections($source)
24+
];
25+
}
26+
27+
/**
28+
* Convert data for menu sections
29+
*
30+
* @param \DOMDocument $source
31+
* @return array
32+
*/
33+
private function convertMenuSections(\DOMDocument $source): array
34+
{
35+
$menuSectionsData = [];
36+
/** @var \DOMNode $menuSection */
37+
foreach ($source->getElementsByTagName('menu_section') as $menuSection) {
38+
$name = $menuSection->attributes->getNamedItem('name')->nodeValue;
39+
/** @var \DOMElement $attributeValue */
40+
foreach ($menuSection->attributes as $attributeName => $attributeValue) {
41+
$menuSectionsData[$name][$attributeName] = $attributeValue->nodeValue;
42+
}
43+
}
44+
uasort($menuSectionsData, function ($firstElement, $secondElement) {
45+
return (int)$firstElement['sortOrder'] <=> (int)$secondElement['sortOrder'];
46+
});
47+
48+
return $menuSectionsData;
49+
}
50+
}

app/code/Magento/PageBuilder/Model/Config/Group/Reader.php renamed to app/code/Magento/PageBuilder/Model/Config/MenuSection/Reader.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\Group;
9+
namespace Magento\PageBuilder\Model\Config\MenuSection;
1010

1111
class Reader extends \Magento\Framework\Config\Reader\Filesystem
1212
{
@@ -16,15 +16,15 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
1616
* @var array
1717
*/
1818
protected $_idAttributes = [
19-
'/config/group' => 'name'
19+
'/config/menu_section' => 'name'
2020
];
2121

2222
/**
2323
* Constructor
2424
*
2525
* @param \Magento\PageBuilder\Model\Config\FileResolver $fileResolver
26-
* @param \Magento\PageBuilder\Model\Config\Group\Converter $converter
27-
* @param \Magento\PageBuilder\Model\Config\Group\SchemaLocator $schemaLocator
26+
* @param \Magento\PageBuilder\Model\Config\MenuSection\Converter $converter
27+
* @param \Magento\PageBuilder\Model\Config\MenuSection\SchemaLocator $schemaLocator
2828
* @param \Magento\Framework\Config\ValidationStateInterface $validationState
2929
* @param string $fileName
3030
* @param array $idAttributes
@@ -33,10 +33,10 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
3333
*/
3434
public function __construct(
3535
\Magento\PageBuilder\Model\Config\FileResolver $fileResolver,
36-
\Magento\PageBuilder\Model\Config\Group\Converter $converter,
37-
\Magento\PageBuilder\Model\Config\Group\SchemaLocator $schemaLocator,
36+
\Magento\PageBuilder\Model\Config\MenuSection\Converter $converter,
37+
\Magento\PageBuilder\Model\Config\MenuSection\SchemaLocator $schemaLocator,
3838
\Magento\Framework\Config\ValidationStateInterface $validationState,
39-
string $fileName = 'group.xml',
39+
string $fileName = 'menu_section.xml',
4040
array $idAttributes = [],
4141
string $domDocumentClass = \Magento\Framework\Config\Dom::class,
4242
string $defaultScope = 'global'

app/code/Magento/PageBuilder/Model/Config/Group/SchemaLocator.php renamed to app/code/Magento/PageBuilder/Model/Config/MenuSection/SchemaLocator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\Group;
9+
namespace Magento\PageBuilder\Model\Config\MenuSection;
1010

1111
class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
1212
{
@@ -31,8 +31,8 @@ public function __construct(
3131
\Magento\Framework\Module\Dir\Reader $moduleReader
3232
) {
3333
$etcDir = $moduleReader->getModuleDir('etc', 'Magento_PageBuilder');
34-
$this->schema = $etcDir . DIRECTORY_SEPARATOR . 'group_merged.xsd';
35-
$this->perFileSchema = $etcDir . DIRECTORY_SEPARATOR . 'group.xsd';
34+
$this->schema = $etcDir . DIRECTORY_SEPARATOR . 'menu_section_merged.xsd';
35+
$this->perFileSchema = $etcDir . DIRECTORY_SEPARATOR . 'menu_section.xsd';
3636
}
3737

3838
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface ConfigInterface
1717
/**
1818
* @return array
1919
*/
20-
public function getGroups() : array;
20+
public function getMenuSections() : array;
2121

2222
/**
2323
* @return array

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function __construct(
131131
public function getConfig()
132132
{
133133
return [
134-
'groups' => $this->getGroups(),
134+
'menu_sections' => $this->getMenuSections(),
135135
'content_types' => $this->getContentTypes(),
136136
'stage_config' => $this->data,
137137
'media_url' => $this->urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]),
@@ -144,13 +144,13 @@ public function getConfig()
144144
}
145145

146146
/**
147-
* Retrieve the content type groups
147+
* Retrieve the content type menu sections
148148
*
149149
* @return array
150150
*/
151-
private function getGroups()
151+
private function getMenuSections()
152152
{
153-
return $this->config->getGroups();
153+
return $this->config->getMenuSections();
154154
}
155155

156156
/**
@@ -194,7 +194,7 @@ private function flattenContentTypeData(string $name, array $contentType)
194194
'label' => $contentType['label'],
195195
'icon' => isset($contentType['icon']) ? $contentType['icon'] : '',
196196
'form' => isset($contentType['form']) ? $contentType['form'] : '',
197-
'group' => $contentType['group'] ?? 'general',
197+
'menu_section' => $contentType['menu_section'] ?? 'general',
198198
'fields' => isset($contentType['form']) ? $this->uiComponentConfig->getFields($contentType['form']) : [],
199199
'component' => $contentType['component'],
200200
'preview_component' => $contentType['preview_component'] ?? self::DEFAULT_PREVIEW_COMPONENT,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@
5757
<see userInput="You saved the page." selector="{{CmsPagesPageActionsSection.savePageSuccessMessage}}" stepKey="assertSavePageSuccessMessage"/>
5858
</actionGroup>
5959
<actionGroup name="verifyPageBuilderVisibleOnPage">
60-
<waitForElementVisible selector="{{PageBuilderPanel.layoutGroup}}" stepKey="seePageBuilderVisible"/>
60+
<waitForElementVisible selector="{{PageBuilderPanel.layoutMenuSection}}" stepKey="seePageBuilderVisible"/>
6161
<dontSee userInput="Enable Advanced CMS" stepKey="dontSeeEnableAdvancedCMSBtn"/>
6262
</actionGroup>
6363
<actionGroup name="verifyPageBuilderVisibleOnStaging">
64-
<scrollTo selector="{{PageBuilderPanel.layoutGroup}}" stepKey="scrollToIdentifyPageBuilder"/>
65-
<waitForElementVisible selector="{{PageBuilderPanel.layoutGroup}}" stepKey="seePageBuilderVisible"/>
64+
<scrollTo selector="{{PageBuilderPanel.layoutMenuSection}}" stepKey="scrollToIdentifyPageBuilder"/>
65+
<waitForElementVisible selector="{{PageBuilderPanel.layoutMenuSection}}" stepKey="seePageBuilderVisible"/>
6666
<dontSee userInput="Enable Advanced CMS" stepKey="dontSeeEnableAdvancedCMSBtn"/>
6767
</actionGroup>
6868
<actionGroup name="verifyPageBuilderNotVisibleOnPage">
6969
<dontSee userInput="Enable Advanced CMS" stepKey="dontSeeEnableAdvancedCMSBtn"/>
70-
<dontSee selector="{{PageBuilderPanel.layoutGroup}}" stepKey="seePageBuilderVisible"/>
70+
<dontSee selector="{{PageBuilderPanel.layoutMenuSection}}" stepKey="seePageBuilderVisible"/>
7171
</actionGroup>
7272
<actionGroup name="setLayout">
7373
<!-- This goes in CE repo -->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<waitForElementVisible selector="{{section.PageBuilderBtn(attributeCode)}}" stepKey="waitForPageBuilderButton"/>
1919
<click selector="{{section.PageBuilderBtn(attributeCode)}}" stepKey="clickOpenPageBuilder"/>
2020
<waitForPageLoad stepKey="waitForPageBuilderToOpen"/>
21-
<waitForElementVisible selector="{{pageBuilderArea}}{{PageBuilderPanel.layoutGroup}}" stepKey="waiForPageBuilderVisible"/>
21+
<waitForElementVisible selector="{{pageBuilderArea}}{{PageBuilderPanel.layoutMenuSection}}" stepKey="waiForPageBuilderVisible"/>
2222
</actionGroup>
2323
<actionGroup name="expandAdminProductSection">
2424
<!-- This goes in CE repo -->

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

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,47 @@
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11-
<actionGroup name="expandPageBuilderPanelGroup">
11+
<actionGroup name="expandPageBuilderPanelMenuSection">
1212
<arguments>
13-
<argument name="group"/>
13+
<argument name="contentType"/>
1414
<argument name="pageBuilderArea" defaultValue="" type="string"/>
1515
</arguments>
16-
<waitForElementVisible selector="{{pageBuilderArea}}{{PageBuilderPanel.panelGroup(group.section)}}" stepKey="waitForGroupVisible"/>
17-
<conditionalClick selector="{{pageBuilderArea}}{{PageBuilderPanel.panelGroup(group.section)}}" dependentSelector="{{pageBuilderArea}}{{PageBuilderPanel.panelGroupActive(group.section)}}" visible="false" stepKey="expandGroup"/>
18-
<waitForElementVisible selector="{{pageBuilderArea}}{{PageBuilderPanel.panelGroupActive(group.section)}}" stepKey="waitForGroupExpanded"/>
16+
<waitForElementVisible selector="{{pageBuilderArea}}{{PageBuilderPanel.panelMenuSection(contentType.section)}}" stepKey="waitForcontentTypeVisible"/>
17+
<conditionalClick selector="{{pageBuilderArea}}{{PageBuilderPanel.panelMenuSection(contentType.section)}}" dependentSelector="{{pageBuilderArea}}{{PageBuilderPanel.panelMenuSectionActive(contentType.section)}}" visible="false" stepKey="expandContentTypeMenuSection"/>
18+
<waitForElementVisible selector="{{pageBuilderArea}}{{PageBuilderPanel.panelMenuSectionActive(contentType.section)}}" stepKey="waitForMenuSectionExpanded"/>
1919
</actionGroup>
20-
<actionGroup name="closePageBuilderPanelGroups">
21-
<click selector="{{PageBuilderPanel.elementsGroup}}" stepKey="clickElementsGroup"/>
22-
<click selector="{{PageBuilderPanel.mediaGroup}}" stepKey="clickMediaGroup"/>
23-
<click selector="{{PageBuilderPanel.addContentGroup}}" stepKey="clickAddContentGroup"/>
20+
<actionGroup name="closePageBuilderPanelMenuSections">
21+
<click selector="{{PageBuilderPanel.elementsMenuSection}}" stepKey="clickElementsMenuSection"/>
22+
<click selector="{{PageBuilderPanel.mediaMenuSection}}" stepKey="clickMediaMenuSection"/>
23+
<click selector="{{PageBuilderPanel.addContentMenuSection}}" stepKey="clickAddContentMenuSection"/>
2424
</actionGroup>
25-
<actionGroup name="validateGroupsAndContentTypes">
26-
<seeNumberOfElements selector="{{PageBuilderPanel.allPanelGroups}}" userInput="4" stepKey="seeNumberOfGroups"/>
27-
<seeNumberOfElements selector="{{PageBuilderPanel.allGroupContentTypes('layout')}}" userInput="3" stepKey="seeNumberOfLayoutGroupContentTypes"/>
28-
<see userInput="Layout" selector="{{PageBuilderPanel.layoutGroup}}" stepKey="seeLayoutGroup"/>
29-
<see userInput="Row" selector="{{PageBuilderPanel.layoutGroupContentType}}" stepKey="seeLayoutGroupRow"/>
30-
<see userInput="Column" selector="{{PageBuilderPanel.layoutGroupContentType}}" stepKey="seeLayoutGroupColumn"/>
31-
<see userInput="Tabs" selector="{{PageBuilderPanel.layoutGroupContentType}}" stepKey="seeLayoutGroupTabs"/>
32-
<click selector="{{PageBuilderPanel.elementsGroup}}" stepKey="clickElementsGroup"/>
33-
<seeNumberOfElements selector="{{PageBuilderPanel.allGroupContentTypes('elements')}}" userInput="5" stepKey="seeNumberOfElementsGroupContentTypes"/>
34-
<see userInput="Elements" selector="{{PageBuilderPanel.elementsGroup}}" stepKey="seeElementsGroup"/>
35-
<see userInput="Text" selector="{{PageBuilderPanel.elementsGroupContentType}}" stepKey="seeElementsGroupText"/>
36-
<see userInput="Heading" selector="{{PageBuilderPanel.elementsGroupContentType}}" stepKey="seeElementsGroupHeading"/>
37-
<see userInput="Buttons" selector="{{PageBuilderPanel.elementsGroupContentType}}" stepKey="seeElementsGroupButtons"/>
38-
<see userInput="Divider" selector="{{PageBuilderPanel.elementsGroupContentType}}" stepKey="seeElementsGroupDivider"/>
39-
<see userInput="HTML Code" selector="{{PageBuilderPanel.elementsGroupContentType}}" stepKey="seeElementsGroupHtml"/>
40-
<click selector="{{PageBuilderPanel.mediaGroup}}" stepKey="clickMediaGroup"/>
41-
<seeNumberOfElements selector="{{PageBuilderPanel.allGroupContentTypes('media')}}" userInput="5" stepKey="seeNumberOfMediaGroupContentTypes"/>
42-
<see userInput="Media" selector="{{PageBuilderPanel.mediaGroup}}" stepKey="seeMediaGroup"/>
43-
<see userInput="Image" selector="{{PageBuilderPanel.mediaGroupContentType}}" stepKey="seeMediaGroupImage"/>
44-
<see userInput="Video" selector="{{PageBuilderPanel.mediaGroupContentType}}" stepKey="seeMediaGroupVideo"/>
45-
<see userInput="Banner" selector="{{PageBuilderPanel.mediaGroupContentType}}" stepKey="seeMediaGroupBanner"/>
46-
<see userInput="Slider" selector="{{PageBuilderPanel.mediaGroupContentType}}" stepKey="seeMediaGroupSlider"/>
47-
<see userInput="Map" selector="{{PageBuilderPanel.mediaGroupContentType}}" stepKey="seeMediaGroupMap"/>
48-
<click selector="{{PageBuilderPanel.addContentGroup}}" stepKey="clickAddContentGroup"/>
49-
<seeNumberOfElements selector="{{PageBuilderPanel.allGroupContentTypes('add_content')}}" userInput="2" stepKey="seeNumberOfAddContentGroupContentTypes"/>
50-
<see userInput="Add Content" selector="{{PageBuilderPanel.addContentGroup}}" stepKey="seeAddContentGroup"/>
51-
<see userInput="Block" selector="{{PageBuilderPanel.addContentGroupContentType}}" stepKey="seeAddContentGroupBlock"/>
52-
<see userInput="Products" selector="{{PageBuilderPanel.addContentGroupContentType}}" stepKey="seeAddContentGroupProducts"/>
25+
<actionGroup name="validateMenuSectionsAndContentTypes">
26+
<seeNumberOfElements selector="{{PageBuilderPanel.allPanelMenuSections}}" userInput="4" stepKey="seeNumberOfMenuSections"/>
27+
<seeNumberOfElements selector="{{PageBuilderPanel.allMenuSectionContentTypes('layout')}}" userInput="3" stepKey="seeNumberOfLayoutMenuSectionContentTypes"/>
28+
<see userInput="Layout" selector="{{PageBuilderPanel.layoutMenuSection}}" stepKey="seeLayoutMenuSection"/>
29+
<see userInput="Row" selector="{{PageBuilderPanel.layoutMenuSectionContentType}}" stepKey="seeLayoutMenuSectionRow"/>
30+
<see userInput="Column" selector="{{PageBuilderPanel.layoutMenuSectionContentType}}" stepKey="seeLayoutMenuSectionColumn"/>
31+
<see userInput="Tabs" selector="{{PageBuilderPanel.layoutMenuSectionContentType}}" stepKey="seeLayoutMenuSectionTabs"/>
32+
<click selector="{{PageBuilderPanel.elementsMenuSection}}" stepKey="clickElementsMenuSection"/>
33+
<seeNumberOfElements selector="{{PageBuilderPanel.allMenuSectionContentTypes('elements')}}" userInput="5" stepKey="seeNumberOfElementsMenuSectionContentTypes"/>
34+
<see userInput="Elements" selector="{{PageBuilderPanel.elementsMenuSection}}" stepKey="seeElementsMenuSection"/>
35+
<see userInput="Text" selector="{{PageBuilderPanel.elementsMenuSectionContentType}}" stepKey="seeElementsMenuSectionText"/>
36+
<see userInput="Heading" selector="{{PageBuilderPanel.elementsMenuSectionContentType}}" stepKey="seeElementsMenuSectionHeading"/>
37+
<see userInput="Buttons" selector="{{PageBuilderPanel.elementsMenuSectionContentType}}" stepKey="seeElementsMenuSectionButtons"/>
38+
<see userInput="Divider" selector="{{PageBuilderPanel.elementsMenuSectionContentType}}" stepKey="seeElementsMenuSectionDivider"/>
39+
<see userInput="HTML Code" selector="{{PageBuilderPanel.elementsMenuSectionContentType}}" stepKey="seeElementsMenuSectionHtml"/>
40+
<click selector="{{PageBuilderPanel.mediaMenuSection}}" stepKey="clickMediaMenuSection"/>
41+
<seeNumberOfElements selector="{{PageBuilderPanel.allMenuSectionContentTypes('media')}}" userInput="5" stepKey="seeNumberOfMediaMenuSectionContentTypes"/>
42+
<see userInput="Media" selector="{{PageBuilderPanel.mediaMenuSection}}" stepKey="seeMediaMenuSection"/>
43+
<see userInput="Image" selector="{{PageBuilderPanel.mediaMenuSectionContentType}}" stepKey="seeMediaMenuSectionImage"/>
44+
<see userInput="Video" selector="{{PageBuilderPanel.mediaMenuSectionContentType}}" stepKey="seeMediaMenuSectionVideo"/>
45+
<see userInput="Banner" selector="{{PageBuilderPanel.mediaMenuSectionContentType}}" stepKey="seeMediaMenuSectionBanner"/>
46+
<see userInput="Slider" selector="{{PageBuilderPanel.mediaMenuSectionContentType}}" stepKey="seeMediaMenuSectionSlider"/>
47+
<see userInput="Map" selector="{{PageBuilderPanel.mediaMenuSectionContentType}}" stepKey="seeMediaMenuSectionMap"/>
48+
<click selector="{{PageBuilderPanel.addContentMenuSection}}" stepKey="clickAddContentMenuSection"/>
49+
<seeNumberOfElements selector="{{PageBuilderPanel.allMenuSectionContentTypes('add_content')}}" userInput="2" stepKey="seeNumberOfAddContentMenuSectionContentTypes"/>
50+
<see userInput="Add Content" selector="{{PageBuilderPanel.addContentMenuSection}}" stepKey="seeAddContentMenuSection"/>
51+
<see userInput="Block" selector="{{PageBuilderPanel.addContentMenuSectionContentType}}" stepKey="seeAddContentMenuSectionBlock"/>
52+
<see userInput="Products" selector="{{PageBuilderPanel.addContentMenuSectionContentType}}" stepKey="seeAddContentMenuSectionProducts"/>
5353
</actionGroup>
5454
</actionGroups>

0 commit comments

Comments
 (0)