057-filament-v5-upgrade #66
@ -741,7 +741,8 @@ public static function table(Table $table): Table
|
|||||||
->visible(function (RestoreRun $record): bool {
|
->visible(function (RestoreRun $record): bool {
|
||||||
$backupSet = $record->backupSet;
|
$backupSet = $record->backupSet;
|
||||||
|
|
||||||
return $record->isDeletable()
|
return ! $record->trashed()
|
||||||
|
&& $record->isDeletable()
|
||||||
&& $backupSet !== null
|
&& $backupSet !== null
|
||||||
&& ! $backupSet->trashed();
|
&& ! $backupSet->trashed();
|
||||||
})
|
})
|
||||||
@ -754,10 +755,10 @@ public static function table(Table $table): Table
|
|||||||
$tenant = $record->tenant;
|
$tenant = $record->tenant;
|
||||||
$backupSet = $record->backupSet;
|
$backupSet = $record->backupSet;
|
||||||
|
|
||||||
if (! $tenant || ! $backupSet || $backupSet->trashed()) {
|
if ($record->trashed() || ! $tenant || ! $backupSet || $backupSet->trashed()) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Restore run cannot be rerun')
|
->title('Restore run cannot be rerun')
|
||||||
->body('Backup set is archived or unavailable.')
|
->body('Restore run or backup set is archived or unavailable.')
|
||||||
->warning()
|
->warning()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
@ -1019,7 +1020,6 @@ public static function table(Table $table): Table
|
|||||||
return [
|
return [
|
||||||
Forms\Components\TextInput::make('confirmation')
|
Forms\Components\TextInput::make('confirmation')
|
||||||
->label('Type DELETE to confirm')
|
->label('Type DELETE to confirm')
|
||||||
->required()
|
|
||||||
->in(['DELETE'])
|
->in(['DELETE'])
|
||||||
->validationMessages([
|
->validationMessages([
|
||||||
'in' => 'Please type DELETE to confirm.',
|
'in' => 'Please type DELETE to confirm.',
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Tables\Filters\TrashedFilter;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
|
|
||||||
@ -71,3 +72,34 @@
|
|||||||
expect($newRun->is_dry_run)->toBeTrue();
|
expect($newRun->is_dry_run)->toBeTrue();
|
||||||
expect($newRun->requested_by)->toBe('tester@example.com');
|
expect($newRun->requested_by)->toBe('tester@example.com');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('rerun action is hidden for archived restore runs', function () {
|
||||||
|
$tenant = Tenant::factory()->create();
|
||||||
|
|
||||||
|
$backupSet = BackupSet::factory()->for($tenant)->create([
|
||||||
|
'status' => 'completed',
|
||||||
|
'item_count' => 0,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$run = RestoreRun::create([
|
||||||
|
'tenant_id' => $tenant->id,
|
||||||
|
'backup_set_id' => $backupSet->id,
|
||||||
|
'status' => 'completed',
|
||||||
|
'is_dry_run' => true,
|
||||||
|
'requested_by' => 'tester@example.com',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$run->delete();
|
||||||
|
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$user->tenants()->syncWithoutDetaching([
|
||||||
|
$tenant->getKey() => ['role' => 'owner'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
Filament::setTenant($tenant, true);
|
||||||
|
|
||||||
|
Livewire::actingAs($user)
|
||||||
|
->test(ListRestoreRuns::class)
|
||||||
|
->filterTable(TrashedFilter::class, false)
|
||||||
|
->assertTableActionHidden('rerun', $run);
|
||||||
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user