Add data export retry and cancel controls
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Filament\Resources\DataExportResource\Tables;
|
||||
|
||||
use App\Jobs\GenerateDataExport;
|
||||
use App\Models\DataExport;
|
||||
use App\Services\Audit\SuperAdminAuditLogger;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
@@ -38,6 +40,7 @@ class DataExportTable
|
||||
DataExport::STATUS_READY => 'success',
|
||||
DataExport::STATUS_FAILED => 'danger',
|
||||
DataExport::STATUS_PROCESSING => 'warning',
|
||||
DataExport::STATUS_CANCELED => 'gray',
|
||||
default => 'gray',
|
||||
}),
|
||||
IconColumn::make('include_media')
|
||||
@@ -71,6 +74,7 @@ class DataExportTable
|
||||
DataExport::STATUS_PROCESSING => __('admin.data_exports.status.processing'),
|
||||
DataExport::STATUS_READY => __('admin.data_exports.status.ready'),
|
||||
DataExport::STATUS_FAILED => __('admin.data_exports.status.failed'),
|
||||
DataExport::STATUS_CANCELED => __('admin.data_exports.status.canceled'),
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
@@ -80,6 +84,45 @@ class DataExportTable
|
||||
->url(fn (DataExport $record) => route('superadmin.data-exports.download', $record))
|
||||
->openUrlInNewTab()
|
||||
->visible(fn (DataExport $record): bool => $record->isReady() && ! $record->hasExpired()),
|
||||
Action::make('retry')
|
||||
->label(__('admin.data_exports.actions.retry'))
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->color('warning')
|
||||
->requiresConfirmation()
|
||||
->visible(fn (DataExport $record): bool => $record->canRetry())
|
||||
->action(function (DataExport $record): void {
|
||||
if (! $record->canRetry()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$record->resetForRetry();
|
||||
GenerateDataExport::dispatch($record->id);
|
||||
|
||||
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||
'updated',
|
||||
$record,
|
||||
source: self::class
|
||||
);
|
||||
}),
|
||||
Action::make('cancel')
|
||||
->label(__('admin.data_exports.actions.cancel'))
|
||||
->icon('heroicon-o-x-circle')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->visible(fn (DataExport $record): bool => $record->canCancel())
|
||||
->action(function (DataExport $record): void {
|
||||
if (! $record->canCancel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$record->markCanceled();
|
||||
|
||||
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||
'updated',
|
||||
$record,
|
||||
source: self::class
|
||||
);
|
||||
}),
|
||||
])
|
||||
->bulkActions([]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user