diff --git a/extensions/package-manager/js/src/admin/components/QueueSection.tsx b/extensions/package-manager/js/src/admin/components/QueueSection.tsx
index f013e79872..7a96575ad7 100644
--- a/extensions/package-manager/js/src/admin/components/QueueSection.tsx
+++ b/extensions/package-manager/js/src/admin/components/QueueSection.tsx
@@ -95,12 +95,15 @@ export default class QueueSection extends Component<{}> {
{
label: extractText(app.translator.trans('flarum-package-manager.admin.sections.queue.columns.status')),
content: (task) => (
-
+ <>
+
+ {['pending', 'running'].includes(task.status()) && }
+ >
),
},
70
diff --git a/extensions/package-manager/js/src/admin/components/SettingsPage.tsx b/extensions/package-manager/js/src/admin/components/SettingsPage.tsx
index 0caf823370..954dd31edd 100644
--- a/extensions/package-manager/js/src/admin/components/SettingsPage.tsx
+++ b/extensions/package-manager/js/src/admin/components/SettingsPage.tsx
@@ -48,7 +48,7 @@ export default class SettingsPage extends ExtensionPage {
items.add('control', , 8);
- if (parseInt(app.data.settings['flarum-package-manager.queue_jobs'])) {
+ if (app.data.settings['flarum-package-manager.queue_jobs'] !== '0' && app.data.settings['flarum-package-manager.queue_jobs']) {
items.add('queue', , 5);
}
@@ -56,4 +56,9 @@ export default class SettingsPage extends ExtensionPage {
return items;
}
+
+ onsaved() {
+ super.onsaved();
+ m.redraw();
+ }
}
diff --git a/extensions/package-manager/js/src/admin/utils/jumpToQueue.ts b/extensions/package-manager/js/src/admin/utils/jumpToQueue.ts
index 0c0c3a08e4..d8e9ea3418 100644
--- a/extensions/package-manager/js/src/admin/utils/jumpToQueue.ts
+++ b/extensions/package-manager/js/src/admin/utils/jumpToQueue.ts
@@ -5,9 +5,36 @@ window.jumpToQueue = jumpToQueue;
export default function jumpToQueue(): void {
app.modal.close();
+
m.route.set(app.route('extension', { id: 'flarum-package-manager' }));
+
app.packageManager.queue.load();
+
setTimeout(() => {
document.getElementById('PackageManager-queueSection')?.scrollIntoView({ block: 'nearest' });
}, 200);
+
+ pollQueue();
+}
+
+let queuePolling: any = null;
+
+export function pollQueue(): void {
+ if (queuePolling) {
+ clearInterval(queuePolling);
+ }
+
+ queuePolling = setTimeout(() => {
+ app.packageManager.queue.load();
+
+ // Check if there is a pending or running task
+ const task = app.packageManager.queue.getItems()?.find((task) => task.status() === 'pending' || task.status() === 'running');
+
+ if (task) {
+ pollQueue();
+ } else {
+ // Refresh the page
+ window.location.reload();
+ }
+ }, 6000);
}
diff --git a/extensions/package-manager/less/admin/QueueSection.less b/extensions/package-manager/less/admin/QueueSection.less
index 0d55d9338f..60059dfe99 100644
--- a/extensions/package-manager/less/admin/QueueSection.less
+++ b/extensions/package-manager/less/admin/QueueSection.less
@@ -11,6 +11,7 @@
.Label {
text-transform: uppercase;
+ margin-inline-end: 8px;
}
.Table {
diff --git a/extensions/package-manager/src/Job/ComposerCommandJob.php b/extensions/package-manager/src/Job/ComposerCommandJob.php
index be9e2140fb..b3d116ca98 100644
--- a/extensions/package-manager/src/Job/ComposerCommandJob.php
+++ b/extensions/package-manager/src/Job/ComposerCommandJob.php
@@ -37,10 +37,10 @@ public function __construct(AbstractActionCommand $command, string $phpVersion)
public function handle(Dispatcher $bus)
{
try {
- ComposerAdapter::setPhpVersion($this->phpVersion);
-
$this->command->task->start();
+ ComposerAdapter::setPhpVersion($this->phpVersion);
+
$bus->dispatch($this->command);
$this->command->task->end(true);
diff --git a/extensions/package-manager/src/Task/Task.php b/extensions/package-manager/src/Task/Task.php
index 9ce2f16d70..479d780de2 100644
--- a/extensions/package-manager/src/Task/Task.php
+++ b/extensions/package-manager/src/Task/Task.php
@@ -60,6 +60,18 @@ class Task extends AbstractModel
'finished_at' => 'datetime',
];
+ public static function boot()
+ {
+ parent::boot();
+
+ static::created(function (self $task) {
+ // auto clear tasks older than 2 weeks.
+ static::query()
+ ->where('created_at', '<', Carbon::now()->subWeeks(2))
+ ->delete();
+ });
+ }
+
public static function build(string $operation, ?string $package): self
{
$task = new static;