Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m30s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m28s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m36s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 1m45s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 1m44s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 1m35s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 54s
- Rollen mit globalen Rechten und Rechten für einzelne Objekte (z. B. „Beiträge schreiben in Kategorie MAV-Info“); Rollen sind additiv, Zuweisungen merken sich ihre Herkunft (manuell oder später Identity-Provider-Gruppe) - Systemrolle „Administration“ ersetzt users.is_admin (Migration übernimmt bestehende Administratoren); nicht löschbar, man kann sie sich nicht selbst entziehen - Rechte je Person vorberechnet und gecacht, Versionszähler invalidiert bei Änderungen - Gate-Anbindung: registrierte Rechte entscheidet das Rechtesystem, Objektregeln die Policies; Admin-Seiten und Plugin-Ressourcen hinter passenden Rechten - Redaktion nach Kategorie: Schreiben und Veröffentlichen getrennt, Liste im Admin auf eigene Kategorien beschränkt, ohne Veröffentlichungsrecht bleibt ein Beitrag Entwurf - Zielgruppen (Rolle/Abteilung/Standort) für Kategorien und Termine als indizierte SQL-Bedingung in Listen, Detailseiten, Kacheln und .ics-Export - Admin: Rollen-Verwaltung, „Rechte prüfen“, Redaktion und Sichtbarkeit direkt an Kategorie bzw. Termin - Kern-Ressourcen explizit registriert, damit nach Updates liegengebliebene alte Dateien nicht doppelt geladen werden - docs/PLUGINS.md für Plugin-Entwicklung; Demo-Rolle „MAV“ Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
142 lines
5.4 KiB
PHP
142 lines
5.4 KiB
PHP
<?php
|
||
|
||
namespace App\Filament\Pages;
|
||
|
||
use App\Models\VendorFeedback;
|
||
use App\Support\Audit;
|
||
use App\Support\Feedback\FeedbackChannels;
|
||
use App\Support\Feedback\FeedbackOutbox;
|
||
use App\Support\Feedback\FeedbackResult;
|
||
use App\Support\Feedback\TechnicalInfo;
|
||
use App\Support\License\LicenseStore;
|
||
use BackedEnum;
|
||
use Filament\Notifications\Notification;
|
||
use Filament\Pages\Page;
|
||
use Filament\Support\Icons\Heroicon;
|
||
use UnitEnum;
|
||
|
||
/**
|
||
* „Hilfe → Rückmeldung geben“: Fehlerbericht oder Funktionswunsch an den
|
||
* Hersteller (docs/specs/feedback.md).
|
||
*/
|
||
class Feedback extends Page
|
||
{
|
||
protected string $view = 'filament.pages.feedback';
|
||
|
||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedChatBubbleLeftEllipsis;
|
||
|
||
protected static string|UnitEnum|null $navigationGroup = 'Hilfe';
|
||
|
||
protected static ?string $navigationLabel = 'Rückmeldung geben';
|
||
|
||
protected static ?string $title = 'Rückmeldung geben';
|
||
|
||
public static function canAccess(): bool
|
||
{
|
||
return auth()->user()?->can('feedback.send') ?? false;
|
||
}
|
||
|
||
protected static ?string $slug = 'rueckmeldung';
|
||
|
||
public string $type = '';
|
||
|
||
public string $subject = '';
|
||
|
||
public string $body = '';
|
||
|
||
public string $severity = 'normal';
|
||
|
||
public string $email = '';
|
||
|
||
public string $name = '';
|
||
|
||
public ?string $lastReference = null;
|
||
|
||
public ?string $notice = null;
|
||
|
||
public function mount(FeedbackChannels $channels): void
|
||
{
|
||
$this->type = (string) array_key_first($channels->available());
|
||
}
|
||
|
||
public function submit(FeedbackChannels $channels, FeedbackOutbox $outbox, TechnicalInfo $info): void
|
||
{
|
||
$available = $channels->available();
|
||
|
||
$this->validate([
|
||
'type' => ['required', 'in:'.implode(',', array_keys($available))],
|
||
'subject' => ['required', 'string', 'max:255'],
|
||
'body' => ['required', 'string', 'min:10', 'max:20000'],
|
||
'severity' => ['required', 'in:low,normal,high,critical'],
|
||
'email' => ['nullable', 'email', 'max:255'],
|
||
'name' => ['nullable', 'string', 'max:255'],
|
||
], attributes: [
|
||
'type' => 'Art der Meldung', 'subject' => 'Betreff', 'body' => 'Beschreibung',
|
||
'email' => 'E-Mail-Adresse', 'name' => 'Name',
|
||
]);
|
||
|
||
$this->notice = null;
|
||
$this->lastReference = null;
|
||
|
||
$payload = array_filter([
|
||
'title' => $this->subject,
|
||
'body' => $this->body,
|
||
'email' => $this->email ?: null,
|
||
'name' => $this->name ?: null,
|
||
'severity' => $this->type === 'bugreport' ? $this->severity : null,
|
||
...$info->collect(),
|
||
], fn ($value) => $value !== null);
|
||
|
||
$result = $outbox->submit(auth()->user(), $this->type, $payload);
|
||
|
||
switch ($result->status) {
|
||
case FeedbackResult::SENT:
|
||
Audit::log('feedback.sent', ['type' => $this->type, 'reference' => $result->reference]);
|
||
$this->lastReference = $result->reference;
|
||
$this->reset(['subject', 'body', 'severity']);
|
||
Notification::make()->success()->title('Vielen Dank – Ihre Meldung ist eingegangen')->body("Referenznummer: {$result->reference}")->persistent()->send();
|
||
break;
|
||
|
||
case FeedbackResult::RETRY:
|
||
$this->reset(['subject', 'body', 'severity']);
|
||
$this->notice = 'Der Server ist gerade nicht erreichbar. Ihre Meldung ist gespeichert und wird automatisch gesendet, sobald es wieder geht. Die Referenznummer erscheint dann unten in der Liste.';
|
||
break;
|
||
|
||
case FeedbackResult::INVALID:
|
||
// Fehler direkt am betroffenen Feld anzeigen (API-Feld „title“ = Formularfeld „subject“).
|
||
foreach ($result->errors as $field => $message) {
|
||
$field = $field === 'title' ? 'subject' : $field;
|
||
$this->addError(in_array($field, ['subject', 'body', 'email', 'name', 'severity'], true) ? $field : 'body', $message);
|
||
}
|
||
|
||
if ($result->errors === []) {
|
||
$this->addError('body', $result->message ?? 'Die Eingabe ist unvollständig.');
|
||
}
|
||
break;
|
||
|
||
case FeedbackResult::RATE_LIMITED:
|
||
$minutes = $result->retryAfter ? max(1, (int) ceil($result->retryAfter / 60)) : null;
|
||
$this->notice = 'Es wurden zu viele Meldungen in kurzer Zeit gesendet. Bitte versuchen Sie es '.($minutes ? "in etwa {$minutes} Minute(n)" : 'später').' noch einmal – Ihre Eingabe bleibt erhalten.';
|
||
break;
|
||
|
||
case FeedbackResult::DISABLED:
|
||
$channels->disable($this->type);
|
||
$this->notice = 'Dieser Meldeweg steht nicht mehr zur Verfügung. Ihre Eingabe bleibt erhalten'.(count($channels->available()) ? ' – bitte wählen Sie eine andere Art der Meldung.' : '.');
|
||
$this->type = (string) array_key_first($channels->available());
|
||
break;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @return array<string, mixed>
|
||
*/
|
||
protected function getViewData(): array
|
||
{
|
||
return [
|
||
'types' => app(FeedbackChannels::class)->available(),
|
||
'technical' => app(TechnicalInfo::class)->collect(),
|
||
'hasLicense' => app(LicenseStore::class)->hasLicense(),
|
||
'history' => VendorFeedback::query()->where('user_id', auth()->id())->latest()->limit(20)->get(),
|
||
];
|
||
}
|
||
}
|