Kurzbeschreibung Versteckt die Rerun-Row-Action für archivierte (soft-deleted) RestoreRuns und verhindert damit fehlerhafte Neu-Starts aus dem Archiv; ergänzt einen Regressionstest. Änderungen Code: RestoreRunResource.php — Sichtbarkeit der rerun-Action geprüft auf ! $record->trashed() und defensive Abbruchprüfung im Action-Handler. Tests: RestoreRunRerunTest.php — neuer Test rerun action is hidden for archived restore runs. Warum Archivierte RestoreRuns durften nicht neu gestartet werden; UI zeigte trotzdem die Option. Das führte zu verwirrendem Verhalten und möglichen Fehlern beim Enqueueing. Verifikation / QA Unit/Feature: ./vendor/bin/sail artisan test tests/Feature/RestoreRunRerunTest.php Stil/format: ./vendor/bin/pint --dirty Manuell (UI): Als Tenant-Admin Filament → Restore Runs öffnen. Filter Archived aktivieren (oder Trashed filter auswählen). Sicherstellen, dass für archivierte Einträge die Rerun-Action nicht sichtbar ist. Auf einem aktiven (nicht-archivierten) Run prüfen, dass Rerun sichtbar bleibt und wie erwartet eine neue RestoreRun erzeugt. Wichtige Hinweise Kein DB-Migration required. Diese PR enthält nur den UI-/Filament-Fix; die zuvor gemachten operative Fixes für Queue/adapter-Reconciliation bleiben ebenfalls auf dem Branch (z. B. frühere commits während der Debugging-Session). T055 (Schema squash) wurde bewusst zurückgestellt und ist nicht Teil dieses PRs. Merge-Checklist Tests lokal laufen (RestoreRunRerunTest grünt) Pint läuft ohne ungepatchte Fehler Branch gepusht: 056-remove-legacy-bulkops (PR-URL: https://git.cloudarix.de/ahmido/TenantAtlas/compare/dev...056-remove-legacy-bulkops) Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #65
68 lines
2.1 KiB
PHP
68 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\OpsUx;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
final class BulkRunContext
|
|
{
|
|
/**
|
|
* @param array{entra_tenant_id?: mixed, directory_context_id?: mixed} $targetScope
|
|
* @param array{kind: string, ids_hash?: string, query_hash?: string} $selectionIdentity
|
|
* @param array<string, mixed> $extra
|
|
* @return array<string, mixed>
|
|
*/
|
|
public static function build(
|
|
string $operationType,
|
|
array $targetScope,
|
|
array $selectionIdentity,
|
|
string $fingerprint,
|
|
array $extra = [],
|
|
): array {
|
|
$targetScope = self::normalizeTargetScope($targetScope);
|
|
|
|
return array_merge($extra, [
|
|
'operation' => [
|
|
'type' => trim($operationType),
|
|
],
|
|
'target_scope' => $targetScope,
|
|
'selection' => $selectionIdentity,
|
|
'idempotency' => [
|
|
'fingerprint' => trim($fingerprint),
|
|
],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @param array{entra_tenant_id?: mixed, directory_context_id?: mixed} $targetScope
|
|
* @return array{entra_tenant_id?: string, directory_context_id?: string}
|
|
*/
|
|
public static function normalizeTargetScope(array $targetScope): array
|
|
{
|
|
$entraTenantId = $targetScope['entra_tenant_id'] ?? null;
|
|
$directoryContextId = $targetScope['directory_context_id'] ?? null;
|
|
|
|
$normalized = [];
|
|
|
|
if (is_string($entraTenantId) && trim($entraTenantId) !== '') {
|
|
$normalized['entra_tenant_id'] = trim($entraTenantId);
|
|
}
|
|
|
|
if (is_string($directoryContextId) && trim($directoryContextId) !== '') {
|
|
$normalized['directory_context_id'] = trim($directoryContextId);
|
|
}
|
|
|
|
if (is_int($directoryContextId)) {
|
|
$normalized['directory_context_id'] = (string) $directoryContextId;
|
|
}
|
|
|
|
if (! isset($normalized['entra_tenant_id']) && ! isset($normalized['directory_context_id'])) {
|
|
throw new InvalidArgumentException('Target scope must include entra_tenant_id or directory_context_id.');
|
|
}
|
|
|
|
return $normalized;
|
|
}
|
|
}
|