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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
refactor(settings): streamline instance admin checks and initialization of settings in Livewire components
Andras Bacsaie3e80744a724
diff --git a/app/Livewire/Settings/Advanced.php b/app/Livewire/Settings/Advanced.phpindex 0456c6291f..4425b414dc 100644--- a/app/Livewire/Settings/Advanced.php+++ b/app/Livewire/Settings/Advanced.php@@ -44,18 +44,17 @@ class Advanced extends Component{if (! isInstanceAdmin()) {return redirect()->route('dashboard');- } else {- $this->server = Server::findOrFail(0);- $this->settings = instanceSettings();- $this->custom_dns_servers = $this->settings->custom_dns_servers;- $this->allowed_ips = $this->settings->allowed_ips;- $this->do_not_track = $this->settings->do_not_track;- $this->is_registration_enabled = $this->settings->is_registration_enabled;- $this->is_dns_validation_enabled = $this->settings->is_dns_validation_enabled;- $this->is_api_enabled = $this->settings->is_api_enabled;- $this->disable_two_step_confirmation = $this->settings->disable_two_step_confirmation;- $this->is_sponsorship_popup_enabled = $this->settings->is_sponsorship_popup_enabled;}+ $this->server = Server::findOrFail(0);+ $this->settings = instanceSettings();+ $this->custom_dns_servers = $this->settings->custom_dns_servers;+ $this->allowed_ips = $this->settings->allowed_ips;+ $this->do_not_track = $this->settings->do_not_track;+ $this->is_registration_enabled = $this->settings->is_registration_enabled;+ $this->is_dns_validation_enabled = $this->settings->is_dns_validation_enabled;+ $this->is_api_enabled = $this->settings->is_api_enabled;+ $this->disable_two_step_confirmation = $this->settings->disable_two_step_confirmation;+ $this->is_sponsorship_popup_enabled = $this->settings->is_sponsorship_popup_enabled;}public function submit()diff --git a/app/Livewire/Settings/Index.php b/app/Livewire/Settings/Index.phpindex 73ee37dbf5..bce3432248 100644--- a/app/Livewire/Settings/Index.php+++ b/app/Livewire/Settings/Index.php@@ -44,17 +44,16 @@ class Index extends Component{if (! isInstanceAdmin()) {return redirect()->route('dashboard');- } else {- $this->settings = instanceSettings();- $this->server = Server::findOrFail(0);- $this->fqdn = $this->settings->fqdn;- $this->public_port_min = $this->settings->public_port_min;- $this->public_port_max = $this->settings->public_port_max;- $this->instance_name = $this->settings->instance_name;- $this->public_ipv4 = $this->settings->public_ipv4;- $this->public_ipv6 = $this->settings->public_ipv6;- $this->instance_timezone = $this->settings->instance_timezone;}+ $this->settings = instanceSettings();+ $this->server = Server::findOrFail(0);+ $this->fqdn = $this->settings->fqdn;+ $this->public_port_min = $this->settings->public_port_min;+ $this->public_port_max = $this->settings->public_port_max;+ $this->instance_name = $this->settings->instance_name;+ $this->public_ipv4 = $this->settings->public_ipv4;+ $this->public_ipv6 = $this->settings->public_ipv6;+ $this->instance_timezone = $this->settings->instance_timezone;}#[Computed]diff --git a/app/Livewire/SettingsBackup.php b/app/Livewire/SettingsBackup.phpindex bb5ed0aa8d..57cb79fcaa 100644--- a/app/Livewire/SettingsBackup.php+++ b/app/Livewire/SettingsBackup.php@@ -46,32 +46,31 @@ class SettingsBackup extends Component{if (! isInstanceAdmin()) {return redirect()->route('dashboard');- } else {- $settings = instanceSettings();- $this->server = Server::findOrFail(0);- $this->database = StandalonePostgresql::whereName('coolify-db')->first();- $s3s = S3Storage::whereTeamId(0)->get() ?? [];- if ($this->database) {- $this->uuid = $this->database->uuid;- $this->name = $this->database->name;- $this->description = $this->database->description;- $this->postgres_user = $this->database->postgres_user;- $this->postgres_password = $this->database->postgres_password;-- if ($this->database->status !== 'running') {- $this->database->status = 'running';- $this->database->save();- }- $this->backup = $this->database->scheduledBackups->first();- if ($this->backup && ! $this->server->isFunctional()) {- $this->backup->enabled = false;- $this->backup->save();- }- $this->executions = $this->backup->executions;+ }+ $settings = instanceSettings();+ $this->server = Server::findOrFail(0);+ $this->database = StandalonePostgresql::whereName('coolify-db')->first();+ $s3s = S3Storage::whereTeamId(0)->get() ?? [];+ if ($this->database) {+ $this->uuid = $this->database->uuid;+ $this->name = $this->database->name;+ $this->description = $this->database->description;+ $this->postgres_user = $this->database->postgres_user;+ $this->postgres_password = $this->database->postgres_password;++ if ($this->database->status !== 'running') {+ $this->database->status = 'running';+ $this->database->save();}- $this->settings = $settings;- $this->s3s = $s3s;+ $this->backup = $this->database->scheduledBackups->first();+ if ($this->backup && ! $this->server->isFunctional()) {+ $this->backup->enabled = false;+ $this->backup->save();+ }+ $this->executions = $this->backup->executions;}+ $this->settings = $settings;+ $this->s3s = $s3s;}public function addCoolifyDatabase()