From caca421e2e74ae32a9d836def7bfa1e842a912c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8F=94=EF=B8=8F=20Peak?= <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 6 Jan 2026 13:44:46 +0100 Subject: [PATCH] fix: db public port instant save and simplify if condition (#7883) --- .../Project/Database/Clickhouse/General.php | 15 +++++++-------- .../Project/Database/Dragonfly/General.php | 15 +++++++-------- app/Livewire/Project/Database/Keydb/General.php | 15 +++++++-------- app/Livewire/Project/Database/Mariadb/General.php | 15 ++++++++------- app/Livewire/Project/Database/Mongodb/General.php | 15 ++++++++------- app/Livewire/Project/Database/Mysql/General.php | 15 ++++++++------- .../Project/Database/Postgresql/General.php | 15 ++++++++------- app/Livewire/Project/Database/Redis/General.php | 15 +++++++-------- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/app/Livewire/Project/Database/Clickhouse/General.php b/app/Livewire/Project/Database/Clickhouse/General.php index c4a7983b8..7ad453fd5 100644 --- a/app/Livewire/Project/Database/Clickhouse/General.php +++ b/app/Livewire/Project/Database/Clickhouse/General.php @@ -168,21 +168,20 @@ public function instantSave() return; } - if ($this->isPublic) { - if (! str($this->database->status)->startsWith('running')) { - $this->dispatch('error', 'Database must be started to be publicly accessible.'); - $this->isPublic = false; + if ($this->isPublic && ! str($this->database->status)->startsWith('running')) { + $this->dispatch('error', 'Database must be started to be publicly accessible.'); + $this->isPublic = false; - return; - } + return; + } + $this->syncData(true); + if ($this->isPublic) { StartDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is no longer publicly accessible.'); } - $this->dbUrlPublic = $this->database->external_db_url; - $this->syncData(true); } catch (\Throwable $e) { $this->isPublic = ! $this->isPublic; $this->syncData(true); diff --git a/app/Livewire/Project/Database/Dragonfly/General.php b/app/Livewire/Project/Database/Dragonfly/General.php index 9052a4749..4e325b9ee 100644 --- a/app/Livewire/Project/Database/Dragonfly/General.php +++ b/app/Livewire/Project/Database/Dragonfly/General.php @@ -178,21 +178,20 @@ public function instantSave() return; } - if ($this->isPublic) { - if (! str($this->database->status)->startsWith('running')) { - $this->dispatch('error', 'Database must be started to be publicly accessible.'); - $this->isPublic = false; + if ($this->isPublic && ! str($this->database->status)->startsWith('running')) { + $this->dispatch('error', 'Database must be started to be publicly accessible.'); + $this->isPublic = false; - return; - } + return; + } + $this->syncData(true); + if ($this->isPublic) { StartDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is no longer publicly accessible.'); } - $this->dbUrlPublic = $this->database->external_db_url; - $this->syncData(true); } catch (\Throwable $e) { $this->isPublic = ! $this->isPublic; $this->syncData(true); diff --git a/app/Livewire/Project/Database/Keydb/General.php b/app/Livewire/Project/Database/Keydb/General.php index 6d21988e7..f02aa6674 100644 --- a/app/Livewire/Project/Database/Keydb/General.php +++ b/app/Livewire/Project/Database/Keydb/General.php @@ -185,21 +185,20 @@ public function instantSave() return; } - if ($this->isPublic) { - if (! str($this->database->status)->startsWith('running')) { - $this->dispatch('error', 'Database must be started to be publicly accessible.'); - $this->isPublic = false; + if ($this->isPublic && ! str($this->database->status)->startsWith('running')) { + $this->dispatch('error', 'Database must be started to be publicly accessible.'); + $this->isPublic = false; - return; - } + return; + } + $this->syncData(true); + if ($this->isPublic) { StartDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is no longer publicly accessible.'); } - $this->dbUrlPublic = $this->database->external_db_url; - $this->syncData(true); } catch (\Throwable $e) { $this->isPublic = ! $this->isPublic; $this->syncData(true); diff --git a/app/Livewire/Project/Database/Mariadb/General.php b/app/Livewire/Project/Database/Mariadb/General.php index 3bffc0bef..74658e2a4 100644 --- a/app/Livewire/Project/Database/Mariadb/General.php +++ b/app/Livewire/Project/Database/Mariadb/General.php @@ -232,22 +232,23 @@ public function instantSave() return; } - if ($this->isPublic) { - if (! str($this->database->status)->startsWith('running')) { - $this->dispatch('error', 'Database must be started to be publicly accessible.'); - $this->isPublic = false; + if ($this->isPublic && ! str($this->database->status)->startsWith('running')) { + $this->dispatch('error', 'Database must be started to be publicly accessible.'); + $this->isPublic = false; - return; - } + return; + } + $this->syncData(true); + if ($this->isPublic) { StartDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is no longer publicly accessible.'); } - $this->syncData(true); } catch (\Throwable $e) { $this->isPublic = ! $this->isPublic; + $this->syncData(true); return handleError($e, $this); } diff --git a/app/Livewire/Project/Database/Mongodb/General.php b/app/Livewire/Project/Database/Mongodb/General.php index 5c0465c22..9f34b73d5 100644 --- a/app/Livewire/Project/Database/Mongodb/General.php +++ b/app/Livewire/Project/Database/Mongodb/General.php @@ -235,22 +235,23 @@ public function instantSave() return; } - if ($this->isPublic) { - if (! str($this->database->status)->startsWith('running')) { - $this->dispatch('error', 'Database must be started to be publicly accessible.'); - $this->isPublic = false; + if ($this->isPublic && ! str($this->database->status)->startsWith('running')) { + $this->dispatch('error', 'Database must be started to be publicly accessible.'); + $this->isPublic = false; - return; - } + return; + } + $this->syncData(true); + if ($this->isPublic) { StartDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is no longer publicly accessible.'); } - $this->syncData(true); } catch (\Throwable $e) { $this->isPublic = ! $this->isPublic; + $this->syncData(true); return handleError($e, $this); } diff --git a/app/Livewire/Project/Database/Mysql/General.php b/app/Livewire/Project/Database/Mysql/General.php index 5ac34299c..86b109251 100644 --- a/app/Livewire/Project/Database/Mysql/General.php +++ b/app/Livewire/Project/Database/Mysql/General.php @@ -239,22 +239,23 @@ public function instantSave() return; } - if ($this->isPublic) { - if (! str($this->database->status)->startsWith('running')) { - $this->dispatch('error', 'Database must be started to be publicly accessible.'); - $this->isPublic = false; + if ($this->isPublic && ! str($this->database->status)->startsWith('running')) { + $this->dispatch('error', 'Database must be started to be publicly accessible.'); + $this->isPublic = false; - return; - } + return; + } + $this->syncData(true); + if ($this->isPublic) { StartDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is no longer publicly accessible.'); } - $this->syncData(true); } catch (\Throwable $e) { $this->isPublic = ! $this->isPublic; + $this->syncData(true); return handleError($e, $this); } diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.php index 84e34c145..e24674315 100644 --- a/app/Livewire/Project/Database/Postgresql/General.php +++ b/app/Livewire/Project/Database/Postgresql/General.php @@ -286,22 +286,23 @@ public function instantSave() return; } - if ($this->isPublic) { - if (! str($this->database->status)->startsWith('running')) { - $this->dispatch('error', 'Database must be started to be publicly accessible.'); - $this->isPublic = false; + if ($this->isPublic && ! str($this->database->status)->startsWith('running')) { + $this->dispatch('error', 'Database must be started to be publicly accessible.'); + $this->isPublic = false; - return; - } + return; + } + $this->syncData(true); + if ($this->isPublic) { StartDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is no longer publicly accessible.'); } - $this->syncData(true); } catch (\Throwable $e) { $this->isPublic = ! $this->isPublic; + $this->syncData(true); return handleError($e, $this); } diff --git a/app/Livewire/Project/Database/Redis/General.php b/app/Livewire/Project/Database/Redis/General.php index f96f5d30e..08bcdc343 100644 --- a/app/Livewire/Project/Database/Redis/General.php +++ b/app/Livewire/Project/Database/Redis/General.php @@ -225,21 +225,20 @@ public function instantSave() return; } - if ($this->isPublic) { - if (! str($this->database->status)->startsWith('running')) { - $this->dispatch('error', 'Database must be started to be publicly accessible.'); - $this->isPublic = false; + if ($this->isPublic && ! str($this->database->status)->startsWith('running')) { + $this->dispatch('error', 'Database must be started to be publicly accessible.'); + $this->isPublic = false; - return; - } + return; + } + $this->syncData(true); + if ($this->isPublic) { StartDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); $this->dispatch('success', 'Database is no longer publicly accessible.'); } - $this->dbUrlPublic = $this->database->external_db_url; - $this->syncData(true); } catch (\Throwable $e) { $this->isPublic = ! $this->isPublic; $this->syncData(true);