diff --git a/app/Livewire/Project/Shared/HealthChecks.php b/app/Livewire/Project/Shared/HealthChecks.php index ae94f7cf2..ee11c496d 100644 --- a/app/Livewire/Project/Shared/HealthChecks.php +++ b/app/Livewire/Project/Shared/HealthChecks.php @@ -47,6 +47,24 @@ public function submit() } } + public function toggleHealthcheck() + { + try { + $this->authorize('update', $this->resource); + $wasEnabled = $this->resource->health_check_enabled; + $this->resource->health_check_enabled = !$this->resource->health_check_enabled; + $this->resource->save(); + + if ($this->resource->health_check_enabled && !$wasEnabled && $this->resource->isRunning()) { + $this->dispatch('info', 'Health check has been enabled. A restart is required to apply the new settings.'); + } else { + $this->dispatch('success', 'Health check ' . ($this->resource->health_check_enabled ? 'enabled' : 'disabled') . '.'); + } + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + public function render() { return view('livewire.project.shared.health-checks'); diff --git a/resources/views/livewire/project/shared/health-checks.blade.php b/resources/views/livewire/project/shared/health-checks.blade.php index fb9f7f3bc..ed64ff28e 100644 --- a/resources/views/livewire/project/shared/health-checks.blade.php +++ b/resources/views/livewire/project/shared/health-checks.blade.php @@ -2,19 +2,33 @@
A custom health check has been detected. If you enable this health check, it will disable the custom one and use this instead.
+