## Summary <!-- Kurz: Was ändert sich und warum? --> ## Spec-Driven Development (SDD) - [ ] Es gibt eine Spec unter `specs/<NNN>-<feature>/` - [ ] Enthaltene Dateien: `plan.md`, `tasks.md`, `spec.md` - [ ] Spec beschreibt Verhalten/Acceptance Criteria (nicht nur Implementation) - [ ] Wenn sich Anforderungen während der Umsetzung geändert haben: Spec/Plan/Tasks wurden aktualisiert ## Implementation - [ ] Implementierung entspricht der Spec - [ ] Edge cases / Fehlerfälle berücksichtigt - [ ] Keine unbeabsichtigten Änderungen außerhalb des Scopes ## Tests - [ ] Tests ergänzt/aktualisiert (Pest/PHPUnit) - [ ] Relevante Tests lokal ausgeführt (`./vendor/bin/sail artisan test` oder `php artisan test`) ## Migration / Config / Ops (falls relevant) - [ ] Migration(en) enthalten und getestet - [ ] Rollback bedacht (rückwärts kompatibel, sichere Migration) - [ ] Neue Env Vars dokumentiert (`.env.example` / Doku) - [ ] Queue/cron/storage Auswirkungen geprüft ## UI (Filament/Livewire) (falls relevant) - [ ] UI-Flows geprüft - [ ] Screenshots/Notizen hinzugefügt ## Notes <!-- Links, Screenshots, Follow-ups, offene Punkte --> Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #3
60 lines
2.0 KiB
PHP
60 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\PolicyResource\Pages;
|
|
|
|
use App\Filament\Resources\PolicyResource;
|
|
use App\Services\Intune\VersionService;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\ViewRecord;
|
|
use Filament\Support\Enums\Width;
|
|
|
|
class ViewPolicy extends ViewRecord
|
|
{
|
|
protected static string $resource = PolicyResource::class;
|
|
|
|
protected Width|string|null $maxContentWidth = Width::Full;
|
|
|
|
protected function getActions(): array
|
|
{
|
|
return [
|
|
Action::make('capture_snapshot')
|
|
->label('Capture snapshot')
|
|
->requiresConfirmation()
|
|
->modalHeading('Capture snapshot now')
|
|
->modalSubheading('This will fetch the latest configuration from Microsoft Graph and store a new policy version.')
|
|
->action(function () {
|
|
$policy = $this->record;
|
|
|
|
try {
|
|
$tenant = $policy->tenant;
|
|
|
|
if (! $tenant) {
|
|
Notification::make()
|
|
->title('Policy has no tenant associated.')
|
|
->danger()
|
|
->send();
|
|
|
|
return;
|
|
}
|
|
|
|
app(VersionService::class)->captureFromGraph($tenant, $policy, auth()->user()?->email ?? null);
|
|
|
|
Notification::make()
|
|
->title('Snapshot captured successfully.')
|
|
->success()
|
|
->send();
|
|
|
|
$this->redirect($this->getResource()::getUrl('view', ['record' => $policy->getKey()]));
|
|
} catch (\Throwable $e) {
|
|
Notification::make()
|
|
->title('Failed to capture snapshot: '.$e->getMessage())
|
|
->danger()
|
|
->send();
|
|
}
|
|
})
|
|
->color('primary'),
|
|
];
|
|
}
|
|
}
|