coolify/app/Livewire/Project/Application/Configuration.php

76 lines
2.3 KiB
PHP
Raw Normal View History

<?php
2023-12-07 18:06:32 +00:00
namespace App\Livewire\Project\Application;
use App\Models\Application;
use Livewire\Component;
class Configuration extends Component
{
2024-12-16 13:11:45 +00:00
public $currentRoute;
public Application $application;
2024-06-10 20:43:34 +00:00
2024-12-16 13:11:45 +00:00
public $project;
public $environment;
public $servers;
2024-06-10 20:43:34 +00:00
protected $listeners = [
'buildPackUpdated' => '$refresh',
'refresh' => '$refresh',
];
public function mount()
{
$this->syncCurrentRoute();
2024-12-03 13:02:12 +00:00
$project = currentTeam()
->projects()
2026-04-23 09:23:31 +00:00
->select('id', 'uuid', 'name', 'team_id')
2024-12-03 13:02:12 +00:00
->where('uuid', request()->route('project_uuid'))
->firstOrFail();
$environment = $project->environments()
->select('id', 'uuid', 'name', 'project_id')
->where('uuid', request()->route('environment_uuid'))
2024-12-03 13:02:12 +00:00
->firstOrFail();
$application = $environment->applications()
->with(['destination.server', 'environment.project'])
2024-11-27 07:07:54 +00:00
->where('uuid', request()->route('application_uuid'))
->firstOrFail();
// Parent page already resolved these; keep them on the model for nested components.
$application->setRelation('environment', $environment);
$environment->setRelation('project', $project);
2024-12-16 13:11:45 +00:00
$this->project = $project;
$this->environment = $environment;
$this->application = $application;
if ($this->application->build_pack === 'dockercompose' && $this->currentRoute === 'project.application.healthcheck') {
return redirect()->route('project.application.configuration', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'application_uuid' => $application->uuid]);
}
}
2024-06-10 20:43:34 +00:00
/**
* Keep sidebar active state in sync on full-page navigations.
* Ignore Livewire update requests so poll/refresh does not clear it.
*/
protected function syncCurrentRoute(): void
{
$routeName = request()->route()?->getName();
if (is_string($routeName) && str_starts_with($routeName, 'project.application.')) {
$this->currentRoute = $routeName;
}
}
public function render()
{
$this->syncCurrentRoute();
return view('livewire.project.application.configuration');
}
}