refactor(DynamicConfigurations): improve handling of dynamic configuration content by ensuring fallback to empty string when content is null

This commit is contained in:
Andras Bacsai
2025-04-13 14:24:27 +02:00
parent 6eea3c50d8
commit 4bc9786046
2 changed files with 3 additions and 2 deletions

View File

@@ -38,7 +38,8 @@ class DynamicConfigurations extends Component
$contents = collect([]); $contents = collect([]);
foreach ($files as $file) { foreach ($files as $file) {
$without_extension = str_replace('.', '|', $file); $without_extension = str_replace('.', '|', $file);
$contents[$without_extension] = instant_remote_process(["cat {$proxy_path}/dynamic/{$file}"], $this->server); $content = instant_remote_process(["cat {$proxy_path}/dynamic/{$file}"], $this->server);
$contents[$without_extension] = $content ?? '';
} }
$this->contents = $contents; $this->contents = $contents;
$this->dispatch('$refresh'); $this->dispatch('$refresh');

View File

@@ -38,7 +38,7 @@
wire:model="contents.{{ $fileName }}" rows="5" /> wire:model="contents.{{ $fileName }}" rows="5" />
@else @else
<livewire:server.proxy.dynamic-configuration-navbar :server_id="$server->id" <livewire:server.proxy.dynamic-configuration-navbar :server_id="$server->id"
:fileName="$fileName" :value="$value" :newFile="false" :fileName="$fileName" :value="$value ?? ''" :newFile="false"
wire:key="{{ $fileName }}-{{ $loop->index }}" /> wire:key="{{ $fileName }}-{{ $loop->index }}" />
<x-forms.textarea disabled wire:model="contents.{{ $fileName }}" <x-forms.textarea disabled wire:model="contents.{{ $fileName }}"
rows="10" /> rows="10" />