diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php index 9cd309885..70b3b5db6 100644 --- a/app/Livewire/Project/Service/Navbar.php +++ b/app/Livewire/Project/Service/Navbar.php @@ -108,6 +108,21 @@ class Navbar extends Component return; } + StopService::run(service: $this->service, dockerCleanup: false); + $this->service->parse(); + $this->dispatch('imagePulled'); + $activity = StartService::run($this->service); + $this->dispatch('activityMonitor', $activity->id); + } + + public function pullAndRestartEvent() + { + $this->checkDeployments(); + if ($this->isDeploymentProgress) { + $this->dispatch('error', 'There is a deployment in progress.'); + + return; + } PullImage::run($this->service); StopService::run(service: $this->service, dockerCleanup: false); $this->service->parse(); diff --git a/resources/views/livewire/project/service/navbar.blade.php b/resources/views/livewire/project/service/navbar.blade.php index 79541fd49..6ff297c61 100644 --- a/resources/views/livewire/project/service/navbar.blade.php +++ b/resources/views/livewire/project/service/navbar.blade.php @@ -22,7 +22,25 @@
@if (str($service->status())->contains('running')) - + Restart + @@ -135,9 +153,13 @@ $wire.$call('start'); }); $wire.$on('restartEvent', () => { - $wire.$dispatch('info', 'Pulling new images.'); + $wire.$dispatch('info', 'Service restart in progress.'); $wire.$call('restart'); }); + $wire.$on('pullAndRestartEvent', () => { + $wire.$dispatch('info', 'Pulling new images.'); + $wire.$call('pullAndRestartEvent'); + }); $wire.on('imagePulled', () => { window.dispatchEvent(new CustomEvent('startservice')); $wire.$dispatch('info', 'Restarting service.');