mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-20 05:20:56 +00:00
feat: add database transactions and component-level authorization to shared variables
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Livewire\SharedVariables\Project;
|
||||
|
||||
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 @@ class Show extends Component
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user