mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-14 04:15:55 +00:00
fix(livewire): preserve wire:dirty across DB status broadcasts
The earlier refreshStatus fix kept user-typed values intact but Livewire still absorbed deferred wire:model values into the snapshot on every broadcast- triggered roundtrip, clearing the unsaved-changes indicator and making the form look auto-saved. Move all status-derived display (DB URLs, SSL toggle/mode, cert expiry) out of each DB General form into a sibling StatusInfo Livewire component, so the form never roundtrips on broadcasts. Shared scaffolding lives in App\Traits\HasDatabaseStatusInfo plus an x-database- status-info Blade component, leaving each per-DB StatusInfo class as a ~20-50 line declaration of label, SSL mode options, and SSL save hooks. Parents dispatch databaseUpdated from save methods so the sibling refreshes after writes. Tests cover the architecture (no DB form subscribes to status broadcasts) and the sibling's refresh-on-status-change behavior.
This commit is contained in:
1 parent
9aee01d5a0
commit
e7e65831a7
27 files changed
+603
-1308
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Project\Database\Postgresql;
|
||||
|
||||
use App\Models\StandalonePostgresql;
|
||||
use App\Traits\HasDatabaseStatusInfo;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Livewire\Component;
|
||||
|
||||
class StatusInfo extends Component
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
use HasDatabaseStatusInfo;
|
||||
|
||||
public StandalonePostgresql $database;
|
||||
|
||||
protected function databaseLabel(): string
|
||||
{
|
||||
return 'Postgres';
|
||||
}
|
||||
|
||||
protected function sslModeOptions(): array
|
||||
{
|
||||
return [
|
||||
'allow' => ['title' => 'Allow insecure connections', 'label' => 'allow (insecure)'],
|
||||
'prefer' => ['title' => 'Prefer secure connections', 'label' => 'prefer (secure)'],
|
||||
'require' => ['title' => 'Require secure connections', 'label' => 'require (secure)'],
|
||||
'verify-ca' => ['title' => 'Verify CA certificate', 'label' => 'verify-ca (secure)'],
|
||||
'verify-full' => ['title' => 'Verify full certificate', 'label' => 'verify-full (secure)'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function sslModeHelper(): string
|
||||
{
|
||||
return 'Choose the SSL verification mode for PostgreSQL connections';
|
||||
}
|
||||
|
||||
protected function afterRefresh(): void
|
||||
{
|
||||
$this->sslMode = $this->database->ssl_mode;
|
||||
}
|
||||
|
||||
protected function applyExtraSslAttributes(): void
|
||||
{
|
||||
$this->database->ssl_mode = $this->sslMode;
|
||||
}
|
||||
|
||||
public function updatedSslMode(): void
|
||||
{
|
||||
$this->instantSaveSSL();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user