2023-09-30 13:08:40 +00:00
|
|
|
<?php
|
|
|
|
|
2024-03-21 11:44:32 +00:00
|
|
|
namespace App\Livewire\Project\Service;
|
2023-09-30 13:08:40 +00:00
|
|
|
|
2023-12-06 13:57:03 +00:00
|
|
|
use App\Models\Service;
|
2024-03-21 11:44:32 +00:00
|
|
|
use Livewire\Component;
|
2023-09-30 13:08:40 +00:00
|
|
|
|
2024-03-21 11:44:32 +00:00
|
|
|
class EditCompose extends Component
|
2023-09-30 13:08:40 +00:00
|
|
|
{
|
2023-12-06 13:57:03 +00:00
|
|
|
public Service $service;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-06 14:50:13 +00:00
|
|
|
public $serviceId;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-06 13:57:03 +00:00
|
|
|
protected $rules = [
|
|
|
|
'service.docker_compose_raw' => 'required',
|
|
|
|
'service.docker_compose' => 'required',
|
2024-05-15 15:52:14 +00:00
|
|
|
'service.is_container_label_escape_enabled' => 'required',
|
2023-12-06 13:57:03 +00:00
|
|
|
];
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-04-16 08:44:23 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
2023-12-06 14:50:13 +00:00
|
|
|
$this->service = Service::find($this->serviceId);
|
|
|
|
}
|
2024-03-21 11:44:32 +00:00
|
|
|
|
2024-04-16 08:44:23 +00:00
|
|
|
public function saveEditedCompose()
|
|
|
|
{
|
2024-06-10 20:43:34 +00:00
|
|
|
$this->dispatch('info', 'Saving new docker compose...');
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('saveCompose', $this->service->docker_compose_raw);
|
2024-03-21 11:44:32 +00:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-05-15 15:52:14 +00:00
|
|
|
public function instantSave()
|
|
|
|
{
|
|
|
|
$this->validate([
|
|
|
|
'service.is_container_label_escape_enabled' => 'required',
|
|
|
|
]);
|
|
|
|
$this->service->save(['is_container_label_escape_enabled' => $this->service->is_container_label_escape_enabled]);
|
2024-06-10 20:43:34 +00:00
|
|
|
$this->dispatch('success', 'Service updated successfully');
|
2024-05-15 15:52:14 +00:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-03-21 11:44:32 +00:00
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.project.service.edit-compose');
|
2023-09-30 13:08:40 +00:00
|
|
|
}
|
|
|
|
}
|