Skip to content

Commit a1486e0

Browse files
committed
Merge branch '2.3-develop' into MAGETWO-88456-translation
2 parents 4199a94 + d189247 commit a1486e0

File tree

189 files changed

+4206
-386
lines changed

Some content is hidden

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

189 files changed

+4206
-386
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Block\Adminhtml\System\Config\Form\Field;
9+
10+
class GoogleMapsApiKey extends \Magento\Config\Block\System\Config\Form\Field
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
protected function _prepareLayout()
16+
{
17+
parent::_prepareLayout();
18+
$this->setTemplate('Magento_PageBuilder::system/config/google_maps_api_key.phtml');
19+
return $this;
20+
}
21+
22+
/**
23+
* @inheritdoc
24+
*/
25+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
26+
{
27+
$element = clone $element;
28+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
29+
return parent::render($element);
30+
}
31+
32+
/**
33+
* @inheritdoc
34+
*/
35+
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
36+
{
37+
$originalData = $element->getOriginalData();
38+
$this->addData(
39+
[
40+
'button_label' => __($originalData['button_label']),
41+
'valid_label' => __($originalData['valid_label']),
42+
'invalid_label' => __($originalData['invalid_label']),
43+
'source_field' => $originalData['source_field'],
44+
'html_id' => $element->getHtmlId(),
45+
'validate_url' => $this->_urlBuilder->getUrl('pagebuilder/googlemaps/validateapi')
46+
]
47+
);
48+
49+
return $this->_toHtml();
50+
}
51+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Block;
9+
10+
/**
11+
* @api
12+
*/
13+
class GoogleMapsApiBlock extends \Magento\Framework\View\Element\Template
14+
{
15+
const GOOGLE_MAPS_API_KEY_PATH = 'cms/pagebuilder/google_maps_api_key';
16+
const GOOGLE_MAPS_LIBRARY_URL = 'https://maps.googleapis.com/maps/api/js?v=3&key=%s';
17+
18+
/**
19+
* Generate URL for retrieving Google Maps Javascript API
20+
*
21+
* @return string
22+
*/
23+
public function getGoogleMapsApiPath(): string
24+
{
25+
$apiKey = $this->_scopeConfig->getValue(self::GOOGLE_MAPS_API_KEY_PATH);
26+
$libraryUrlWithKey = sprintf(self::GOOGLE_MAPS_LIBRARY_URL, $apiKey);
27+
return $libraryUrlWithKey;
28+
}
29+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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\Component;
10+
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\UrlInterface;
13+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
14+
use Magento\PageBuilder\Model\GoogleMaps\ApiKeyValidator;
15+
16+
class GoogleMapsApiKeyValidationContainer extends \Magento\Ui\Component\Container
17+
{
18+
const GOOGLE_MAPS_API_KEY_PATH = 'cms/pagebuilder/google_maps_api_key';
19+
20+
/**
21+
* @var UrlInterface
22+
*/
23+
private $url;
24+
25+
/**
26+
* @var ScopeConfigInterface
27+
*/
28+
private $scopeConfig;
29+
30+
/**
31+
* @var ApiKeyValidator
32+
*/
33+
private $apiKeyValidator;
34+
35+
/**
36+
* Constructor
37+
*
38+
* @param ContextInterface $context
39+
* @param UrlInterface $url
40+
* @param ScopeConfigInterface $scopeConfig
41+
* @param ApiKeyValidator $apiKeyValidator
42+
* @param array $components
43+
* @param array $data
44+
*/
45+
public function __construct(
46+
ContextInterface $context,
47+
UrlInterface $url,
48+
ScopeConfigInterface $scopeConfig,
49+
ApiKeyValidator $apiKeyValidator,
50+
array $components = [],
51+
array $data = []
52+
) {
53+
parent::__construct(
54+
$context,
55+
$components,
56+
$data
57+
);
58+
$this->url = $url;
59+
$this->scopeConfig = $scopeConfig;
60+
$this->apiKeyValidator = $apiKeyValidator;
61+
}
62+
63+
/**
64+
* Prepare component configuration
65+
*
66+
* @return void
67+
*/
68+
public function prepare()
69+
{
70+
parent::prepare();
71+
$config = $this->getData('config');
72+
$apiKey = $this->scopeConfig->getValue(self::GOOGLE_MAPS_API_KEY_PATH) ?: "";
73+
$response = $this->apiKeyValidator->validate($apiKey);
74+
if (!$response['success']) {
75+
$config['visible'] = true;
76+
}
77+
78+
if (isset($config['map_configuration_url'])) {
79+
$config['map_configuration_url'] = $this->url->getUrl($config['map_configuration_url']);
80+
}
81+
if (isset($config['content'])) {
82+
$config['content'] = sprintf($config['content'], $config['map_configuration_url']);
83+
}
84+
85+
$this->setData('config', (array) $config);
86+
}
87+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Controller\Adminhtml\GoogleMaps;
9+
10+
use Magento\Framework\Controller\ResultFactory;
11+
12+
class ValidateApi extends \Magento\Backend\App\Action
13+
{
14+
const ADMIN_RESOURCE = 'Magento_Backend::content';
15+
16+
/**
17+
* @var \Magento\PageBuilder\Model\GoogleMaps\ApiKeyValidator
18+
*/
19+
private $apiKeyValidator;
20+
21+
/**
22+
* Constructor
23+
*
24+
* @param \Magento\Backend\App\Action\Context $context
25+
* @param \Magento\PageBuilder\Model\GoogleMaps\ApiKeyValidator $apiKeyValidator
26+
*/
27+
public function __construct(
28+
\Magento\Backend\App\Action\Context $context,
29+
\Magento\PageBuilder\Model\GoogleMaps\ApiKeyValidator $apiKeyValidator
30+
) {
31+
parent::__construct($context);
32+
$this->apiKeyValidator = $apiKeyValidator;
33+
}
34+
35+
/**
36+
* Send test request to Google Maps and return response
37+
*
38+
* @return \Magento\Framework\Controller\Result\Json
39+
*/
40+
public function execute()
41+
{
42+
$apiKey = $this->getRequest()->getParam('key');
43+
$validationResult = $this->apiKeyValidator->validate($apiKey);
44+
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($validationResult);
45+
}
46+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Model\GoogleMaps;
9+
10+
class ApiKeyValidator
11+
{
12+
const GOOGLE_MAPS_EMBED_URL = 'https://www.google.com/maps/embed/v1/place?key=%s&q=Austin+TX';
13+
14+
/**
15+
* Send test request to Google Maps and return response
16+
*
17+
* @param string $apiKey
18+
* @return array
19+
*/
20+
public function validate(string $apiKey): array
21+
{
22+
$testUrl = sprintf(self::GOOGLE_MAPS_EMBED_URL, $apiKey);
23+
$curl = curl_init($testUrl);
24+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
25+
$result = curl_exec($curl);
26+
$responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
27+
$returnArray = [
28+
'responseMessage' => $responseCode !== 200 ? $result : '',
29+
'success' => $responseCode === 200 ? true : false
30+
];
31+
32+
return $returnArray;
33+
}
34+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="addAccordionItem">
1212
<arguments>
1313
<argument name="index" defaultValue="0" type="string"/>
Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="validateGroupsAndContentTypes">
1212
<see userInput="General" selector="{{PageBuilderActionsSection.generalGroup}}" stepKey="seeGeneralGroup"/>
1313
<see userInput="Row" selector="{{PageBuilderActionsSection.generalGroupBlock}}" stepKey="seeGeneralGroupRow"/>
@@ -79,15 +79,17 @@
7979
<dragAndDrop selector1="{{PageBuilderActionsSection.draggableContentBlockInPanel(contentBlockType.name)}}" selector2="{{PageBuilderActionsSection.dropAreaInStage}}" stepKey="dropContentBlockIntoStage"/>
8080
<waitForLoadingMaskToDisappear stepKey="waitForAnimation" />
8181
<waitForElementVisible time="10" selector="{{PageBuilderActionsSection.contentBlockInStage(contentBlockType.role)}}" stepKey="waitForContentBlockInStage" />
82+
<waitForPageLoad stepKey="waitForToolbarsToLoad" time="30"/>
8283
</actionGroup>
8384
<actionGroup name="dragContentBlockToStageByIndex">
8485
<arguments>
8586
<argument name="contentBlockType" defaultValue=""/>
8687
<argument name="contentBlockNumber" defaultValue="1" type="string"/>
8788
</arguments>
8889
<dragAndDrop selector1="{{PageBuilderActionsSection.draggableContentBlockInPanel(contentBlockType.name)}}" selector2="{{PageBuilderActionsSection.dropAreaInStage}}" stepKey="dropContentBlockIntoStage"/>
89-
<waitForLoadingMaskToDisappear stepKey="waitForAnimation" />
90+
<waitForPageLoad stepKey="waitForAnimation" time="30"/>
9091
<waitForElementVisible time="10" selector="{{PageBuilderActionsSection.contentBlockInStageByIndex(contentBlockType.role, contentBlockNumber)}}" stepKey="waitForContentBlockInStage" />
92+
<waitForPageLoad stepKey="waitForToolbarsToLoad" time="30"/>
9193
</actionGroup>
9294
<actionGroup name="dragContentBlockToStageAndExpectEditPanel">
9395
<arguments>
@@ -109,7 +111,24 @@
109111
</arguments>
110112
<scrollTo selector="{{CmsNewPagePageActionsSection.contentSectionName}}" stepKey="scrollToTopOfStage"/>
111113
<dragAndDrop selector1="{{PageBuilderActionsSection.draggableContentBlockInPanel(contentBlockType.name)}}" selector2="{{PageBuilderActionsSection.contentBlockContainer(containerTargetType.role, containerTargetIndex)}}" stepKey="dropContentBlockIntoStage"/>
114+
<waitForPageLoad stepKey="waitForAnimation" time="30"/>
115+
<waitForElementVisible time="10" selector="{{PageBuilderActionsSection.contentBlockInStageByIndex(contentBlockType.role, contentBlockIndex)}}" stepKey="waitForContentBlockInStage" />
116+
<waitForPageLoad stepKey="waitForToolbarsToLoad" time="30"/>
117+
</actionGroup>
118+
<actionGroup name="dragContentBlockNextToExistingContentBlock">
119+
<arguments>
120+
<argument name="contentBlockType" defaultValue=""/>
121+
<argument name="existingContentBlock" defaultValue=""/>
122+
<argument name="existingContentBlockIndex" defaultValue="1" type="string"/>
123+
<argument name="contentBlockIndex" defaultValue="1" type="string"/>
124+
<argument name="offsetXCoordinate" defaultValue="0" type="string"/>
125+
<argument name="offsetYCoordinate" defaultValue="0" type="string"/>
126+
</arguments>
127+
<scrollTo selector="{{CmsNewPagePageActionsSection.contentSectionName}}" stepKey="scrollToTopOfStage"/>
128+
<dragAndDrop selector1="{{PageBuilderActionsSection.draggableContentBlockInPanel(contentBlockType.name)}}" selector2="{{PageBuilderActionsSection.contentBlockInStageByIndex(existingContentBlock.role, existingContentBlockIndex)}}" x="{{offsetXCoordinate}}" y="{{offsetYCoordinate}}" stepKey="dropContentBlockIntoStage"/>
129+
<waitForPageLoad stepKey="waitForAnimation" time="30"/>
112130
<waitForElementVisible time="10" selector="{{PageBuilderActionsSection.contentBlockInStageByIndex(contentBlockType.role, contentBlockIndex)}}" stepKey="waitForContentBlockInStage" />
131+
<waitForPageLoad stepKey="waitForToolbarsToLoad" time="30"/>
113132
</actionGroup>
114133
<actionGroup name="openPageBuilderEditPanel">
115134
<arguments>
@@ -138,10 +157,10 @@
138157
<waitForElementVisible time="10" selector="{{PageBuilderActionsSection.contentBlockOptionsMenuByIndex(contentBlockType.role, contentBlockIndex)}}" stepKey="waitForOptions"/>
139158
<waitForElementVisible selector="{{PageBuilderActionsSection.contentBlockEditByIndex(contentBlockType.role, contentBlockIndex)}}" stepKey="waitForEditButton"/>
140159
<click selector="{{PageBuilderActionsSection.contentBlockEditByIndex(contentBlockType.role, contentBlockIndex)}}" stepKey="clickEditContentBlock"/>
141-
<waitForLoadingMaskToDisappear stepKey="waitForAnimation"/>
160+
<waitForPageLoad stepKey="waitForAnimation1" time="30"/>
142161
<waitForElementVisible selector="{{PageBuilderActionsSection.editForm}}" stepKey="waitForEditForm"/>
143162
<see userInput="Edit {{contentBlockType.name}}" selector="{{PageBuilderActionsSection.editFormTitle}}" stepKey="seeContentBlockNameInEditFormTitle"/>
144-
<waitForLoadingMaskToDisappear stepKey="waitForAnimation2"/>
163+
<waitForPageLoad stepKey="waitForAnimation2" time="30"/>
145164
</actionGroup>
146165
<actionGroup name="duplicateContentBlock">
147166
<arguments>
@@ -622,40 +641,6 @@
622641
<click selector="{{CmsPagesPageActionsSection.firstItemEditButton}}" stepKey="clickSelectEditOnFirstItem"/>
623642
<waitForPageLoad stepKey="waitForEditCmsPage" />
624643
</actionGroup>
625-
<actionGroup name="enablePageBuilderSetting">
626-
<amOnPage url="{{AdminContentManagementPage.url}}" stepKey="navigateToConfigurationPage" />
627-
<waitForPageLoad stepKey="wait1"/>
628-
<conditionalClick stepKey="expandWYSIWYGOptions" selector="{{ContentManagementSection.PageBuilderOptions}}" dependentSelector="{{ContentManagementSection.CheckIfPageBuilderTabExpanded}}" visible="true" />
629-
<waitForElementVisible selector="{{ContentManagementSection.EnablePageBuilder}}" stepKey="waitForEnablePageBuilder" />
630-
<selectOption selector="{{ContentManagementSection.EnablePageBuilder}}" userInput="Yes" stepKey="selectOption1"/>
631-
<click selector="{{ContentManagementSection.PageBuilderOptions}}" stepKey="collapsePageBuilderOptions" />
632-
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig" />
633-
<waitForPageLoad stepKey="wait2"/>
634-
</actionGroup>
635-
<actionGroup name="disablePageBuilderSetting">
636-
<!-- Enable first since it's dependent on disable Disclaimer modal showing -->
637-
<amOnPage url="{{AdminContentManagementPage.url}}" stepKey="navigateToConfigurationPage1" />
638-
<waitForPageLoad stepKey="waitForPageLoad1"/>
639-
<conditionalClick stepKey="expandWYSIWYGOptions" selector="{{ContentManagementSection.PageBuilderOptions}}" dependentSelector="{{ContentManagementSection.CheckIfPageBuilderTabExpanded}}" visible="true"/>
640-
<waitForElementVisible selector="{{ContentManagementSection.EnablePageBuilder}}" stepKey="waitForEnablePageBuilder"/>
641-
<selectOption selector="{{ContentManagementSection.EnablePageBuilder}}" userInput="Yes" stepKey="selectOption1"/>
642-
<click selector="{{ContentManagementSection.PageBuilderOptions}}" stepKey="collapsePageBuilderOptions"/>
643-
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig"/>
644-
<!-- NOW disable -->
645-
<amOnPage url="{{AdminContentManagementPage.url}}" stepKey="navigateToConfigurationPage2" />
646-
<waitForPageLoad stepKey="waitForPageLoad2"/>
647-
<conditionalClick stepKey="expandPageBuilderTab" selector="{{PageBuilderCollapsibleSection.AdvancedContentToolsTab}}" dependentSelector="{{PageBuilderCollapsibleSection.CheckIfTabOpen}}" visible="true" />
648-
<waitForElementVisible selector="{{PageBuilderCollapsibleSection.EnablePageBuilderDrp}}" stepKey="waitForEnablePageBuilderVisible" />
649-
<selectOption selector="{{PageBuilderCollapsibleSection.EnablePageBuilderDrp}}" userInput="No" stepKey="selectNo"/>
650-
<waitForElementVisible selector="{{PageBuilderCollapsibleSection.DisclaimerMessage}}" stepKey="waitForPopUpMsg2"/>
651-
<waitForElementVisible selector="{{PageBuilderCollapsibleSection.TurnOffBtn}}" stepKey="waitForTurnOffButton"/>
652-
<click selector="{{PageBuilderCollapsibleSection.TurnOffBtn}}" stepKey="selectTurnOff" />
653-
<waitForElementNotVisible selector="{{PageBuilderCollapsibleSection.DisclaimerMessage}}" stepKey="waitForPopupClose2"/>
654-
<seeOptionIsSelected selector="{{PageBuilderCollapsibleSection.EnablePageBuilderDrp}}" userInput="No" stepKey="verifyNoSelected"/>
655-
<click selector="{{PageBuilderCollapsibleSection.AdvancedContentToolsTab}}" stepKey="collapseAdvancedContentToolsTab" />
656-
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig2" />
657-
<waitForPageLoad stepKey="waitForPageLoad3"/>
658-
</actionGroup>
659644
<actionGroup name="verifyPageBuilderVisibleOnPage">
660645
<waitForElementVisible selector="{{PageBuilderActionsSection.identifyPageBuilder}}" stepKey="seePageBuilderVisible" />
661646
<dontSee userInput="Enable Advanced CMS" stepKey="dontSeeEnableAdvancedCMSBtn"/>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="validateVisualSelects">
1212
<arguments>
1313
<argument name="property1" defaultValue=""/>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="validateEmptyAnchorStage">
1212
<arguments>
1313
<argument name="index" defaultValue="1" type="string"/>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="openPageBuilderEditPanelSmallByIndex">
1212
<arguments>
1313
<argument name="contentBlockType" defaultValue=""/>

0 commit comments

Comments
 (0)