Skip to content

Commit 6eccc7f

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into 2.2-develop-pr27
2 parents 748d2fc + 22eac8e commit 6eccc7f

File tree

42 files changed

+1171
-166
lines changed

Some content is hidden

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

42 files changed

+1171
-166
lines changed

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,16 @@
139139
<type name="Magento\Backend\Model\Menu\Builder">
140140
<plugin name="SetupMenuBuilder" type="Magento\Backend\Model\Setup\MenuBuilder" />
141141
</type>
142-
<type name="Magento\Config\Model\Config\Structure\ConcealInProductionConfigList">
142+
<type name="Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProduction">
143143
<arguments>
144144
<argument name="configs" xsi:type="array">
145145
<item name="dev" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::HIDDEN</item>
146+
</argument>
147+
</arguments>
148+
</type>
149+
<type name="Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProductionWithoutScdOnDemand">
150+
<arguments>
151+
<argument name="configs" xsi:type="array">
146152
<item name="general/locale/code" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::DISABLED</item>
147153
</argument>
148154
</arguments>

app/code/Magento/Captcha/i18n/en_US.csv

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ Forms,Forms
2020
"Number of Symbols","Number of Symbols"
2121
"Please specify 8 symbols at the most. Range allowed (e.g. 3-5)","Please specify 8 symbols at the most. Range allowed (e.g. 3-5)"
2222
"Symbols Used in CAPTCHA","Symbols Used in CAPTCHA"
23-
"
24-
Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.<br />Similar looking characters (e.g. ""i"", ""l"", ""1"") decrease chance of correct recognition by customer.
25-
","
26-
Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.<br />Similar looking characters (e.g. ""i"", ""l"", ""1"") decrease chance of correct recognition by customer.
27-
"
23+
"Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.<br />Similar looking characters (e.g. ""i"", ""l"", ""1"") decrease chance of correct recognition by customer.","Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.<br />Similar looking characters (e.g. ""i"", ""l"", ""1"") decrease chance of correct recognition by customer."
2824
"Case Sensitive","Case Sensitive"
2925
"Enable CAPTCHA on Storefront","Enable CAPTCHA on Storefront"
3026
"CAPTCHA for ""Create user"" and ""Forgot password"" forms is always enabled if chosen.","CAPTCHA for ""Create user"" and ""Forgot password"" forms is always enabled if chosen."

app/code/Magento/Catalog/Model/Product/Type/AbstractType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function getChildrenIds($parentId, $required = true)
251251
}
252252

253253
/**
254-
* Retrieve parent ids array by requered child
254+
* Retrieve parent ids array by required child
255255
*
256256
* @param int|array $childId
257257
* @return array

app/code/Magento/Checkout/view/frontend/web/js/sidebar.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ define([
99
'Magento_Customer/js/customer-data',
1010
'Magento_Ui/js/modal/alert',
1111
'Magento_Ui/js/modal/confirm',
12+
'underscore',
1213
'jquery/ui',
1314
'mage/decorate',
1415
'mage/collapsible',
1516
'mage/cookies'
16-
], function ($, authenticationPopup, customerData, alert, confirm) {
17+
], function ($, authenticationPopup, customerData, alert, confirm, _) {
1718
'use strict';
1819

1920
$.widget('mage.sidebar', {
@@ -219,6 +220,11 @@ define([
219220
* @param {HTMLElement} elem
220221
*/
221222
_updateItemQtyAfter: function (elem) {
223+
var productData = this._getProductById(Number(elem.data('cart-item')));
224+
225+
if (!_.isUndefined(productData)) {
226+
$(document).trigger('ajax:updateCartItemQty', productData['product_sku']);
227+
}
222228
this._hideItemButton(elem);
223229
},
224230

