fix: revert to original dispatch approach with unique wire:key per monitor

Root cause analysis:
- Changed from dispatch to property binding broke the activity monitor completely
- ActivityMonitor component expects activityMonitor event, not property binding
- Original approach was correct: use dispatch + event listeners

Solution:
- Revert to original dispatch('activityMonitor', $activity->id) calls
- Use @if conditionals to render only one monitor at a time (removes from DOM)
- Add unique wire:key to each monitor instance to prevent conflicts
- S3 download monitor: wire:key="s3-download-{{ $resource->uuid }}"
- Database restore monitor: wire:key="database-restore-{{ $resource->uuid }}"

This ensures:
- Activity monitors display correctly when processes start
- Only one monitor is rendered at a time (S3 download OR database restore)
- Each monitor has unique identity via wire:key
- Event listeners work as designed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-11-02 17:10:34 +01:00
parent 1271e7df2c
commit f2a017a063
3 changed files with 27 additions and 35 deletions

View File

@@ -68,8 +68,6 @@ class Import extends Component
public bool $s3DownloadInProgress = false;
public ?int $currentActivityId = null;
public function getListeners()
{
$userId = Auth::id();
@@ -271,7 +269,7 @@ EOD;
'container' => $this->container,
'serverId' => $this->server->id,
]);
$this->currentActivityId = $activity->id;
$this->dispatch('activityMonitor', $activity->id);
}
} catch (\Throwable $e) {
return handleError($e, $this);
@@ -411,8 +409,8 @@ EOD;
$this->s3DownloadedFile = $downloadPath;
$this->filename = $downloadPath;
$this->currentActivityId = $activity->id;
$this->dispatch('activityMonitor', $activity->id);
$this->dispatch('info', 'Downloading file from S3. This may take a few minutes for large backups...');
} catch (\Throwable $e) {
$this->s3DownloadInProgress = false;
@@ -494,7 +492,7 @@ EOD;
's3DownloadedFile' => $this->s3DownloadedFile,
'resourceUuid' => $this->resource->uuid,
]);
$this->currentActivityId = $activity->id;
$this->dispatch('activityMonitor', $activity->id);
}
} catch (\Throwable $e) {
return handleError($e, $this);
@@ -524,7 +522,6 @@ EOD;
// Reset S3 download state
$this->s3DownloadedFile = null;
$this->s3DownloadInProgress = false;
$this->currentActivityId = null;
$this->filename = null;
}
}