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
fix(env-vars): show single empty state for searches
Andras Bacsaid7524a743d3a
diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/All.php b/app/Livewire/Project/Shared/EnvironmentVariable/All.phpindex 65f0bd4378..2a1a47b4dc 100644--- a/app/Livewire/Project/Shared/EnvironmentVariable/All.php+++ b/app/Livewire/Project/Shared/EnvironmentVariable/All.php@@ -45,6 +45,7 @@ class All extends Componentunset($this->environmentVariablesPreview);unset($this->hardcodedEnvironmentVariables);unset($this->hardcodedEnvironmentVariablesPreview);+ unset($this->hasEnvironmentVariables);}public function mount()@@ -111,6 +112,19 @@ class All extends Componentreturn trim($this->search);}+ public function getHasEnvironmentVariablesProperty(): bool+ {+ return $this->environmentVariables->isNotEmpty() ||+ $this->environmentVariablesPreview->isNotEmpty() ||+ $this->hardcodedEnvironmentVariables->isNotEmpty() ||+ $this->hardcodedEnvironmentVariablesPreview->isNotEmpty();+ }++ public function getIsSearchActiveProperty(): bool+ {+ return $this->searchTerm() !== '';+ }+public function getHardcodedEnvironmentVariablesProperty(){return $this->getHardcodedVariables(false);@@ -313,6 +327,7 @@ class All extends Componentunset($this->environmentVariablesPreview);unset($this->hardcodedEnvironmentVariables);unset($this->hardcodedEnvironmentVariablesPreview);+ unset($this->hasEnvironmentVariables);$this->dispatch('success', 'Environment variable added.');}@@ -446,6 +461,7 @@ class All extends Componentunset($this->environmentVariablesPreview);unset($this->hardcodedEnvironmentVariables);unset($this->hardcodedEnvironmentVariablesPreview);+ unset($this->hasEnvironmentVariables);$this->getDevView();}}diff --git a/resources/views/livewire/project/shared/environment-variable/all.blade.php b/resources/views/livewire/project/shared/environment-variable/all.blade.phpindex 77ac92ffee..f49765286e 100644--- a/resources/views/livewire/project/shared/environment-variable/all.blade.php+++ b/resources/views/livewire/project/shared/environment-variable/all.blade.php@@ -43,64 +43,66 @@@endif</div>@if ($view === 'normal')- <div class="flex flex-col md:flex-row gap-2 justify-between md:items-center">- <div>- <h3>Production Environment Variables</h3>- <div class="subtitle">Environment (secrets) variables for Production.</div>- </div>- <div class="w-full md:w-96">- <div class="relative">- <input type="search" placeholder="Search" aria-label="Search environment variables"- wire:model.live.debounce.300ms="search" class="w-full input pl-10" />- <div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">- <div class="relative w-4 h-4">- <svg wire:loading.remove wire:target="search" aria-hidden="true"- class="absolute inset-0 w-4 h-4 dark:text-neutral-400" fill="none"- stroke="currentColor" viewBox="0 0 24 24">- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"- d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />- </svg>- <svg wire:loading wire:target="search" aria-hidden="true"- class="absolute inset-0 w-4 h-4 text-coollabs dark:text-warning animate-spin"- fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">- <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor"- stroke-width="4" />- <path class="opacity-75" fill="currentColor"- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />- </svg>- </div>+ <div class="w-full md:w-96">+ <div class="relative">+ <input type="search" placeholder="Search" aria-label="Search environment variables"+ wire:model.live.debounce.300ms="search" class="w-full input pl-10" />+ <div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">+ <div class="relative w-4 h-4">+ <svg wire:loading.remove wire:target="search" aria-hidden="true"+ class="absolute inset-0 w-4 h-4 dark:text-neutral-400" fill="none" stroke="currentColor"+ viewBox="0 0 24 24">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"+ d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />+ </svg>+ <svg wire:loading wire:target="search" aria-hidden="true"+ class="absolute inset-0 w-4 h-4 text-coollabs dark:text-warning animate-spin" fill="none"+ viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor"+ stroke-width="4" />+ <path class="opacity-75" fill="currentColor"+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />+ </svg></div></div></div></div>- @forelse ($this->environmentVariables as $env)- <livewire:project.shared.environment-variable.show wire:key="environment-{{ $env->id }}" :env="$env"- :type="$resource->type()" />- @empty+ @if ($this->isSearchActive && ! $this->hasEnvironmentVariables)<div>No environment variables found.</div>- @endforelse- @if (($resource->type() === 'service' || $resource?->build_pack === 'dockercompose') && $this->hardcodedEnvironmentVariables->isNotEmpty())- @foreach ($this->hardcodedEnvironmentVariables as $index => $env)- <livewire:project.shared.environment-variable.show-hardcoded- wire:key="hardcoded-prod-{{ $env['key'] }}-{{ $env['service_name'] ?? 'default' }}-{{ $index }}" :env="$env" />- @endforeach- @endif- @if ($resource->type() === 'application' && $resource->environment_variables_preview->count() > 0 && $showPreview)+ @else<div>- <h3>Preview Deployments Environment Variables</h3>- <div>Environment (secrets) variables for Preview Deployments.</div>+ <h3>Production Environment Variables</h3>+ <div>Environment (secrets) variables for Production.</div></div>- @foreach ($this->environmentVariablesPreview as $env)+ @forelse ($this->environmentVariables as $env)<livewire:project.shared.environment-variable.show wire:key="environment-{{ $env->id }}" :env="$env":type="$resource->type()" />- @endforeach- @if (($resource->type() === 'service' || $resource?->build_pack === 'dockercompose') && $this->hardcodedEnvironmentVariablesPreview->isNotEmpty())- @foreach ($this->hardcodedEnvironmentVariablesPreview as $index => $env)+ @empty+ <div>No environment variables found.</div>+ @endforelse+ @if (($resource->type() === 'service' || $resource?->build_pack === 'dockercompose') && $this->hardcodedEnvironmentVariables->isNotEmpty())+ @foreach ($this->hardcodedEnvironmentVariables as $index => $env)<livewire:project.shared.environment-variable.show-hardcoded- wire:key="hardcoded-preview-{{ $env['key'] }}-{{ $env['service_name'] ?? 'default' }}-{{ $index }}"- :env="$env" />+ wire:key="hardcoded-prod-{{ $env['key'] }}-{{ $env['service_name'] ?? 'default' }}-{{ $index }}" :env="$env" />@endforeach@endif+ @if ($resource->type() === 'application' && $resource->environment_variables_preview->count() > 0 && $showPreview)+ <div>+ <h3>Preview Deployments Environment Variables</h3>+ <div>Environment (secrets) variables for Preview Deployments.</div>+ </div>+ @foreach ($this->environmentVariablesPreview as $env)+ <livewire:project.shared.environment-variable.show wire:key="environment-{{ $env->id }}" :env="$env"+ :type="$resource->type()" />+ @endforeach+ @if (($resource->type() === 'service' || $resource?->build_pack === 'dockercompose') && $this->hardcodedEnvironmentVariablesPreview->isNotEmpty())+ @foreach ($this->hardcodedEnvironmentVariablesPreview as $index => $env)+ <livewire:project.shared.environment-variable.show-hardcoded+ wire:key="hardcoded-preview-{{ $env['key'] }}-{{ $env['service_name'] ?? 'default' }}-{{ $index }}"+ :env="$env" />+ @endforeach+ @endif+ @endif@endif@else<form wire:submit.prevent='submit' class="flex flex-col gap-2">diff --git a/tests/Feature/EnvironmentVariableMultilineToggleViewTest.php b/tests/Feature/EnvironmentVariableMultilineToggleViewTest.phpindex e27fd0b4b8..632f6f9435 100644--- a/tests/Feature/EnvironmentVariableMultilineToggleViewTest.php+++ b/tests/Feature/EnvironmentVariableMultilineToggleViewTest.php@@ -29,3 +29,19 @@ it('uses sans font for the developer bulk environment variable editor', function->not->toContain('wire:model="variables" monospace')->not->toContain('wire:model="variablesPreview" monospace');});++it('renders the environment variable search field above the production title', function () {+ $view = file_get_contents(resource_path('views/livewire/project/shared/environment-variable/all.blade.php'));++ expect(strpos($view, 'aria-label="Search environment variables"'))+ ->toBeLessThan(strpos($view, '<h3>Production Environment Variables</h3>'));+});++it('renders a single no results message for empty environment variable searches', function () {+ $view = file_get_contents(resource_path('views/livewire/project/shared/environment-variable/all.blade.php'));++ expect($view)+ ->toContain('@if ($this->isSearchActive && ! $this->hasEnvironmentVariables)')+ ->toContain('<div>No environment variables found.</div>')+ ->toContain('@else');+});