mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-19 13:01:19 +00:00
fix(podcast-import): show cancel or retry action depending on task status
This commit is contained in:
parent
06c4f15477
commit
e42258de1f
@ -145,11 +145,17 @@ class PodcastImportController extends BaseController
|
||||
$importTask = $importQueue[$taskId];
|
||||
switch ($action) {
|
||||
case 'cancel':
|
||||
$importTask->cancel();
|
||||
if ($importTask->status === TaskStatus::Running || $importTask->status === TaskStatus::Queued) {
|
||||
$importTask->cancel();
|
||||
|
||||
return redirect()->back()
|
||||
->with('message', lang('PodcastImport.messages.canceled'));
|
||||
}
|
||||
|
||||
return redirect()->back()
|
||||
->with('message', lang('PodcastImport.messages.canceled'));
|
||||
->with('error', lang('PodcastImport.messages.notRunning'));
|
||||
case 'retry':
|
||||
if ($importTask->status === TaskStatus::Running) {
|
||||
if ($importTask->status === TaskStatus::Running || $importTask->status === TaskStatus::Queued) {
|
||||
return redirect()->back()
|
||||
->with('error', lang('PodcastImport.messages.alreadyRunning'));
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ return [
|
||||
],
|
||||
'messages' => [
|
||||
'canceled' => 'Import task has been successfully canceled!',
|
||||
'notRunning' => 'Cannot cancel Import Task as it is not running.',
|
||||
'alreadyRunning' => 'Import Task is already running. You may cancel it before retrying.',
|
||||
'retried' => 'Import task has been queued, it will be retried shortly!',
|
||||
'deleted' => 'Import task has been successfully deleted!',
|
||||
|
@ -98,31 +98,37 @@ use Modules\PodcastImport\Entities\TaskStatus;
|
||||
[
|
||||
'header' => lang('Common.list.actions'),
|
||||
'cell' => function (PodcastImportTask $importTask) {
|
||||
$menuItems = [
|
||||
[
|
||||
'type' => 'separator',
|
||||
],
|
||||
[
|
||||
'type' => 'link',
|
||||
'title' => lang('PodcastImport.queue.actions.delete'),
|
||||
'uri' => route_to('podcast-imports-task-action', $importTask->id, 'delete'),
|
||||
'class' => 'font-semibold text-red-600',
|
||||
],
|
||||
];
|
||||
|
||||
if ($importTask->status === TaskStatus::Running || $importTask->status === TaskStatus::Queued) {
|
||||
array_unshift($menuItems, [
|
||||
'type' => 'link',
|
||||
'title' => lang('PodcastImport.queue.actions.cancel'),
|
||||
'uri' => route_to('podcast-imports-task-action', $importTask->id, 'cancel'),
|
||||
]);
|
||||
} else {
|
||||
array_unshift($menuItems, [
|
||||
'type' => 'link',
|
||||
'title' => lang('PodcastImport.queue.actions.retry'),
|
||||
'uri' => route_to('podcast-imports-task-action', $importTask->id, 'retry'),
|
||||
], );
|
||||
}
|
||||
|
||||
return '<div class="inline-flex items-center gap-x-2">' .
|
||||
'<button id="more-dropdown-' . $importTask->id . '" type="button" class="inline-flex items-center p-1 rounded-full focus:ring-accent" data-dropdown="button" data-dropdown-target="more-dropdown-' . $importTask->id . '-menu" aria-haspopup="true" aria-expanded="false">' .
|
||||
icon('more') .
|
||||
'</button>' .
|
||||
'<DropdownMenu id="more-dropdown-' . $importTask->id . '-menu" labelledby="more-dropdown-' . $importTask->id . '" offsetY="-24" items="' . esc(json_encode([
|
||||
[
|
||||
'type' => 'link',
|
||||
'title' => lang('PodcastImport.queue.actions.cancel'),
|
||||
'uri' => route_to('podcast-imports-task-action', $importTask->id, 'cancel'),
|
||||
],
|
||||
[
|
||||
'type' => 'link',
|
||||
'title' => lang('PodcastImport.queue.actions.retry'),
|
||||
'uri' => route_to('podcast-imports-task-action', $importTask->id, 'retry'),
|
||||
],
|
||||
[
|
||||
'type' => 'separator',
|
||||
],
|
||||
[
|
||||
'type' => 'link',
|
||||
'title' => lang('PodcastImport.queue.actions.delete'),
|
||||
'uri' => route_to('podcast-imports-task-action', $importTask->id, 'delete'),
|
||||
'class' => 'font-semibold text-red-600',
|
||||
],
|
||||
])) . '" />' .
|
||||
'<DropdownMenu id="more-dropdown-' . $importTask->id . '-menu" labelledby="more-dropdown-' . $importTask->id . '" offsetY="-24" items="' . esc(json_encode($menuItems)) . '" />' .
|
||||
'</div>';
|
||||
},
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user