Skip to content

Commit 0d9699f

Browse files
committed
Merge branch 'MC-5723-google-maps' into MC-5255
2 parents b9886fa + df6fc4c commit 0d9699f

File tree

99 files changed

+2634
-4723
lines changed

Some content is hidden

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

99 files changed

+2634
-4723
lines changed

README.md

Lines changed: 12 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,28 @@
1-
# magento2-page-builder
2-
3-
<!-- {% raw %} -->
4-
51
## PageBuilder Early Access Program
62

7-
The PageBuilder Early Access Program (EAP) gives partners the following perks:
8-
9-
* Explore PageBuilder extension points to build custom modules and integrations for 3rd party services, such as Facebook, Instagram, etc.
10-
* Try out PageBuilder customization options and extend its functionality beyond its default features.
11-
* Preview PageBuilder to prepare a migration plan from BlueFoot 1.0 to PageBuilder.
12-
13-
**Note:**
14-
*This program should not be used to design and launch a production website using early code.*
15-
16-
## Installation
17-
18-
We offer one method for installing PageBuilder:
19-
20-
* As a [Composer package] - use this option if you do not plan to contribute to the PageBuilder code repository.
21-
* Using the [GitHub repository] - use this option to install PageBuilder from the GitHub repository and contribute to the code.
22-
23-
[Composer package]: docs/install-pagebuilder.md#composer-installation
24-
[GitHub repository]: docs/install-pagebuilder.md#github-installation
25-
26-
<!-- {% comment %} -->
3+
The Page Builder Early Access Program (EAP) gives partners the following perks:
4+
5+
* Explore extension points to build custom modules and integrations for 3rd party services, such as Facebook and Instagram.
6+
* Try out customization options and extend its functionality beyond its default features.
7+
* Preview to prepare a migration plan from BlueFoot 1.0 to PageBuilder.
278

289
## Developer documentation
2910

