Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/2.4-develop' into minicart-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
engcom-Foxtrot committed Jan 9, 2020
2 parents ca8c75a + dbb159a commit f9eb4e4
Show file tree
Hide file tree
Showing 3,708 changed files with 100,753 additions and 29,411 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[![Open Source Helpers](https://www.codetriage.com/magento/magento2/badges/users.svg)](https://www.codetriage.com/magento/magento2)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.svg)](https://crowdin.com/project/magento-2)
<h2>Welcome</h2>

## Welcome
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.

## Magento System Requirements
Expand Down Expand Up @@ -30,7 +31,7 @@ To suggest documentation improvements, click [here][4].
[4]: https://devdocs.magento.com

<h3>Community Maintainers</h3>
The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks these Community Maintainers for their valuable contributions.
The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks to these Community Maintainers for their valuable contributions.

<a href="https://magento.com/magento-contributors#maintainers">
<img src="https://raw.githubusercontent.com/wiki/magento/magento2/images/maintainers.png"/>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/AdminAnalytics/registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* See COPYING.txt for license details.
*/

use \Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_AdminAnalytics', __DIR__);
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<item name="text" xsi:type="string" translate="true"><![CDATA[
<p>Help us improve Magento Admin by allowing us to collect usage data.</p>
<p>All usage data that we collect for this purpose cannot be used to individually identify you and is used only to improve the Magento Admin and related products and services.</p>
<p>You can learn more and opt out at any time by following the instructions in <a href="https://docs.magento.com/m2/ce/user_guide/stores/admin.html" target="_blank">merchant documentation</a>.</p>
<p>You can learn more and opt out at any time by following the instructions in <a href="https://docs.magento.com/m2/ce/user_guide/stores/admin.html" target="_blank" tabindex="0">merchant documentation</a>.</p>
]]></item>
</item>
</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@ define([
enableLogAction: '${ $.provider }:data.enableLogAction',
disableLogAction: '${ $.provider }:data.disableLogAction'
},
options: {
keyEventHandlers: {
/**
* Prevents escape key from exiting out of modal
*/
escapeKey: function () {
return;
}
}
},
options: {},
notificationWindow: null
},

Expand All @@ -41,11 +32,32 @@ define([
this._super();
},

/**
* Configure ESC and TAB so user can't leave modal
* without selecting an option
*
* @returns {Object} Chainable.
*/
initModalEvents: function () {
this._super();
//Don't allow ESC key to close modal
this.options.keyEventHandlers.escapeKey = this.handleEscKey.bind(this);
//Restrict tab action to the modal
this.options.keyEventHandlers.tabKey = this.handleTabKey.bind(this);

return this;
},

/**
* Once the modal is opened it hides the X
*/
onOpened: function () {
$('.modal-header button.action-close').hide();
$('.modal-header button.action-close').attr('disabled', true).hide();

this.focusableElements = $(this.rootSelector).find('a[href], button:enabled');
this.firstFocusableElement = this.focusableElements[0];
this.lastFocusableElement = this.focusableElements[this.focusableElements.length - 1];
this.firstFocusableElement.focus();
},

/**
Expand Down Expand Up @@ -104,11 +116,70 @@ define([
* Allows admin usage popup to be shown first and then new release notification
*/
openReleasePopup: function () {
var notifiModal = registry.get('release_notification.release_notification.notification_modal_1');
var notificationModalSelector = 'release_notification.release_notification.notification_modal_1';

if (analyticsPopupConfig.releaseVisible) {
notifiModal.initializeContentAfterAnalytics();
registry.get(notificationModalSelector).initializeContentAfterAnalytics();
}
},

/**
* Handle Tab and Shift+Tab key event
*
* Keep the tab actions restricted to the popup modal
* so the user must select an option to dismiss the modal
*/
handleTabKey: function (event) {
var modal = this,
KEY_TAB = 9;

/**
* Handle Shift+Tab to tab backwards
*/
function handleBackwardTab() {
if (document.activeElement === modal.firstFocusableElement ||
document.activeElement === $(modal.rootSelector)[0]
) {
event.preventDefault();
modal.lastFocusableElement.focus();
}
}

/**
* Handle Tab forward
*/
function handleForwardTab() {
if (document.activeElement === modal.lastFocusableElement) {
event.preventDefault();
modal.firstFocusableElement.focus();
}
}

switch (event.keyCode) {
case KEY_TAB:
if (modal.focusableElements.length === 1) {
event.preventDefault();
break;
}

if (event.shiftKey) {
handleBackwardTab();
break;
}
handleForwardTab();
break;
default:
break;
}
},

/**
* Handle Esc key
*
* Esc key should not close modal
*/
handleEscKey: function (event) {
event.preventDefault();
}
}
);
Expand Down
27 changes: 15 additions & 12 deletions app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/**
* Adminhtml AdminNotification Severity Renderer
*
Expand All @@ -8,12 +10,16 @@

namespace Magento\AdminNotification\Block\Grid\Renderer;

use Magento\Backend\Block\Context;
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
use Magento\Framework\App\ActionInterface;
use Magento\Framework\DataObject;
use Magento\Framework\Url\Helper\Data;

/**
* Renderer class for action in the admin notifications grid
*
* @package Magento\AdminNotification\Block\Grid\Renderer
*/
class Actions extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
class Actions extends AbstractRenderer
{
/**
* @var \Magento\Framework\Url\Helper\Data
Expand All @@ -25,11 +31,8 @@ class Actions extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstrac
* @param \Magento\Framework\Url\Helper\Data $urlHelper
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Framework\Url\Helper\Data $urlHelper,
array $data = []
) {
public function __construct(Context $context, Data $urlHelper, array $data = [])
{
$this->_urlHelper = $urlHelper;
parent::__construct($context, $data);
}
Expand All @@ -40,7 +43,7 @@ public function __construct(
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
public function render(DataObject $row)
{
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' .
$this->escapeUrl($row->getUrl())
Expand All @@ -49,7 +52,7 @@ public function render(\Magento\Framework\DataObject $row)

$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl(
'*/*/markAsRead/',
['_current' => true, 'id' => $row->getId()]
['_current' => true, 'id' => $row->getNotificationId()]
) . '">' . __(
'Mark as Read'
) . '</a>' : '';
Expand All @@ -63,8 +66,8 @@ public function render(\Magento\Framework\DataObject $row)
'*/*/remove/',
[
'_current' => true,
'id' => $row->getId(),
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
'id' => $row->getNotificationId(),
ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
]
),
__('Are you sure?'),
Expand Down
12 changes: 10 additions & 2 deletions app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/**
* Adminhtml AdminNotification Severity Renderer
*
Expand All @@ -7,15 +9,21 @@
*/
namespace Magento\AdminNotification\Block\Grid\Renderer;

