diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.php index 832a0d55cf..acc7dc8608 100644 --- a/app/Livewire/Project/Application/Previews.php +++ b/app/Livewire/Project/Application/Previews.php @@ -68,6 +68,14 @@ class Previews extends Component $this->dispatch('configurationChanged'); } + public function togglePreviewDeployments(): void + { + $this->authorize('update', $this->application); + + $this->isPreviewDeploymentsEnabled = ! $this->isPreviewDeploymentsEnabled; + $this->savePreviewSettings(); + } + private function syncDockerTags(): void { $this->previewDockerTags = []; diff --git a/resources/views/livewire/project/application/previews.blade.php b/resources/views/livewire/project/application/previews.blade.php index b85d769af3..54c8b9dfd3 100644 --- a/resources/views/livewire/project/application/previews.blade.php +++ b/resources/views/livewire/project/application/previews.blade.php @@ -5,13 +5,22 @@ @endphp -
- + + @can('update', $application) + @if ($isPreviewDeploymentsEnabled) + + Disable preview deployments + + @else + + Enable preview deployments + + @endif + @endcan + + +
call('togglePreviewDeployments') + ->assertSee('Disable preview deployments') + ->assertSet('isPreviewDeploymentsEnabled', true); + + expect($this->application->fresh()->settings->is_preview_deployments_enabled)->toBeTrue(); +}); + it('does not show git preview settings for non-git applications', function (string $buildPack, ?string $dockerfile) { $this->application->update(['build_pack' => $buildPack, 'dockerfile' => $dockerfile]);