diff --git a/app/Livewire/SharedVariables/Environment/Show.php b/app/Livewire/SharedVariables/Environment/Show.php index 6c8342c41..6b1d35d14 100644 --- a/app/Livewire/SharedVariables/Environment/Show.php +++ b/app/Livewire/SharedVariables/Environment/Show.php @@ -5,6 +5,7 @@ use App\Models\Application; use App\Models\Project; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; +use Illuminate\Support\Facades\DB; use Livewire\Component; class Show extends Component @@ -98,23 +99,26 @@ public function submit() private function handleBulkSubmit() { $variables = parseEnvFormatToArray($this->variables); - $changesMade = false; - // Delete removed variables - $deletedCount = $this->deleteRemovedVariables($variables); - if ($deletedCount > 0) { - $changesMade = true; - } + DB::transaction(function () use ($variables) { + $changesMade = false; - // Update or create variables - $updatedCount = $this->updateOrCreateVariables($variables); - if ($updatedCount > 0) { - $changesMade = true; - } + // Delete removed variables + $deletedCount = $this->deleteRemovedVariables($variables); + if ($deletedCount > 0) { + $changesMade = true; + } - if ($changesMade) { - $this->dispatch('success', 'Environment variables updated.'); - } + // Update or create variables + $updatedCount = $this->updateOrCreateVariables($variables); + if ($updatedCount > 0) { + $changesMade = true; + } + + if ($changesMade) { + $this->dispatch('success', 'Environment variables updated.'); + } + }); } private function deleteRemovedVariables($variables) diff --git a/app/Livewire/SharedVariables/Project/Show.php b/app/Livewire/SharedVariables/Project/Show.php index a3abe5df2..93ead33a3 100644 --- a/app/Livewire/SharedVariables/Project/Show.php +++ b/app/Livewire/SharedVariables/Project/Show.php @@ -4,6 +4,7 @@ use App\Models\Project; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; +use Illuminate\Support\Facades\DB; use Livewire\Component; class Show extends Component @@ -95,23 +96,26 @@ public function submit() private function handleBulkSubmit() { $variables = parseEnvFormatToArray($this->variables); - $changesMade = false; - // Delete removed variables - $deletedCount = $this->deleteRemovedVariables($variables); - if ($deletedCount > 0) { - $changesMade = true; - } + DB::transaction(function () use ($variables) { + $changesMade = false; - // Update or create variables - $updatedCount = $this->updateOrCreateVariables($variables); - if ($updatedCount > 0) { - $changesMade = true; - } + // Delete removed variables + $deletedCount = $this->deleteRemovedVariables($variables); + if ($deletedCount > 0) { + $changesMade = true; + } - if ($changesMade) { - $this->dispatch('success', 'Environment variables updated.'); - } + // Update or create variables + $updatedCount = $this->updateOrCreateVariables($variables); + if ($updatedCount > 0) { + $changesMade = true; + } + + if ($changesMade) { + $this->dispatch('success', 'Environment variables updated.'); + } + }); } private function deleteRemovedVariables($variables) diff --git a/app/Livewire/SharedVariables/Team/Index.php b/app/Livewire/SharedVariables/Team/Index.php index 6311d9a87..bd23bca82 100644 --- a/app/Livewire/SharedVariables/Team/Index.php +++ b/app/Livewire/SharedVariables/Team/Index.php @@ -4,6 +4,7 @@ use App\Models\Team; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; +use Illuminate\Support\Facades\DB; use Livewire\Component; class Index extends Component @@ -89,23 +90,26 @@ public function submit() private function handleBulkSubmit() { $variables = parseEnvFormatToArray($this->variables); - $changesMade = false; - // Delete removed variables - $deletedCount = $this->deleteRemovedVariables($variables); - if ($deletedCount > 0) { - $changesMade = true; - } + DB::transaction(function () use ($variables) { + $changesMade = false; - // Update or create variables - $updatedCount = $this->updateOrCreateVariables($variables); - if ($updatedCount > 0) { - $changesMade = true; - } + // Delete removed variables + $deletedCount = $this->deleteRemovedVariables($variables); + if ($deletedCount > 0) { + $changesMade = true; + } - if ($changesMade) { - $this->dispatch('success', 'Environment variables updated.'); - } + // Update or create variables + $updatedCount = $this->updateOrCreateVariables($variables); + if ($updatedCount > 0) { + $changesMade = true; + } + + if ($changesMade) { + $this->dispatch('success', 'Environment variables updated.'); + } + }); } private function deleteRemovedVariables($variables) diff --git a/resources/views/livewire/shared-variables/environment/show.blade.php b/resources/views/livewire/shared-variables/environment/show.blade.php index 02cc07b28..fde2d0ae8 100644 --- a/resources/views/livewire/shared-variables/environment/show.blade.php +++ b/resources/views/livewire/shared-variables/environment/show.blade.php @@ -9,9 +9,7 @@ @endcan - @can('update', $environment) - {{ $view === 'normal' ? 'Developer view' : 'Normal view' }} - @endcan + {{ $view === 'normal' ? 'Developer view' : 'Normal view' }}
You can use these variables anywhere with @{{ environment.VARIABLENAME }}@{{ environment.VARIABLENAME }} @else
- @can('update', $environment) - - Save All Environment Variables - @else - - @endcan + + Save All Environment Variables
@endif
diff --git a/resources/views/livewire/shared-variables/project/show.blade.php b/resources/views/livewire/shared-variables/project/show.blade.php index 99d95059a..f89ad9ce7 100644 --- a/resources/views/livewire/shared-variables/project/show.blade.php +++ b/resources/views/livewire/shared-variables/project/show.blade.php @@ -9,9 +9,7 @@ @endcan - @can('update', $project) - {{ $view === 'normal' ? 'Developer view' : 'Normal view' }} - @endcan + {{ $view === 'normal' ? 'Developer view' : 'Normal view' }}
You can use these variables anywhere with
@@ -30,14 +28,9 @@
@else
- @can('update', $project) - - Save All Environment Variables - @else - - @endcan + + Save All Environment Variables
@endif diff --git a/resources/views/livewire/shared-variables/team/index.blade.php b/resources/views/livewire/shared-variables/team/index.blade.php index 44399dcda..fcfca35fb 100644 --- a/resources/views/livewire/shared-variables/team/index.blade.php +++ b/resources/views/livewire/shared-variables/team/index.blade.php @@ -9,9 +9,7 @@ @endcan - @can('update', $team) - {{ $view === 'normal' ? 'Developer view' : 'Normal view' }} - @endcan + {{ $view === 'normal' ? 'Developer view' : 'Normal view' }}
You can use these variables anywhere with @{{ team.VARIABLENAME }} @{{ team.VARIABLENAME }} @else
- @can('update', $team) - - Save All Environment Variables - @else - - @endcan + + Save All Environment Variables
@endif