Skip to content

Commit c32fb8b

Browse files
Merge remote-tracking branch 'magento-l3/ACP2E-1385' into PR-L3-21-02-2023
2 parents 9e21149 + 6e19d56 commit c32fb8b

File tree

8 files changed

+82
-29
lines changed

8 files changed

+82
-29
lines changed

app/code/Magento/AsynchronousOperations/Model/AccessValidator.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
namespace Magento\AsynchronousOperations\Model;
88

9-
/**
10-
* Class AccessValidator
11-
*/
9+
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface;
10+
use Magento\Authorization\Model\UserContextInterface;
11+
1212
class AccessValidator
1313
{
1414
/**
15-
* @var \Magento\Authorization\Model\UserContextInterface
15+
* @var UserContextInterface
1616
*/
1717
private $userContext;
1818

@@ -27,13 +27,12 @@ class AccessValidator
2727
private $bulkSummaryFactory;
2828

2929
/**
30-
* AccessValidator constructor.
31-
* @param \Magento\Authorization\Model\UserContextInterface $userContext
30+
* @param UserContextInterface $userContext
3231
* @param \Magento\Framework\EntityManager\EntityManager $entityManager
3332
* @param \Magento\AsynchronousOperations\Api\Data\BulkSummaryInterfaceFactory $bulkSummaryFactory
3433
*/
3534
public function __construct(
36-
\Magento\Authorization\Model\UserContextInterface $userContext,
35+
UserContextInterface $userContext,
3736
\Magento\Framework\EntityManager\EntityManager $entityManager,
3837
\Magento\AsynchronousOperations\Api\Data\BulkSummaryInterfaceFactory $bulkSummaryFactory
3938
) {
@@ -50,11 +49,15 @@ public function __construct(
5049
*/
5150
public function isAllowed($bulkUuid)
5251
{
53-
/** @var \Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface $bulkSummary */
52+
/** @var BulkSummaryInterface $bulkSummary */
5453
$bulkSummary = $this->entityManager->load(
5554
$this->bulkSummaryFactory->create(),
5655
$bulkUuid
5756
);
57+
if ((int) $bulkSummary->getUserType() === UserContextInterface::USER_TYPE_INTEGRATION) {
58+
return true;
59+
}
60+
5861
return ((int) $bulkSummary->getUserId()) === ((int) $this->userContext->getUserId());
5962
}
6063
}

app/code/Magento/AsynchronousOperations/Model/BulkStatus/Options.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,29 @@
77

88
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface;
99

10-
/**
11-
* Class Options
12-
*/
1310
class Options implements \Magento\Framework\Data\OptionSourceInterface
1411
{
1512
/**
16-
* @return array
13+
* @inheritDoc
1714
*/
1815
public function toOptionArray()
1916
{
2017
return [
2118
[
2219
'value' => BulkSummaryInterface::NOT_STARTED,
23-
'label' => 'Not Started'
20+
'label' => __('Not Started')
2421
],
2522
[
2623
'value' => BulkSummaryInterface::IN_PROGRESS,
27-
'label' => 'In Progress'
24+
'label' => __('In Progress')
2825
],
2926
[
3027
'value' => BulkSummaryInterface::FINISHED_SUCCESSFULLY,
31-
'label' => 'Finished Successfully'
28+
'label' => __('Finished Successfully')
3229
],
3330
[
3431
'value' => BulkSummaryInterface::FINISHED_WITH_FAILURE,
35-
'label' => 'Finished with Failure'
32+
'label' => __('Finished with Failure')
3633
]
3734
];
3835
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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\AsynchronousOperations\Model\BulkUserType;
9+
10+
use Magento\Authorization\Model\UserContextInterface;
11+
use Magento\Framework\Data\OptionSourceInterface;
12+
13+
class Options implements OptionSourceInterface
14+
{
15+
/**
16+
* @inheritDoc
17+
*/
18+
public function toOptionArray(): array
19+
{
20+
return [
21+
[
22+
'value' => UserContextInterface::USER_TYPE_ADMIN,
23+
'label' => __('Admin user')
24+
],
25+
[
26+
'value' => UserContextInterface::USER_TYPE_INTEGRATION,
27+
'label' => __('Integration')
28+
]
29+
];
30+
}
31+
}

app/code/Magento/AsynchronousOperations/Ui/Component/DataProvider/SearchResult.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
99
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
1010
use Magento\Framework\Event\ManagerInterface as EventManager;
11+
use Magento\Framework\Model\ResourceModel\AbstractResource;
1112
use Psr\Log\LoggerInterface as Logger;
1213
use Magento\Authorization\Model\UserContextInterface;
1314
use Magento\Framework\Bulk\BulkSummaryInterface;
1415
use Magento\AsynchronousOperations\Model\StatusMapper;
1516
use Magento\AsynchronousOperations\Model\BulkStatus\CalculatedStatusSql;
1617

17-
/**
18-
* Class SearchResult
19-
*/
2018
class SearchResult extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
2119
{
2220
/**
@@ -40,7 +38,6 @@ class SearchResult extends \Magento\Framework\View\Element\UiComponent\DataProvi
4038
private $calculatedStatusSql;
4139

4240
/**
43-
* SearchResult constructor.
4441
* @param EntityFactory $entityFactory
4542
* @param Logger $logger
4643
* @param FetchStrategy $fetchStrategy
@@ -49,7 +46,7 @@ class SearchResult extends \Magento\Framework\View\Element\UiComponent\DataProvi
4946
* @param StatusMapper $statusMapper
5047
* @param CalculatedStatusSql $calculatedStatusSql
5148
* @param string $mainTable
52-
* @param null $resourceModel
49+
* @param AbstractResource $resourceModel
5350
* @param string $identifierName
5451
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
5552
*/
@@ -80,7 +77,7 @@ public function __construct(
8077
}
8178

8279
/**
83-
* {@inheritdoc}
80+
* @inheritdoc
8481
*/
8582
protected function _initSelect()
8683
{
@@ -93,12 +90,18 @@ protected function _initSelect()
9390
)->where(
9491
'user_id=?',
9592
$this->userContext->getUserId()
93+
)->where(
94+
'user_type=?',
95+
UserContextInterface::USER_TYPE_ADMIN
96+
)->orWhere(
97+
'user_type=?',
98+
UserContextInterface::USER_TYPE_INTEGRATION
9699
);
97100
return $this;
98101
}
99102

100103
/**
101-
* {@inheritdoc}
104+
* @inheritdoc
102105
*/
103106
protected function _afterLoad()
104107
{
@@ -110,7 +113,7 @@ protected function _afterLoad()
110113
}
111114

112115
/**
113-
* {@inheritdoc}
116+
* @inheritdoc
114117
*/
115118
public function addFieldToFilter($field, $condition = null)
116119
{
@@ -133,7 +136,7 @@ public function addFieldToFilter($field, $condition = null)
133136
}
134137

135138
/**
136-
* {@inheritdoc}
139+
* @inheritdoc
137140
*/
138141
public function getSelectCountSql()
139142
{

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ Error,Error
3333
"Dismiss All Completed Tasks","Dismiss All Completed Tasks"
3434
"Action Details - #","Action Details - #"
3535
"Number of Records Affected","Number of Records Affected"
36+
"User Type","User Type"
37+
"Admin user","Admin user"
38+
"Integration","Integration"
39+
"Not Started","Not Started"
40+
"In Progress","In Progress"
41+
"Finished Successfully","Finished Successfully"
42+
"Finished with Failure","Finished with Failure"

app/code/Magento/AsynchronousOperations/view/adminhtml/ui_component/bulk_listing.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@
8181
<label translate="true">Description of Operation</label>
8282
</settings>
8383
</column>
84+
<column name="user_type" component="Magento_Ui/js/grid/columns/select" sortOrder="55">
85+
<settings>
86+
<filter>select</filter>
87+
<options class="\Magento\AsynchronousOperations\Model\BulkUserType\Options"/>
88+
<dataType>select</dataType>
89+
<label translate="true">User Type</label>
90+
</settings>
91+
</column>
8492
<column name="status" component="Magento_Ui/js/grid/columns/select" sortOrder="60">
8593
<settings>
8694
<filter>select</filter>

dev/tests/integration/testsuite/Magento/AsynchronousOperations/Ui/Component/DataProvider/SearchResultTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
use Magento\TestFramework\Helper\Bootstrap;
99

10-
/**
11-
* Class SearchResultTest
12-
*/
1310
class SearchResultTest extends \PHPUnit\Framework\TestCase
1411
{
1512
/**
@@ -29,6 +26,6 @@ public function testGetAllIds()
2926
$searchResult = $objectManager->create(
3027
\Magento\AsynchronousOperations\Ui\Component\DataProvider\SearchResult::class
3128
);
32-
$this->assertEquals(5, $searchResult->getTotalCount());
29+
$this->assertEquals(6, $searchResult->getTotalCount());
3330
}
3431
}

dev/tests/integration/testsuite/Magento/AsynchronousOperations/_files/bulk.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
'description' => 'Bulk Description',
3030
'operation_count' => 3,
3131
],
32+
'in_progress_integration' => [
33+
'uuid' => 'bulk-uuid-2.1',
34+
'user_id' => 100,
35+
'user_type' => \Magento\Authorization\Model\UserContextInterface::USER_TYPE_INTEGRATION,
36+
'description' => 'Bulk Description',
37+
'operation_count' => 3,
38+
],
3239
'in_progress_failed' => [
3340
'uuid' => 'bulk-uuid-3',
3441
'user_id' => 1,

0 commit comments

Comments
 (0)