mirror of
https://github.com/coollabsio/coolify.git
synced 2026-08-28 10:05:25 -05:00
Use stable identities for dynamic rows and nested components so reordering does not target the wrong item. Scope storage count and volume-list refreshes, preserve PostgreSQL script identity when renaming files, use Livewire-aware destination redirects, and bump the version to 4.3.13.
70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Project\Database;
|
|
|
|
use App\Models\StandalonePostgresql;
|
|
use Exception;
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
use Livewire\Attributes\Locked;
|
|
use Livewire\Attributes\Validate;
|
|
use Livewire\Component;
|
|
|
|
class InitScript extends Component
|
|
{
|
|
use AuthorizesRequests;
|
|
|
|
#[Locked]
|
|
public StandalonePostgresql $database;
|
|
|
|
#[Locked]
|
|
public array $script;
|
|
|
|
#[Locked]
|
|
public int $index;
|
|
|
|
#[Locked]
|
|
public string $originalFilename;
|
|
|
|
#[Validate(['nullable', 'string'])]
|
|
public ?string $filename = null;
|
|
|
|
#[Validate(['nullable', 'string'])]
|
|
public ?string $content = null;
|
|
|
|
public function mount()
|
|
{
|
|
try {
|
|
$this->index = data_get($this->script, 'index');
|
|
$this->filename = data_get($this->script, 'filename');
|
|
$this->originalFilename = (string) data_get($this->script, 'filename');
|
|
$this->content = data_get($this->script, 'content');
|
|
} catch (Exception $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
|
|
public function submit()
|
|
{
|
|
try {
|
|
$this->authorize('update', $this->database);
|
|
$this->validate();
|
|
$this->script['index'] = $this->index;
|
|
$this->script['content'] = $this->content;
|
|
$this->script['filename'] = $this->filename;
|
|
$this->dispatch('save_init_script', $this->script, $this->originalFilename);
|
|
} catch (Exception $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
|
|
public function delete()
|
|
{
|
|
try {
|
|
$this->authorize('update', $this->database);
|
|
$this->dispatch('delete_init_script', $this->script);
|
|
} catch (Exception $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
}
|