@@ -241,11 +247,24 @@ define([
241247
* @private
242248
*/
243249
_removeItemAfter: function (elem) {
244-
var productData = customerData.get('cart')().items.find(function (item) {
245-
return Number(elem.data('cart-item')) === Number(item['item_id']);
246-
});
250+
var productData = this._getProductById(Number(elem.data('cart-item')));
251+
252+
if (!_.isUndefined(productData)) {
253+
$(document).trigger('ajax:removeFromCart', productData['product_sku']);
254+
}
255+
},
247256

248-
$(document).trigger('ajax:removeFromCart', productData['product_sku']);
257+
/**
258+
* Retrieves product data by Id.
259+
*
260+
* @param {Number} productId - product Id
261+
* @returns {Object|undefined}
262+
* @private
263+
*/
264+
_getProductById: function (productId) {
265+
return _.find(customerData.get('cart')().items, function (item) {
266+
return productId === Number(item['item_id']);
267+
});
249268
},
250269

251270
/**

app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
require([
22
'jquery',
33
'Magento_Customer/js/customer-data',
4+
'underscore',
45
'domReady!'
5-
], function ($, customerData) {
6+
], function ($, customerData, _) {
67
'use strict';
78

89
var selectors = {
@@ -41,7 +42,7 @@ require([
4142
if (!(data && data.items && data.items.length && productId)) {
4243
return;
4344
}
44-
product = data.items.find(function (item) {
45+
product = _.find(data.items, function (item) {
4546
if (item['item_id'] === itemId) {
4647
return item['product_id'] === productId ||
4748
item['item_id'] === productId;

app/code/Magento/Config/Block/System/Config/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ protected function _getAdditionalElementTypes()
709709
}
710710

711711
/**
712-
* Temporary moved those $this->getRequest()->getParam('blabla') from the code accross this block
712+
* Temporary moved those $this->getRequest()->getParam('blabla') from the code across this block
713713
* to getBlala() methods to be later set from controller with setters
714714
*/
715715

app/code/Magento/Config/Model/Config/Structure/ConcealInProductionConfigList.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
* Defines status of visibility of form elements on Stores > Settings > Configuration page
1212
* in Admin Panel in Production mode.
1313
* @api
14-
* @since 100.2.0
14+
* @deprecated class location was changed
15+
* @see \Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProduction
1516
*/
1617
class ConcealInProductionConfigList implements ElementVisibilityInterface
1718
{
@@ -54,7 +55,7 @@ public function __construct(State $state, array $configs = [])
5455

5556
/**
5657
* @inheritdoc
57-
* @since 100.2.0
58+
* @deprecated
5859
*/
5960
public function isHidden($path)
6061
{
@@ -66,7 +67,7 @@ public function isHidden($path)
6667

6768
/**
6869
* @inheritdoc
69-
* @since 100.2.0
70+
* @deprecated
7071
*/
7172
public function isDisabled($path)
7273
{
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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\Config\Model\Config\Structure\ElementVisibility;
9+
10+
use Magento\Config\Model\Config\Structure\ElementVisibilityInterface;
11+
use Magento\Framework\App\State;
12+
13+
/**
14+
* Defines status of visibility of form elements on Stores > Settings > Configuration page
15+
* in Admin Panel in Production mode.
16+
* @api
17+
*/
18+
class ConcealInProduction implements ElementVisibilityInterface
19+
{
20+
/**
21+
* The list of form element paths with concrete visibility status.
22+
*
23+
* E.g.
24+
*
25+
* ```php
26+
* [
27+
* 'general/locale/code' => ElementVisibilityInterface::DISABLED,
28+
* 'general/country' => ElementVisibilityInterface::HIDDEN,
29+
* ];
30+
* ```
31+
*
32+
* It means that:
33+
* - field Locale (in group Locale Options in section General) will be disabled
34+
* - group Country Options (in section General) will be hidden
35+
*
36+
* @var array
37+
*/
38+
private $configs = [];
39+
40+
/**
41+
* The object that has information about the state of the system.
42+
*
43+
* @var State
44+
*/
45+
private $state;
46+
47+
/**
48+
*
49+
* The list of form element paths which ignore visibility status.
50+
*
51+
* E.g.
52+
*
53+
* ```php
54+
* [
55+
* 'general/country/default' => '',
56+
* ];
57+
* ```
58+
*
59+
* It means that:
60+
* - field 'default' in group Country Options (in section General) will be showed, even if all group(section)
61+
* will be hidden.
62+
*
63+
* @var array
64+
*/
65+
private $exemptions = [];
66+
67+
/**
68+
* @param State $state The object that has information about the state of the system
69+
* @param array $configs The list of form element paths with concrete visibility status.
70+
* @param array $exemptions The list of form element paths which ignore visibility status.
71+
*/
72+
public function __construct(State $state, array $configs = [], array $exemptions = [])
73+
{
74+
$this->state = $state;
75+
$this->configs = $configs;
76+
$this->exemptions = $exemptions;
77+
}
78+
79+
/**
80+
* @inheritdoc
81+
* @since 100.2.0
82+
*/
83+
public function isHidden($path)
84+
{
85+
$path = $this->normalizePath($path);
86+
if ($this->state->getMode() === State::MODE_PRODUCTION
87+
&& preg_match('/(?<group>(?<section>.*?)\/.*?)\/.*?/', $path, $match)) {
88+
$group = $match['group'];
89+
$section = $match['section'];
90+
$exemptions = array_keys($this->exemptions);
91+
$checkedItems = [];
92+
foreach ([$path, $group, $section] as $itemPath) {
93+
$checkedItems[] = $itemPath;
94+
if (!empty($this->configs[$itemPath])) {
95+
return $this->configs[$itemPath] === static::HIDDEN
96+
&& empty(array_intersect($checkedItems, $exemptions));
97+
}
98+
}
99+
}
100+
101+
return false;
102+
}
103+
104+
/**
105+
* @inheritdoc
106+
* @since 100.2.0
107+
*/
108+
public function isDisabled($path)
109+
{
110+
$path = $this->normalizePath($path);
111+
if ($this->state->getMode() === State::MODE_PRODUCTION) {
112+
while (true) {
113+
if (!empty($this->configs[$path])) {
114+
return $this->configs[$path] === static::DISABLED;
115+
}
116+
117+
$position = strripos($path, '/');
118+
if ($position === false) {
119+
break;
120+
}
121+
$path = substr($path, 0, $position);
122+
}
123+
}
124+
125+
return false;
126+
}
127+
128+
/**
129+
* Returns normalized path.
130+
*
131+
* @param string $path The path to be normalized
132+
* @return string The normalized path
133+
*/
134+
private function normalizePath($path)
135+
{
136+
return trim($path, '/');
137+
}
138+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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\Config\Model\Config\Structure\ElementVisibility;
9+
10+
use Magento\Config\Model\Config\Structure\ElementVisibilityInterface;
11+
use Magento\Framework\App\DeploymentConfig;
12+
use Magento\Framework\Config\ConfigOptionsListConstants as Constants;
13+
14+
/**
15+
* Defines status of visibility of form elements on Stores > Settings > Configuration page
16+
* when Constants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION is enabled
17+
* otherwise rule from Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProduction is used
18+
* @see \Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProduction
19+
*
20+
* @api
21+
*/
22+
class ConcealInProductionWithoutScdOnDemand implements ElementVisibilityInterface
23+
{
24+
/**
25+
* @var ConcealInProduction Element visibility rules in the Production mode
26+
*/
27+
private $concealInProduction;
28+
29+
/**
30+
* @var DeploymentConfig The application deployment configuration
31+
*/
32+
private $deploymentConfig;
33+
34+
/**
35+
* @param ConcealInProductionFactory $concealInProductionFactory
36+
* @param DeploymentConfig $deploymentConfig Deployment configuration reader
37+
* @param array $configs The list of form element paths with concrete visibility status.
38+
* @param array $exemptions The list of form element paths which ignore visibility status.
39+
*/
40+
public function __construct(
41+
ConcealInProductionFactory $concealInProductionFactory,
42+
DeploymentConfig $deploymentConfig,
43+
array $configs = [],
44+
array $exemptions = []
45+
) {
46+
$this->concealInProduction = $concealInProductionFactory
47+
->create(['configs' => $configs, 'exemptions' => $exemptions]);
48+
$this->deploymentConfig = $deploymentConfig;
49+
}
50+
51+
/**
52+
* @inheritdoc
53+
*/
54+
public function isHidden($path): bool
55+
{
56+
if (!$this->deploymentConfig->getConfigData(Constants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION)) {
57+
return $this->concealInProduction->isHidden($path);
58+
}
59+
return false;
60+
}
61+
62+
/**
63+
* @inheritdoc
64+
*/
65+
public function isDisabled($path): bool
66+
{
67+
if (!$this->deploymentConfig->getConfigData(Constants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION)) {
68+
return $this->concealInProduction->isDisabled($path);
69+
}
70+
return false;
71+
}
72+
}

0 commit comments

Comments
 (0)