Hydrate configurationPolicies/{id}/settings for endpoint security/baseline policies so snapshots include real rule data.
Treat those types like Settings Catalog policies in the normalizer so they show the searchable settings table, recognizable categories, and readable choice values (firewall-specific formatting + interface badge parsing).
Improve “General” tab cards: badge lists for platforms/technologies, template reference summary (name/family/version/ID), and ISO timestamps rendered as YYYY‑MM‑DD HH:MM:SS; added regression test for the view.
Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local>
Reviewed-on: #23
75 lines
2.9 KiB
PHP
75 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\PolicyResource\Pages;
|
|
|
|
use App\Filament\Resources\PolicyResource;
|
|
use App\Models\Tenant;
|
|
use App\Services\Intune\PolicySyncService;
|
|
use Filament\Actions;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
|
|
class ListPolicies extends ListRecords
|
|
{
|
|
protected static string $resource = PolicyResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Actions\Action::make('sync')
|
|
->label('Sync from Intune')
|
|
->icon('heroicon-o-arrow-path')
|
|
->color('primary')
|
|
->requiresConfirmation()
|
|
->action(function () {
|
|
try {
|
|
$tenant = Tenant::current();
|
|
|
|
/** @var PolicySyncService $service */
|
|
$service = app(PolicySyncService::class);
|
|
|
|
$result = $service->syncPoliciesWithReport($tenant);
|
|
$syncedCount = count($result['synced'] ?? []);
|
|
$failureCount = count($result['failures'] ?? []);
|
|
|
|
$body = $syncedCount.' policies synced';
|
|
|
|
if ($failureCount > 0) {
|
|
$first = $result['failures'][0] ?? [];
|
|
$firstType = $first['policy_type'] ?? 'unknown';
|
|
$firstStatus = $first['status'] ?? null;
|
|
|
|
$firstErrorMessage = null;
|
|
$firstErrors = $first['errors'] ?? null;
|
|
if (is_array($firstErrors) && isset($firstErrors[0]) && is_array($firstErrors[0])) {
|
|
$firstErrorMessage = $firstErrors[0]['message'] ?? null;
|
|
}
|
|
|
|
$suffix = $firstStatus ? "first: {$firstType} {$firstStatus}" : "first: {$firstType}";
|
|
|
|
if (is_string($firstErrorMessage) && $firstErrorMessage !== '') {
|
|
$suffix .= ' - '.trim($firstErrorMessage);
|
|
}
|
|
|
|
$body .= " ({$failureCount} failed; {$suffix})";
|
|
}
|
|
|
|
Notification::make()
|
|
->title('Policy sync completed')
|
|
->body($body)
|
|
->success()
|
|
->sendToDatabase(auth()->user())
|
|
->send();
|
|
} catch (\Throwable $e) {
|
|
Notification::make()
|
|
->title('Policy sync failed')
|
|
->body($e->getMessage())
|
|
->danger()
|
|
->sendToDatabase(auth()->user())
|
|
->send();
|
|
}
|
|
}),
|
|
];
|
|
}
|
|
}
|