30-
### Getting Started
31-
32-
1. [Introduction](docs/getting-started/introduction.md)
33-
2. [Install Page Builder](docs/getting-started/install-pagebuilder.md)
34-
3. [Activate Page Builder](docs/getting-started/activate-pagebuilder.md)
35-
36-
### Customizations
37-
38-
* [Block chooser](docs/customizations/block-chooser.md)
39-
* [Full-width page layouts](docs/customizations/full-width-page-layouts.md)
40-
* [Responsive layouts](docs/customizations/responsive-layouts.md)
41-
* [Storefront customization](docs/customizations/storefront-customization.md)
42-
* [Visual selects](docs/customizations/visual-selects.md)
43-
* [Additional data configuration](docs/customizations/additional-data-configuration.md)
44-
* [Product conditions](docs/customizations/product-conditions.md)
45-
* [Server-side rendered previews](docs/customizations/server-side-rendered-previews.md)
46-
47-
### How Tos
48-
49-
* [How to develop a new content type](docs/how-to/how-to-develop-new-content-type.md)
50-
* [How to develop a container content type](docs/how-to/how-to-develop-container-content-type.md)
51-
* [How to use the Image Uploader](docs/how-to/how-to-use-image-uploader.md)
52-
* [How to add inline text editing](docs/how-to/how-to-add-inline-text-editing.md)
53-
* [How to add a custom toolbar](docs/how-to/how-to-add-custom-toolbar.md)
54-
* [How to convert product attribute fields to use Page Builder](docs/how-to/how-to-convert-product-attributes-to-use-pagebuilder.md)
55-
* [How to store a component master format as a widget-directive](docs/how-to/how-to-store-master-format-as-widget-directive.md)
56-
57-
### Reference
58-
59-
* [Architecture](docs/reference/architecture.md)
60-
* [Events](docs/reference/events.md)
61-
* [Knockout bindings](docs/reference/knockout-bindings.md)
62-
* [Configuration](docs/reference/configuration.md)
63-
* [Master format](docs/reference/master-format.md)
64-
65-
### Migration
66-
67-
* [Migrate from BlueFoot](docs/migration/migrate-from-bluefoot.md)
68-
* [Migrate custom content types from BlueFoot](docs/migration/migrate-custom-content-types-from-bluefoot.md)
69-
70-
<!-- {% endcomment %} -->
11+
We will update the developer documentation frequently during beta. Please use this link to access the latest updates: 
12+
[Page Builder developer documentation](https://devdocs.magedevteam.com/ds_pagebuilder/page-builder/getting-started/introduction.html)
7113

7214
## Contribute to PageBuilder
7315

7416
We appreciate any and all contributions to PageBuilder. If you are interested in contributing to this repository, please see our [Contribution Guide].
7517

76-
[Contribution Guide]: CONTRIBUTING.md
77-
7818
## PageBuilder updates from the Magento core team
7919

80-
The PageBuilder team updates the code every 2 weeks.
81-
**These changes may introduce breaking changes.**
82-
83-
## Provide feedback
20+
We will push new beta releases once a week, including work from the backlog. We don't expect any large breaking changes, but we will communicate them to you if the need arises.
8421

85-
We want to hear what you think of PageBuilder!
86-
We are particularly interested on your thoughts on the following:
22+
## Contact us
8723

88-
* [How would you customize PageBuilder and what do you need to accomplish this task?](https://github.com/magento/magento2-page-builder/issues/57)
89-
* [What web content API do you use or would like to see in PageBuilder?](https://github.com/magento/magento2-page-builder/issues/58)
24+
To participate in technical discussions and ask questions, join us in [Slack], where a number of Page Builder team members are present.
9025

91-
To participate in technical discussions and ask questions, join us in [Slack].
9226

93-
For all other questions or requests, contact [Olena Tkacheva].
94-
95-
[Slack]: https://magentocommeng.slack.com/
96-
[Olena Tkacheva]: https://magentocommeng.slack.com/messages/@UAFV915FB
97-
98-
<!-- {% endraw %} -->
27+
[Contribution Guide]: CONTRIBUTING.md
28+
[Slack]: https://magentocommeng.slack.com/messages/GANS1R4C9

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

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
namespace Magento\PageBuilder\Block;
99

10+
use Magento\Framework\View\Element\Template;
11+
1012
/**
13+
* Google Maps API Block
14+
*
1115
* @api
1216
*/
1317
class GoogleMapsApi extends \Magento\Framework\View\Element\Template
@@ -16,16 +20,24 @@ class GoogleMapsApi extends \Magento\Framework\View\Element\Template
1620
const GOOGLE_MAPS_LIBRARY_URL = 'https://maps.googleapis.com/maps/api/js?v=3&key=%s';
1721
const GOOGLE_MAPS_STYLE_PATH = 'cms/pagebuilder/google_maps_style';
1822

23+
/**
24+
* Retrieve the Google Maps API key
25+
*
26+
* @return string
27+
*/
28+
public function getApiKey(): ?string
29+
{
30+
return $this->_scopeConfig->getValue(self::GOOGLE_MAPS_API_KEY_PATH);
31+
}
32+
1933
/**
2034
* Generate URL for retrieving Google Maps Javascript API
2135
*
2236
* @return string
2337
*/
2438
public function getLibraryUrl(): string
2539
{
26-
$apiKey = $this->_scopeConfig->getValue(self::GOOGLE_MAPS_API_KEY_PATH);
27-
$libraryUrlWithKey = sprintf(self::GOOGLE_MAPS_LIBRARY_URL, $apiKey);
28-
return $libraryUrlWithKey;
40+
return sprintf(self::GOOGLE_MAPS_LIBRARY_URL, $this->getApiKey());
2941
}
3042

3143
/**
@@ -37,4 +49,32 @@ public function getStyle(): ?string
3749
{
3850
return $this->_scopeConfig->getValue(self::GOOGLE_MAPS_STYLE_PATH);
3951
}
52+
53+
/**
54+
* Return the translated message for an invalid API key.
55+
*
56+
* @return \Magento\Framework\Phrase
57+
*/
58+
public function getInvalidApiKeyMessage(): \Magento\Framework\Phrase
59+
{
60+
return __(
61+
"You must provide a valid <a href='%1'>Google Maps API key</a> to use a map.",
62+
$this->_urlBuilder->getUrl('adminhtml/system_config/edit/section/cms', ['_fragment' => 'cms_pagebuilder'])
63+
);
64+
}
65+
66+
/**
67+
* Include the Google Maps library within the admin only if the API key is set
68+
*
69+
* @return bool
70+
*/
71+
public function shouldIncludeGoogleMapsLibrary(): bool
72+
{
73+
try {
74+
return $this->_appState->getAreaCode() !== \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE ||
75+
$this->getApiKey();
76+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
77+
return false;
78+
}
79+
}
4080
}

app/code/Magento/PageBuilder/Component/GoogleMapsApiKeyValidationContainer.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Magento\PageBuilder\Model\GoogleMaps\ApiKeyValidator;
1515

1616
/**
17+
* Google Maps API Key Validation Container for UI Component Form
18+
*
1719
* @api
1820
*/
1921
class GoogleMapsApiKeyValidationContainer extends \Magento\Ui\Component\Container
@@ -30,26 +32,19 @@ class GoogleMapsApiKeyValidationContainer extends \Magento\Ui\Component\Containe
3032
*/
3133
private $scopeConfig;
3234

33-
/**
34-
* @var ApiKeyValidator
35-
*/
36-
private $apiKeyValidator;
37-
3835
/**
3936
* Constructor
4037
*
4138
* @param ContextInterface $context
4239
* @param UrlInterface $url
4340
* @param ScopeConfigInterface $scopeConfig
44-
* @param ApiKeyValidator $apiKeyValidator
4541
* @param array $components
4642
* @param array $data
4743
*/
4844
public function __construct(
4945
ContextInterface $context,
5046
UrlInterface $url,
5147
ScopeConfigInterface $scopeConfig,
52-
ApiKeyValidator $apiKeyValidator,
5348
array $components = [],
5449
array $data = []
5550
) {
@@ -60,7 +55,6 @@ public function __construct(
6055
);
6156
$this->url = $url;
6257
$this->scopeConfig = $scopeConfig;
63-
$this->apiKeyValidator = $apiKeyValidator;
6458
}
6559

6660
/**
@@ -73,13 +67,15 @@ public function prepare()
7367
parent::prepare();
7468
$config = $this->getData('config');
7569
$apiKey = $this->scopeConfig->getValue(self::GOOGLE_MAPS_API_KEY_PATH) ?: "";
76-
$response = $this->apiKeyValidator->validate($apiKey);
77-
if (!$response['success']) {
70+
if (trim($apiKey) == "") {
7871
$config['visible'] = true;
7972
}
8073

8174
if (isset($config['map_configuration_url'])) {
82-
$config['map_configuration_url'] = $this->url->getUrl($config['map_configuration_url']);
75+
$config['map_configuration_url'] = $this->url->getUrl(
76+
$config['map_configuration_url'],
77+
['_fragment' => 'cms_pagebuilder']
78+
);
8379
}
8480
if (isset($config['content'])) {
8581
$config['content'] = sprintf($config['content'], $config['map_configuration_url']);

app/code/Magento/PageBuilder/Controller/Adminhtml/GoogleMaps/ValidateApi.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99

1010
use Magento\Framework\Controller\ResultFactory;
1111

12-
class ValidateApi extends \Magento\Backend\App\Action
12+
/**
13+
* Class ValidateApi
14+
*/
15+
class ValidateApi extends \Magento\Backend\App\Action implements \Magento\Framework\App\Action\HttpPostActionInterface
1316
{
1417
const ADMIN_RESOURCE = 'Magento_Backend::content';
1518

@@ -39,7 +42,7 @@ public function __construct(
3942
*/
4043
public function execute()
4144
{
42-
$apiKey = $this->getRequest()->getParam('key');
45+
$apiKey = $this->getRequest()->getParam('googleMapsApiKey');
4346
$validationResult = $this->apiKeyValidator->validate($apiKey);
4447
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($validationResult);
4548
}

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

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,22 @@
218218
<waitForElementVisible selector="{{page.height(index, height.value)}}" stepKey="waitForHeight"/>
219219
<waitForElementVisible selector="{{page.showControls(index, showControls.value)}}" stepKey="waitForShowControls"/>
220220
</actionGroup>
221+
<actionGroup name="validateMapSettingsWithErrorOverlay">
222+
<arguments>
223+
<argument name="page"/>
224+
<argument name="height" defaultValue="PageBuilderMapHeightDefaultProperty"/>
225+
<argument name="showControls" defaultValue="PageBuilderMapShowControls_Default"/>
226+
<argument name="index" defaultValue="1" type="string"/>
227+
</arguments>
228+
<comment userInput="validateMapSettings" stepKey="comment"/>
229+
<waitForElement selector="{{page.base(index)}}" stepKey="waitForMap"/>
230+
<waitForElement selector="{{page.height(index, height.value)}}" stepKey="waitForHeight"/>
231+
<dontSeeElement selector="{{page.height(index, height.value)}}" stepKey="dontSeeHeight"/>
232+
<seeElementInDOM selector="{{page.height(index, height.value)}}" stepKey="seeInDOMHeight"/>
233+
<waitForElement selector="{{page.showControls(index, showControls.value)}}" stepKey="waitForShowControls"/>
234+
<dontSeeElement selector="{{page.showControls(index, showControls.value)}}" stepKey="dontSeeShowControls"/>
235+
<seeElementInDOM selector="{{page.showControls(index, showControls.value)}}" stepKey="seeInDOMShowControls"/>
236+
</actionGroup>
221237
<actionGroup name="validateEmptyMapStoreFront">
222238
<arguments>
223239
<argument name="index" defaultValue="1" type="string"/>
@@ -375,21 +391,20 @@
375391
<waitForElementVisible selector="{{page.latitude(index, latitude)}}" stepKey="waitForLatitude"/>
376392
<waitForElementVisible selector="{{page.longitude(index, longitude)}}" stepKey="waitForLongitude"/>
377393
</actionGroup>
378-
<actionGroup name="dontSeeWarningMessage">
394+
<actionGroup name="validateMapErrorMessageStage">
379395
<arguments>
380-
<argument name="page" defaultValue="MapOnStage"/>
381396
<argument name="index" defaultValue="1" type="string"/>
382397
</arguments>
383-
<waitForElement selector="{{page.base(index)}}" stepKey="seeMap"/>
384-
<dontSee userInput="{{googleMapsAPIKey.warningMessage}}" stepKey="dontSeeWarningMessage"/>
398+
<waitForElement selector="{{MapOnStage.base(index)}}" stepKey="seeMap"/>
399+
<waitForElementVisible selector="{{MapOnStage.errorContainer(index)}}" stepKey="seeMapErrorContainer"/>
400+
<see userInput="{{PageBuilderMapCommonData.mapErrorMessageAdmin}}" selector="{{MapOnStage.errorContainer(index)}}" stepKey="seeMapErrorMessage"/>
385401
</actionGroup>
386-
<actionGroup name="validateMapErrorMessageStage">
402+
<actionGroup name="validateMapErrorMessageAddLocationForm">
387403
<arguments>
388404
<argument name="index" defaultValue="1" type="string"/>
389405
</arguments>
390-
<waitForElement selector="{{MapOnStage.base(index)}}" stepKey="seeMap"/>
391-
<waitForElementVisible selector="{{MapOnStage.errorContainer(index)}}" stepKey="seeMapErrorContainer"/>
392-
<see userInput="{{PageBuilderMapCommonData.mapErrorMessageStage}}" selector="{{MapOnStage.errorContainer(index)}}" stepKey="seeMapErrorMessage"/>
406+
<waitForElementVisible selector="{{AddLocationForm.errorContainer(index)}}" stepKey="seeMapErrorContainer"/>
407+
<see userInput="{{PageBuilderMapCommonData.mapErrorMessageAdmin}}" selector="{{AddLocationForm.errorContainer(index)}}" stepKey="seeMapErrorMessage"/>
393408
</actionGroup>
394409
<actionGroup name="validateMapErrorMessageStorefront">
395410
<arguments>
@@ -400,11 +415,20 @@
400415
<see userInput="{{PageBuilderMapCommonData.mapErrorTitleStorefront}}" selector="{{MapOnStorefront.errorTitle(index)}}" stepKey="seeMapErrorTitle"/>
401416
<see userInput="{{PageBuilderMapCommonData.mapErrorMessageStorefront}}" selector="{{MapOnStorefront.errorMessage(index)}}" stepKey="seeMapErrorMessage"/>
402417
</actionGroup>
403-
<actionGroup name="dontSeeRenderedMapOnLocationForm">
418+
<actionGroup name="validateWarningMessageLink">
404419
<arguments>
405-
<argument name="index" defaultValue="1" type="string"/>
420+
<argument name="section"/>
406421
</arguments>
407-
<waitForElementVisible selector="{{AddLocationForm.base(index)}}" stepKey="seeMap"/>
408-
<dontSeeElementInDOM selector="{{AddLocationForm.renderedMap}}" stepKey="dontSeeRenderedMap"/>
422+
<waitForElementVisible selector="{{section.warningMessageLink}}" stepKey="waitForWarningMessageLink"/>
423+
<click selector="{{section.warningMessageLink}}" stepKey="clickLink"/>
424+
<waitForPageLoad stepKey="waitForPageLoad"/>
425+
<seeInCurrentUrl url="{{AdminContentManagementPage.url}}#cms_pagebuilder" stepKey="validateURL"/>
426+
<seeElement selector="{{ContentManagementSection.GoogleMapsAPIKeyInputField}}" stepKey="seeGoogleMapsAPIKeyInputField"/>
427+
</actionGroup>
428+
<actionGroup name="validateAdvancedStyleWithAllUpdatedMapWithErrorOverlay" extends="validateAdvancedStyleWithAllUpdatedNotVisible">
429+
<comment userInput="removing w/ merge" stepKey="dontSeeElement"/>
430+
</actionGroup>
431+
<actionGroup name="validateAdvancedStyleWithNoAlignmentMapWithErrorOverlay" extends="validateAdvancedStyleWithNoAlignmentNotVisible">
432+
<comment userInput="removing w/ merge" stepKey="dontSeeElement"/>
409433
</actionGroup>
410434
</actionGroups>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@
9191
<actionGroup name="clickAndValidateGoogleMapsAPIKeyTestKeyButton">
9292
<arguments>
9393
<argument name="expectedResult" defaultValue="success" type="string"/>
94+
<argument name="buttonText" type="string"/>
9495
</arguments>
9596
<comment userInput="clickAndValidateGoogleMapsAPIKeyTestKeyButton" stepKey="comment"/>
9697
<waitForElementVisible selector="{{ContentManagementSection.GoogleMapsAPIKeyTestKeyButton}}" stepKey="waitForTestKeyButtonEnabled"/>
9798
<click selector="{{ContentManagementSection.GoogleMapsAPIKeyTestKeyButton}}" stepKey="clickTestKeyButton"/>
9899
<waitForPageLoad stepKey="waitForPageLoad"/>
99-
<waitForElementVisible selector="{{ContentManagementSection.GoogleMapsAPIKeyTestKeyResult(expectedResult)}}" stepKey="waitForTestKeyButtonResult"/>
100+
<waitForElementVisible selector="{{ContentManagementSection.GoogleMapsAPIKeyTestKeyResult}} .icon-admin-pagebuilder-{{expectedResult}}" stepKey="waitForTestKeyButtonResult"/>
101+
<see userInput="{{buttonText}}" selector="{{ContentManagementSection.GoogleMapsAPIKeyTestKeyResult}}" stepKey="seeTestKeyButtonText"/>
100102
</actionGroup>
101103
<actionGroup name="inputGoogleMapsStyle">
102104
<arguments>

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
<data key="row">row_cms_pagebuilder_google_maps_api_key</data>
1414
<data key="label">Google Maps API Key</data>
1515
<data key="default"/>
16-
<data key="valid">AIzaSyCw10cOO31cpxb2bcwnHPHKtxov8oUbxJw</data>
16+
<data key="valid">AIzaSyA7TbgpW4U9yKFNzJmHPwLUh_bWt9nXBl4</data>
1717
<data key="invalidOneCharacter">a</data>
18-
<data key="invalidOneCharacterOffOfValid">aIzaSyCw10cOO31cpxb2bcwnHPHKtxov8oUbxJw</data>
18+
<data key="invalidOneCharacterOffOfValid">aIzaSyA7TbgpW4U9yKFNzJmHPwLUh_bWt9nXBl4</data>
1919
<data key="empty"/>
2020
<data key="warningMessage">You must provide the Google Maps API key in order to use the map</data>
21+
<data key="keyButtonText">Test Key</data>
22+
<data key="invalidKeyButtonText">Key is invalid. Try a different key.</data>
23+
<data key="validKeyButtonText">Key is valid</data>
2124
</entity>
2225
<entity name="googleMapsStyle" type="config">
2326
<data key="section">cms_pagebuilder</data>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<entity name="PageBuilderMapCommonData" type="pagebuilder__map_common_data">
2525
<data key="mapErrorTitleStorefront">Oops! Something went wrong.</data>
2626
<data key="mapErrorMessageStorefront">This page didn't load Google Maps correctly. See the JavaScript console for technical details.</data>
27-
<data key="mapErrorMessageStage">Enter API Key to use Google Maps</data>
27+
<data key="mapErrorMessageAdmin">You must provide a valid Google Maps API key to use a map.</data>
2828
</entity>
2929
<!-- Map Position -->
3030
<entity name="PageBuilderMapPositionDefaultProperty" type="pagebuilder_map_position_property">

app/code/Magento/PageBuilder/Test/Mftf/Section/ContentManagementSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<element name="ConfigurationFieldLabel" type="button" selector="//div[contains(@class,'form-inline')]//fieldset[@id='{{arg1}}']//tr[@id='{{arg2}}']//span[.='{{arg3}}']" parameterized="true"/>
2121
<element name="GoogleMapsAPIKeyInputField" type="input" selector="#cms_pagebuilder_google_maps_api_key"/>
2222
<element name="GoogleMapsAPIKeyTestKeyButton" type="button" selector="#cms_pagebuilder_google_maps_api_key_validator"/>
23-
<element name="GoogleMapsAPIKeyTestKeyResult" type="button" selector="#cms_pagebuilder_google_maps_api_key_validator .result .icon-admin-pagebuilder-{{arg1}}" parameterized="true"/>
23+
<element name="GoogleMapsAPIKeyTestKeyResult" type="button" selector="#cms_pagebuilder_google_maps_api_key_validator .result"/>
2424
<element name="GoogleMapsAPIKeyHelperText" type="text" selector="#row_cms_pagebuilder_google_maps_api_key .value .note span"/>
2525
<element name="GoogleMapsGetAPIKeyLink" type="button" selector="#row_cms_pagebuilder_google_maps_api_key a[href]"/>
2626
<element name="GoogleMapsStyleInputField" type="input" selector="#cms_pagebuilder_google_maps_style"/>

0 commit comments

Comments
 (0)