2025-09-30 09:43:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire;
|
|
|
|
|
|
|
|
|
|
use App\Models\ApplicationDeploymentQueue;
|
|
|
|
|
use App\Models\Server;
|
|
|
|
|
use Livewire\Attributes\Computed;
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class DeploymentsIndicator extends Component
|
|
|
|
|
{
|
|
|
|
|
public bool $expanded = false;
|
|
|
|
|
|
|
|
|
|
#[Computed]
|
|
|
|
|
public function deployments()
|
|
|
|
|
{
|
2025-12-08 12:39:33 +00:00
|
|
|
$servers = Server::ownedByCurrentTeamCached();
|
2025-09-30 09:43:30 +00:00
|
|
|
|
2025-10-04 16:02:20 +00:00
|
|
|
return ApplicationDeploymentQueue::with(['application.environment.project'])
|
|
|
|
|
->whereIn('status', ['in_progress', 'queued'])
|
2025-09-30 09:43:30 +00:00
|
|
|
->whereIn('server_id', $servers->pluck('id'))
|
2025-10-01 18:10:22 +00:00
|
|
|
->orderBy('id')
|
2025-09-30 09:43:30 +00:00
|
|
|
->get([
|
|
|
|
|
'id',
|
|
|
|
|
'application_id',
|
|
|
|
|
'application_name',
|
|
|
|
|
'deployment_url',
|
|
|
|
|
'pull_request_id',
|
|
|
|
|
'server_name',
|
|
|
|
|
'server_id',
|
|
|
|
|
'status',
|
2025-10-01 18:10:22 +00:00
|
|
|
]);
|
2025-09-30 09:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Computed]
|
|
|
|
|
public function deploymentCount()
|
|
|
|
|
{
|
|
|
|
|
return $this->deployments->count();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 08:39:56 +00:00
|
|
|
#[Computed]
|
|
|
|
|
public function shouldReduceOpacity(): bool
|
|
|
|
|
{
|
|
|
|
|
return request()->routeIs('project.application.deployment.*');
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-30 09:43:30 +00:00
|
|
|
public function toggleExpanded()
|
|
|
|
|
{
|
|
|
|
|
$this->expanded = ! $this->expanded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
|
{
|
|
|
|
|
return view('livewire.deployments-indicator');
|
|
|
|
|
}
|
|
|
|
|
}
|