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(env): shared variables can not be updated

peaklabs-dev9f3c6b4b7634
diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
index 4b66bfdcb6..3a7d0faa57 100644
--- a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
+++ b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
@@ -77,18 +77,28 @@ class Show extends Component
public function syncData(bool $toModel = false)
{
if ($toModel) {
- $this->validate();
+ if ($this->isSharedVariable) {
+ $this->validate([
+ 'key' => 'required|string',
+ 'value' => 'nullable',
+ 'is_multiline' => 'required|boolean',
+ 'is_literal' => 'required|boolean',
+ 'is_shown_once' => 'required|boolean',
+ 'real_value' => 'nullable',
+ ]);
+ } else {
+ $this->validate();
+ $this->env->is_build_time = $this->is_build_time;
+ $this->env->is_required = $this->is_required;
+ $this->env->is_shared = $this->is_shared;
+ }
$this->env->key = $this->key;
$this->env->value = $this->value;
- $this->env->is_build_time = $this->is_build_time;
$this->env->is_multiline = $this->is_multiline;
$this->env->is_literal = $this->is_literal;
$this->env->is_shown_once = $this->is_shown_once;
- $this->env->is_required = $this->is_required;
- $this->env->is_shared = $this->is_shared;
$this->env->save();
} else {
-
$this->key = $this->env->key;
$this->value = $this->env->value;
$this->is_build_time = $this->env->is_build_time ?? false;
@@ -141,30 +151,15 @@ class Show extends Component
public function submit()
{
try {
- if ($this->isSharedVariable) {
- $this->validate([
- 'key' => 'required|string',
- 'value' => 'nullable',
- 'is_shown_once' => 'required|boolean',
- ]);
- } else {
- $this->validate();
- }
-
if (! $this->isSharedVariable && $this->is_required && str($this->value)->isEmpty()) {
$oldValue = $this->env->getOriginal('value');
$this->value = $oldValue;
- $this->dispatch('error', 'Required environment variable cannot be empty.');
+ $this->dispatch('error', 'Required environment variables cannot be empty.');
return;
}
$this->serialize();
-
- if ($this->isSharedVariable) {
- unset($this->is_required);
- }
-
$this->syncData(true);
$this->dispatch('success', 'Environment variable updated.');
$this->dispatch('envsUpdated');