Skip to content

Commit 634d286

Browse files
Merge remote-tracking branch '34557/indexer-status-customer-grid' into comm_jul
2 parents 0c799d3 + 5d4f406 commit 634d286

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Scheduled.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Indexer\Block\Backend\Grid\Column\Renderer;
77

8+
use Magento\Customer\Model\Customer;
9+
810
/**
911
* Renderer for 'Scheduled' column in indexer grid
1012
*/
@@ -18,13 +20,35 @@ class Scheduled extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstr
1820
*/
1921
public function render(\Magento\Framework\DataObject $row)
2022
{
23+
if ($this->isPreferRealtime($row->getIndexerId())) {
24+
$scheduleClass = 'grid-severity-major';
25+
$realtimeClass = 'grid-severity-notice';
26+
} else {
27+
$scheduleClass = 'grid-severity-notice';
28+
$realtimeClass = 'grid-severity-major';
29+
}
30+
2131
if ($this->_getValue($row)) {
22-
$class = 'grid-severity-notice';
32+
$class = $scheduleClass;
2333
$text = __('Update by Schedule');
2434
} else {
25-
$class = 'grid-severity-major';
35+
$class = $realtimeClass;
2636
$text = __('Update on Save');
2737
}
38+
2839
return '<span class="' . $class . '"><span>' . $text . '</span></span>';
2940
}
41+
42+
/**
43+
* Determine if an indexer is recommended to be in 'realtime' mode
44+
*
45+
* @param string $indexer
46+
* @return bool
47+
*/
48+
public function isPreferRealtime(string $indexer): bool
49+
{
50+
return in_array($indexer, [
51+
Customer::CUSTOMER_GRID_INDEXER_ID,
52+
]);
53+
}
3054
}

app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/ScheduledTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
class ScheduledTest extends TestCase
1616
{
1717
/**
18+
* @param string $indexer
1819
* @param bool $rowValue
1920
* @param string $class
2021
* @param string $text
2122
* @dataProvider typeProvider
2223
*/
23-
public function testRender($rowValue, $class, $text)
24+
public function testRender($indexer, $rowValue, $class, $text)
2425
{
2526
$html = '<span class="' . $class . '"><span>' . $text . '</span></span>';
2627
$row = new DataObject();
@@ -32,6 +33,7 @@ public function testRender($rowValue, $class, $text)
3233
$model = new Scheduled($context);
3334
$column->setGetter('getValue');
3435
$row->setValue($rowValue);
36+
$row->setIndexerId($indexer);
3537
$model->setColumn($column);
3638

3739
$result = $model->render($row);
@@ -44,9 +46,12 @@ public function testRender($rowValue, $class, $text)
4446
public function typeProvider()
4547
{
4648
return [
47-
[true, 'grid-severity-notice', __('Update by Schedule')],
48-
[false, 'grid-severity-major', __('Update on Save')],
49-
['', 'grid-severity-major', __('Update on Save')],
49+
['customer_grid', true, 'grid-severity-major', __('Update by Schedule')],
50+
['customer_grid', false, 'grid-severity-notice', __('Update on Save')],
51+
['customer_grid', '', 'grid-severity-notice', __('Update on Save')],
52+
['catalog_product_price', true, 'grid-severity-notice', __('Update by Schedule')],
53+
['catalog_product_price', false, 'grid-severity-major', __('Update on Save')],
54+
['catalog_product_price', '', 'grid-severity-major', __('Update on Save')],
5055
];
5156
}
5257
}

app/code/Magento/Indexer/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"require": {
88
"php": "~8.1.0||~8.2.0",
99
"magento/framework": "*",
10-
"magento/module-backend": "*"
10+
"magento/module-backend": "*",
11+
"magento/module-customer": "*"
1112
},
1213
"type": "magento2-module",
1314
"license": [

app/code/Magento/Indexer/etc/module.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
99
<module name="Magento_Indexer" >
1010
<sequence>
11+
<module name="Magento_Customer"/>
1112
<module name="Magento_Store"/>
1213
<module name="Magento_AdminNotification"/>
1314
</sequence>

0 commit comments

Comments
 (0)