From 279ab00ee757ac502446cfd903797ef8e790ea50 Mon Sep 17 00:00:00 2001 From: "Joseph.Rawlings" Date: Mon, 8 Dec 2025 14:17:07 -0500 Subject: [PATCH] Add rename configuration functionality in Firewall component and view --- .../Servers/Proxmox/Livewire/Firewall.php | 82 +++++++++++++++++++ .../Servers/Proxmox/views/firewall.blade.php | 46 +++++++++++ 2 files changed, 128 insertions(+) diff --git a/extensions/Servers/Proxmox/Livewire/Firewall.php b/extensions/Servers/Proxmox/Livewire/Firewall.php index dfc1a9343..5f8f2bce0 100644 --- a/extensions/Servers/Proxmox/Livewire/Firewall.php +++ b/extensions/Servers/Proxmox/Livewire/Firewall.php @@ -61,6 +61,9 @@ class Firewall extends Component public bool $showApplyConfigModal = false; public ?FirewallConfiguration $applyingConfiguration = null; public array $applyCompatibilityWarnings = []; + public bool $showRenameConfigModal = false; + public ?int $renamingConfigId = null; + public string $renameConfigName = ''; // Apply to All Servers public bool $showApplyToAllModal = false; @@ -2292,6 +2295,85 @@ class Firewall extends Component } } + /** + * Open the rename configuration modal. + */ + public function openRenameConfigModal(int $configId): void + { + $userId = Auth::id(); + if (!$userId) { + return; + } + + $config = FirewallConfiguration::forUser($userId)->find($configId); + if (!$config) { + $this->error = 'Configuration not found or access denied'; + $this->showErrorModal = true; + return; + } + + $this->renamingConfigId = $configId; + $this->renameConfigName = $config->configuration_name; + $this->showRenameConfigModal = true; + } + + /** + * Close the rename configuration modal. + */ + public function closeRenameConfigModal(): void + { + $this->renamingConfigId = null; + $this->renameConfigName = ''; + $this->showRenameConfigModal = false; + } + + /** + * Rename a saved configuration. + */ + public function renameConfiguration(): void + { + if (!$this->renamingConfigId) { + return; + } + + $this->validate([ + 'renameConfigName' => 'required|string|min:1|max:255', + ]); + + $userId = Auth::id(); + if (!$userId) { + $this->error = 'You must be logged in to rename configurations'; + $this->showErrorModal = true; + return; + } + + $this->loading = true; + + try { + $config = FirewallConfiguration::forUser($userId)->find($this->renamingConfigId); + + if (!$config) { + $this->error = 'Configuration not found or access denied'; + $this->showErrorModal = true; + return; + } + + $config->update([ + 'configuration_name' => trim($this->renameConfigName), + ]); + + $this->notify('Configuration renamed successfully', 'success'); + $this->closeRenameConfigModal(); + $this->loadSavedConfigurations(); + } catch (\Exception $e) { + Log::error('Failed to rename firewall configuration: ' . $e->getMessage()); + $this->error = 'Failed to rename configuration: ' . $e->getMessage(); + $this->showErrorModal = true; + } finally { + $this->loading = false; + } + } + // ==================== APPLY TO ALL SERVERS ==================== /** diff --git a/extensions/Servers/Proxmox/views/firewall.blade.php b/extensions/Servers/Proxmox/views/firewall.blade.php index b96b94794..29a694a30 100644 --- a/extensions/Servers/Proxmox/views/firewall.blade.php +++ b/extensions/Servers/Proxmox/views/firewall.blade.php @@ -1473,6 +1473,9 @@ + @@ -2369,6 +2372,49 @@ @endif +{{-- Rename Configuration Modal --}} +@if($showRenameConfigModal && $renamingConfigId) +
+
+ +
+
+ +
+
+

Rename Configuration

+

Enter a new name for this configuration

+
+
+ +
+ + + @error('renameConfigName') +

{{ $message }}

+ @enderror +
+ +
+ + +
+
+
+@endif + @script