Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: db public port instant save and simplify if condition (#7883)

🏔️ Peakcaca421e2e74
diff --git a/app/Livewire/Project/Database/Clickhouse/General.php b/app/Livewire/Project/Database/Clickhouse/General.php
index c4a7983b8f..7ad453fd58 100644
--- a/app/Livewire/Project/Database/Clickhouse/General.php
+++ b/app/Livewire/Project/Database/Clickhouse/General.php
@@ -168,21 +168,20 @@ class General extends Component
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 9052a4749e..4e325b9eef 100644
--- a/app/Livewire/Project/Database/Dragonfly/General.php
+++ b/app/Livewire/Project/Database/Dragonfly/General.php
@@ -178,21 +178,20 @@ class General extends Component
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 6d21988e7b..f02aa6674b 100644
--- a/app/Livewire/Project/Database/Keydb/General.php
+++ b/app/Livewire/Project/Database/Keydb/General.php
@@ -185,21 +185,20 @@ class General extends Component
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 3bffc0bef7..74658e2a4e 100644
--- a/app/Livewire/Project/Database/Mariadb/General.php
+++ b/app/Livewire/Project/Database/Mariadb/General.php
@@ -232,22 +232,23 @@ class General extends Component
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 5c0465c22f..9f34b73d5b 100644
--- a/app/Livewire/Project/Database/Mongodb/General.php
+++ b/app/Livewire/Project/Database/Mongodb/General.php
@@ -235,22 +235,23 @@ class General extends Component
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 5ac34299c2..86b1092514 100644
--- a/app/Livewire/Project/Database/Mysql/General.php
+++ b/app/Livewire/Project/Database/Mysql/General.php
@@ -239,22 +239,23 @@ class General extends Component
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 84e34c145c..e246743151 100644
--- a/app/Livewire/Project/Database/Postgresql/General.php
+++ b/app/Livewire/Project/Database/Postgresql/General.php
@@ -286,22 +286,23 @@ class General extends Component
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 f96f5d30ed..08bcdc3431 100644
--- a/app/Livewire/Project/Database/Redis/General.php
+++ b/app/Livewire/Project/Database/Redis/General.php
@@ -225,21 +225,20 @@ class General extends Component
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);