Skip to content

Commit 4c6fcbb

Browse files
Merge pull request #16 from magentix/feature/display-error-column
Display the error message directly in the grid
2 parents 79984a3 + 58d0a24 commit 4c6fcbb

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/*
3+
* Copyright © Ghost Unicorns snc. All rights reserved.
4+
* See LICENSE for license details.
5+
*/
6+
7+
namespace GhostUnicorns\WebapiLogs\Ui\Component\Listing\Column;
8+
9+
use Magento\Ui\Component\Listing\Columns\Column;
10+
11+
class ResponseBody extends Column
12+
{
13+
public function prepareDataSource(array $dataSource): array
14+
{
15+
if (isset($dataSource['data']['items'])) {
16+
foreach ($dataSource['data']['items'] as & $item) {
17+
if (isset($item[$this->getData('name')]) && isset($item['response_code'])) {
18+
if ((int)$item['response_code'] === 200) {
19+
$item[$this->getData('name')] = '';
20+
}
21+
}
22+
}
23+
}
24+
25+
return $dataSource;
26+
}
27+
}

view/adminhtml/ui_component/webapi_logs_reports_index_listing.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@
184184
</item>
185185
</argument>
186186
</column>
187+
<column name="response_body" class="GhostUnicorns\WebapiLogs\Ui\Component\Listing\Column\ResponseBody">
188+
<argument name="data" xsi:type="array">
189+
<item name="config" xsi:type="array">
190+
<item name="filter" xsi:type="string">text</item>
191+
<item name="label" xsi:type="string" translate="true">Error</item>
192+
<item name="sortOrder" xsi:type="number">25</item>
193+
<item name="resizeDefaultWidth" xsi:type="string">100</item>
194+
</item>
195+
</argument>
196+
</column>
187197
<column name="created_at" class="GhostUnicorns\WebapiLogs\Ui\Component\Listing\Column\Datetime"
188198
component="Magento_Ui/js/grid/columns/date">
189199
<settings>

0 commit comments

Comments
 (0)