Skip to content

Commit

Permalink
Use Sansec PackageVerdict Naming Convention
Browse files Browse the repository at this point in the history
  • Loading branch information
pykettk committed Apr 27, 2023
1 parent ab10abf commit 15dc07e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 88 deletions.
18 changes: 0 additions & 18 deletions Enum/IntegrityCheckerArrayKeys.php

This file was deleted.

5 changes: 3 additions & 2 deletions Model/IntegrityResultsRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Element119\SansecComposerIntegrityChecker\Model;

use Element119\SansecComposerIntegrityChecker\Enum\IntegrityCheckerArrayKeys;
use Element119\SansecComposerIntegrityChecker\Scope\Config;
use Exception;
use Hyva\Admin\Api\HyvaGridArrayProviderInterface;
Expand Down Expand Up @@ -71,7 +70,9 @@ public function getFailedMatches(array $packages = []): array
$threshold = $this->moduleConfig->getSansecComposerIntegrityMatchThreshold();

foreach ($packages ?: $this->getLastResults() as $package) {
if ((int)$package[IntegrityCheckerArrayKeys::Percentage->value] < $threshold) {
$package = (array)$package;

if ((int)$package['percentage'] < $threshold) {
$failures[] = $package;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
</source>
<columns>
<include>
<column name="package"/>
<column name="name"/>
<column name="version"/>
<column name="status"/>
<column name="verdict"/>
<column name="percentage"/>
<column name="checksum"/>
<column name="package_id"/>
<column name="id"/>
</include>
</columns>
<navigation>
Expand All @@ -27,19 +27,19 @@
<export type="xlsx" label="Export as XLSX"/>
</exports>
<filters>
<filter column="package"/>
<filter column="name"/>
<filter column="version"/>
<filter column="status"/>
<filter column="verdict"/>
<filter column="percentage"/>
<filter column="checksum"/>
<filter column="package_id"/>
<filter column="id"/>
</filters>
<pager>
<defaultPageSize>20</defaultPageSize>
<pageSizes>20,30,50,100,200</pageSizes>
</pager>
<sorting>
<defaultSortByColumn>package</defaultSortByColumn>
<defaultSortByColumn>name</defaultSortByColumn>
<defaultSortDirection>asc</defaultSortDirection>
</sorting>
</navigation>
Expand Down
73 changes: 12 additions & 61 deletions view/adminhtml/templates/email/failure-list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
declare(strict_types=1);

use Element119\SansecComposerIntegrityChecker\Enum\IntegrityCheckerArrayKeys;
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\Template;

Expand All @@ -16,71 +15,23 @@ use Magento\Framework\View\Element\Template;
<table>
<thead>
<tr>
<th>
<strong>
<?= $escaper->escapeHtml(
__(ucwords(str_replace(['-', '_'], ' ', IntegrityCheckerArrayKeys::Package->value)))
); ?>
</strong>
</th>
<th>
<strong>
<?= $escaper->escapeHtml(
__(ucwords(str_replace(['-', '_'], ' ', IntegrityCheckerArrayKeys::Version->value)))
); ?>
</strong>
</th>
<th>
<strong>
<?= $escaper->escapeHtml(
__(ucwords(str_replace(['-', '_'], ' ', IntegrityCheckerArrayKeys::Status->value)))
); ?>
</strong>
</th>
<th>
<strong>
<?= $escaper->escapeHtml(
__(ucwords(str_replace(['-', '_'], ' ', IntegrityCheckerArrayKeys::Percentage->value)))
); ?>
</strong>
</th>
<th>
<strong>
<?= $escaper->escapeHtml(
__(ucwords(str_replace(['-', '_'], ' ', IntegrityCheckerArrayKeys::Checksum->value)))
); ?>
</strong>
</th>
<th>
<strong>
<?= $escaper->escapeHtml(
__(ucwords(str_replace(['-', '_'], ' ', IntegrityCheckerArrayKeys::PackageId->value)))
); ?>
</strong>
</th>
<th><strong><?= $escaper->escapeHtml(__('Package')); ?></strong></th>
<th><strong><?= $escaper->escapeHtml(__('Version')); ?></strong></th>
<th><strong><?= $escaper->escapeHtml(__('Verdict')); ?></strong></th>
<th><strong><?= $escaper->escapeHtml(__('Percentage')); ?></strong></th>
<th><strong><?= $escaper->escapeHtml(__('Checksum')); ?></strong></th>
<th><strong><?= $escaper->escapeHtml(__('Package ID')); ?></strong></th>
</tr>
</thead>
<tbody>
<?php foreach ($packageData as $data): ?>
<tr>
<td style="padding: 10px;">
<?= $escaper->escapeHtml($data[IntegrityCheckerArrayKeys::Package->value]); ?>
</td>
<td style="padding: 10px;">
<?= $escaper->escapeHtml($data[IntegrityCheckerArrayKeys::Version->value]); ?>
</td>
<td style="padding: 10px;">
<?= $escaper->escapeHtml($data[IntegrityCheckerArrayKeys::Status->value]); ?>
</td>
<td style="padding: 10px;">
<?= $escaper->escapeHtml($data[IntegrityCheckerArrayKeys::Percentage->value]); ?>
</td>
<td style="padding: 10px;">
<?= $escaper->escapeHtml($data[IntegrityCheckerArrayKeys::Checksum->value]); ?>
</td>
<td style="padding: 10px;">
<?= $escaper->escapeHtml($data[IntegrityCheckerArrayKeys::PackageId->value]); ?>
</td>
<td style="padding: 10px;"><?= $escaper->escapeHtml($data['name']); ?></td>
<td style="padding: 10px;"><?= $escaper->escapeHtml($data['version']); ?></td>
<td style="padding: 10px;"><?= $escaper->escapeHtml($data['verdict']); ?></td>
<td style="padding: 10px;"><?= $escaper->escapeHtml($data['percentage']); ?></td>
<td style="padding: 10px;"><?= $escaper->escapeHtml($data['checksum']); ?></td>
<td style="padding: 10px;"><?= $escaper->escapeHtml($data['id']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down

0 comments on commit 15dc07e

Please sign in to comment.