Skip to content

Commit b56762f

Browse files
author
Michael Yu
committed
MC-823: Address architecture feedback
-Renamed google-maps-api-validator to google-maps-api-key-validator -Renamed mapStyle to just style -Updated variable naming convention
1 parent b5ac7ae commit b56762f

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderMapGoogleMapsStyleTests.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
<actionGroup ref="navigateToStoreFront" stepKey="navigateToStoreFront2">
226226
<argument name="contentType" value="PageBuilderMapContentType"/>
227227
</actionGroup>
228-
<executeJS function="return document.evaluate('//body//script[contains(.,\'mapStyle\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=mapStyle:\s').+(?=')/)" stepKey="mapStyle1"/>
228+
<executeJS function="return document.evaluate('//body//script[contains(.,\'Magento_PageBuilder/js/utils/map\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=style:\s').+(?=')/)" stepKey="mapStyle1"/>
229229
<assertEquals stepKey="assertMapStyle1">
230230
<actualResult type="variable">$mapStyle1</actualResult>
231231
<expectedResult type="string">{{googleMapsStyle.empty}}</expectedResult>
@@ -240,7 +240,7 @@
240240
<actionGroup ref="navigateToStoreFront" stepKey="navigateToStoreFront3">
241241
<argument name="contentType" value="PageBuilderMapContentType"/>
242242
</actionGroup>
243-
<executeJS function="return decodeURIComponent(JSON.parse('&quot;' + document.evaluate('//body//script[contains(.,\'mapStyle\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=mapStyle:\s').+(?=')/)[0].replace(/\\&quot;/g, '\\\\&quot;') + '&quot;'))" stepKey="mapStyle2"/>
243+
<executeJS function="return decodeURIComponent(JSON.parse('&quot;' + document.evaluate('//body//script[contains(.,\'Magento_PageBuilder/js/utils/map\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=style:\s').+(?=')/)[0].replace(/\\&quot;/g, '\\\\&quot;') + '&quot;'))" stepKey="mapStyle2"/>
244244
<assertEquals stepKey="assertMapStyle2">
245245
<actualResult type="variable">$mapStyle2</actualResult>
246246
<expectedResult type="string">{{googleMapsStyle.validShort}}</expectedResult>
@@ -253,7 +253,7 @@
253253
<actionGroup ref="navigateToStoreFront" stepKey="navigateToStoreFront4">
254254
<argument name="contentType" value="PageBuilderMapContentType"/>
255255
</actionGroup>
256-
<executeJS function="return decodeURIComponent(JSON.parse('&quot;' + document.evaluate('//body//script[contains(.,\'mapStyle\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=mapStyle:\s').+(?=')/)[0].replace(/\\&quot;/g, '\\\\&quot;') + '&quot;'))" stepKey="mapStyle3"/>
256+
<executeJS function="return decodeURIComponent(JSON.parse('&quot;' + document.evaluate('//body//script[contains(.,\'Magento_PageBuilder/js/utils/map\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=style:\s').+(?=')/)[0].replace(/\\&quot;/g, '\\\\&quot;') + '&quot;'))" stepKey="mapStyle3"/>
257257
<assertEquals stepKey="assertMapStyle3">
258258
<actualResult type="variable">$mapStyle3</actualResult>
259259
<expectedResult type="string">{{googleMapsStyle.validShort}}</expectedResult>
@@ -264,7 +264,7 @@
264264
<actionGroup ref="navigateToStoreFront" stepKey="navigateToStoreFront5">
265265
<argument name="contentType" value="PageBuilderMapContentType"/>
266266
</actionGroup>
267-
<executeJS function="return document.evaluate('//body//script[contains(.,\'mapStyle\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=mapStyle:\s').+(?=')/)" stepKey="mapStyle4"/>
267+
<executeJS function="return document.evaluate('//body//script[contains(.,\'Magento_PageBuilder/js/utils/map\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=style:\s').+(?=')/)" stepKey="mapStyle4"/>
268268
<assertEquals stepKey="assertMapStyle4">
269269
<actualResult type="variable">$mapStyle4</actualResult>
270270
<expectedResult type="string">{{googleMapsStyle.empty}}</expectedResult>
@@ -318,7 +318,7 @@
318318
<switchToPreviousTab stepKey="switchToPreviousTab"/>
319319
<reloadPage stepKey="reloadPage"/>
320320
<waitForPageLoad stepKey="waitForPageLoad"/>
321-
<executeJS function="return decodeURIComponent(JSON.parse('&quot;' + document.evaluate('//body//script[contains(.,\'mapStyle\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=mapStyle:\s').+(?=')/)[0].replace(/\\&quot;/g, '\\\\&quot;') + '&quot;'))" stepKey="mapStyle1"/>
321+
<executeJS function="return decodeURIComponent(JSON.parse('&quot;' + document.evaluate('//body//script[contains(.,\'Magento_PageBuilder/js/utils/map\')]', document, null, XPathResult.STRING_TYPE, null).stringValue.match(/(?&lt;=style:\s').+(?=')/)[0].replace(/\\&quot;/g, '\\\\&quot;') + '&quot;'))" stepKey="mapStyle1"/>
322322
<assertEquals stepKey="assertMapStyle1">
323323
<actualResult type="variable">$mapStyle1</actualResult>
324324
<expectedResult type="string">{{googleMapsStyle.validShort}}</expectedResult>