class Notice extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
use Magento\Framework\DataObject;

/**
* Renderer class for notice in the admin notifications grid
*/
class Notice extends AbstractRenderer
{
/**
* Renders grid column
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
public function render(DataObject $row)
{
return '<span class="grid-row-title">' .
$this->escapeHtml($row->getTitle()) .
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/**
* Adminhtml AdminNotification Severity Renderer
*
Expand All @@ -7,9 +9,16 @@
*/
namespace Magento\AdminNotification\Block\Grid\Renderer;

use Magento\AdminNotification\Model\Inbox;
use Magento\Backend\Block\Context;
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
use Magento\Framework\DataObject;
use Magento\Framework\Notification\MessageInterface;

class Severity extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
/**
* Renderer class for severity in the admin notifications grid
*/
class Severity extends AbstractRenderer
{
/**
* @var \Magento\AdminNotification\Model\Inbox
Expand All @@ -21,11 +30,8 @@ class Severity extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra
* @param \Magento\AdminNotification\Model\Inbox $notice
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\AdminNotification\Model\Inbox $notice,
array $data = []
) {
public function __construct(Context $context, Inbox $notice, array $data = [])
{
parent::__construct($context, $data);
$this->_notice = $notice;
}
Expand All @@ -36,12 +42,14 @@ public function __construct(
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
public function render(DataObject $row)
{
$class = '';
$value = '';

switch ($row->getData($this->getColumn()->getIndex())) {
$column = $this->getColumn();
$index = $column->getIndex();
switch ($row->getData($index)) {
case MessageInterface::SEVERITY_CRITICAL:
$class = 'critical';
$value = $this->_notice->getSeverities(MessageInterface::SEVERITY_CRITICAL);
Expand All @@ -59,6 +67,7 @@ public function render(\Magento\Framework\DataObject $row)
$value = $this->_notice->getSeverities(MessageInterface::SEVERITY_NOTICE);
break;
}

return '<span class="grid-severity-' . $class . '"><span>' . $value . '</span></span>';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
declare(strict_types = 1);

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

/**
* Test class for \Magento\AdminNotification\Block\Grid\Renderer\Actions
*/

namespace Magento\AdminNotification\Test\Unit\Block\Grid\Renderer;

use Magento\AdminNotification\Block\Grid\Renderer\Actions;
use Magento\Backend\Block\Context;
use Magento\Framework\DataObject;
use Magento\Framework\Escaper;
use Magento\Framework\Url\Helper\Data;
use Magento\Framework\UrlInterface;
use PHPUnit\Framework\TestCase;

class ActionsTest extends TestCase
{
/**
* System under Test
* @var Actions
*/
private $sut;

protected function setUp() : void
{
parent::setUp();

/** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaperMock */
$escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
$escaperMock->expects($this->once())->method('escapeUrl')->willReturn('https://magento.com');

/** @var UrlInterface | \PHPUnit_Framework_MockObject_MockObject $urlBuilder */
$urlBuilder = $this->getMockBuilder(UrlInterface::class)->getMock();
$urlBuilder->expects($this->once())->method('getUrl')->willReturn('http://magento.com');

/** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
$contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilder);

/** @var Data | \PHPUnit_Framework_MockObject_MockObject $urlHelperMock */
$urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock();
$urlHelperMock->expects($this->once())->method('getEncodedUrl')->willReturn('http://magento.com');

$this->sut = new Actions($contextMock, $urlHelperMock);
}

public function testShouldRenderMessageWhenUrlIsGiven() : void
{
$dataObject = new DataObject();
$dataObject->setdata('url', 'https://magento.com');
$dataObject->setdata('is_read', true);
$dataObject->setdata('id', 1);

$actual = $this->sut->render($dataObject);

// Ignoring Code Style at this point due to the long HEREDOC
// phpcs:disable
$expected = <<<HTML
<a class="action-details" target="_blank" href="https://magento.com">Read Details</a><a class="action-delete" href="http://magento.com" onClick="deleteConfirm('Are you sure?', this.href); return false;">Remove</a>
HTML;
// phpcs:enable

$this->assertEquals($actual, $expected);
}
}
Loading

0 comments on commit f9eb4e4

Please sign in to comment.