From d7524a743d3a78a12bac4ce51baab25043c845ec Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Wed, 3 Jun 2026 12:54:50 +0200 Subject: [PATCH] fix(env-vars): show single empty state for searches Move the environment variable search field above the production section and hide production and preview headings when a search has no results. --- .../Shared/EnvironmentVariable/All.php | 16 ++++ .../shared/environment-variable/all.blade.php | 94 ++++++++++--------- ...ronmentVariableMultilineToggleViewTest.php | 16 ++++ 3 files changed, 80 insertions(+), 46 deletions(-) diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/All.php b/app/Livewire/Project/Shared/EnvironmentVariable/All.php index 65f0bd437..2a1a47b4d 100644 --- a/app/Livewire/Project/Shared/EnvironmentVariable/All.php +++ b/app/Livewire/Project/Shared/EnvironmentVariable/All.php @@ -45,6 +45,7 @@ public function updatedSearch() unset($this->environmentVariablesPreview); unset($this->hardcodedEnvironmentVariables); unset($this->hardcodedEnvironmentVariablesPreview); + unset($this->hasEnvironmentVariables); } public function mount() @@ -111,6 +112,19 @@ private function searchTerm(): string return 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 @@ private function handleSingleSubmit($data) unset($this->environmentVariablesPreview); unset($this->hardcodedEnvironmentVariables); unset($this->hardcodedEnvironmentVariablesPreview); + unset($this->hasEnvironmentVariables); $this->dispatch('success', 'Environment variable added.'); } @@ -446,6 +461,7 @@ public function refreshEnvs() unset($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.php index 77ac92ffe..f49765286 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 @if ($view === 'normal') -
-
-

Production Environment Variables

-
Environment (secrets) variables for Production.
-
-
-
- -
-
- - -
+
+
+ +
+
+ +
- @forelse ($this->environmentVariables as $env) - - @empty + @if ($this->isSearchActive && ! $this->hasEnvironmentVariables)
No environment variables found.
- @endforelse - @if (($resource->type() === 'service' || $resource?->build_pack === 'dockercompose') && $this->hardcodedEnvironmentVariables->isNotEmpty()) - @foreach ($this->hardcodedEnvironmentVariables as $index => $env) - - @endforeach - @endif - @if ($resource->type() === 'application' && $resource->environment_variables_preview->count() > 0 && $showPreview) + @else
-

Preview Deployments Environment Variables

-
Environment (secrets) variables for Preview Deployments.
+

Production Environment Variables

+
Environment (secrets) variables for Production.
- @foreach ($this->environmentVariablesPreview as $env) + @forelse ($this->environmentVariables as $env) - @endforeach - @if (($resource->type() === 'service' || $resource?->build_pack === 'dockercompose') && $this->hardcodedEnvironmentVariablesPreview->isNotEmpty()) - @foreach ($this->hardcodedEnvironmentVariablesPreview as $index => $env) + @empty +
No environment variables found.
+ @endforelse + @if (($resource->type() === 'service' || $resource?->build_pack === 'dockercompose') && $this->hardcodedEnvironmentVariables->isNotEmpty()) + @foreach ($this->hardcodedEnvironmentVariables as $index => $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) +
+

Preview Deployments Environment Variables

+
Environment (secrets) variables for Preview Deployments.
+
+ @foreach ($this->environmentVariablesPreview as $env) + + @endforeach + @if (($resource->type() === 'service' || $resource?->build_pack === 'dockercompose') && $this->hardcodedEnvironmentVariablesPreview->isNotEmpty()) + @foreach ($this->hardcodedEnvironmentVariablesPreview as $index => $env) + + @endforeach + @endif + @endif @endif @else
diff --git a/tests/Feature/EnvironmentVariableMultilineToggleViewTest.php b/tests/Feature/EnvironmentVariableMultilineToggleViewTest.php index e27fd0b4b..632f6f943 100644 --- a/tests/Feature/EnvironmentVariableMultilineToggleViewTest.php +++ b/tests/Feature/EnvironmentVariableMultilineToggleViewTest.php @@ -29,3 +29,19 @@ ->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, '

Production Environment Variables

')); +}); + +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('
No environment variables found.
') + ->toContain('@else'); +});