app/code/Magento/PageBuilder/view/adminhtml/templates/system/config/google_maps_api_key.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
type="button"
1313
id="<?= $block->escapeHtmlAttr($block->getHtmlId()) ?>"
1414
data-mage-init='{
15-
"Magento_PageBuilder/js/system/config/google-maps-api-validator": {
15+
"Magento_PageBuilder/js/system/config/google-maps-api-key-validator": {
1616
"elementId": "<?= $block->escapeJs($block->getHtmlId()) ?>",
1717
"validateUrl": "<?= $block->escapeJs($block->getValidateUrl()) ?>",
1818
"buttonLabel": "<?= $block->escapeJs($block->getButtonLabel()) ?>",

app/code/Magento/PageBuilder/view/adminhtml/web/js/system/config/google-maps-api-validator.js renamed to app/code/Magento/PageBuilder/view/adminhtml/web/js/system/config/google-maps-api-key-validator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ define(['jquery'], function($) {
1212
* @param {Object} config
1313
* @param {HTMLElement} el
1414
*/
15-
var GoogleMapsApiValidator = function(config, el) {
15+
var GoogleMapsApiKeyValidator = function(config, el) {
1616
var sourceElement = $('#' + config.sourceField),
1717
initialValue = sourceElement.val(),
1818
resultElement = $('#' + config.elementId + ' > .result');
@@ -50,5 +50,5 @@ define(['jquery'], function($) {
5050
})
5151
};
5252

53-
return GoogleMapsApiValidator;
53+
return GoogleMapsApiKeyValidator;
5454
});

app/code/Magento/PageBuilder/view/base/templates/googlemaps.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
config: {
1515
'Magento_PageBuilder/js/utils/map': {
16-
mapStyle: '<?= $block->escapeJs($block->getStyle()); ?>'
16+
style: '<?= $block->escapeJs($block->getStyle()); ?>'
1717
}
1818
}
1919
});

app/code/Magento/PageBuilder/view/base/web/js/utils/map.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ define([
3535
};
3636
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
3737

38-
return function (element, markers, options) {
39-
var mapOptions,
40-
mapStyle;
38+
return function (element, markers, additionalOptions) {
39+
var options,
40+
style;
4141

4242
/**
4343
* Replace the content of element with a placeholder
@@ -64,12 +64,12 @@ define([
6464
* Just in case of a bad JSON that bypassed validation
6565
*/
6666
try {
67-
mapStyle = module.config().mapStyle ? JSON.parse(module.config().mapStyle) : [];
67+
style = module.config().style ? JSON.parse(module.config().style) : [];
6868
}
6969
catch (error) {
70-
mapStyle = [];
70+
style = [];
7171
}
72-
mapOptions = _.extend({
72+
options = _.extend({
7373
zoom: 8,
7474
center: getGoogleLatitudeLongitude({
7575
latitude: 30.2672,
@@ -82,11 +82,11 @@ define([
8282
mapTypeControlOptions: {
8383
style: google.maps.MapTypeControlStyle.DEFAULT
8484
},
85-
styles: mapStyle
86-
}, options);
85+
styles: style
86+
}, additionalOptions);
8787

8888
/* Create the map */
89-
this.map = new google.maps.Map(element, mapOptions);
89+
this.map = new google.maps.Map(element, options);
9090
this.markers = [];
9191

9292
/**

0 commit comments

Comments
 (0)