Add rename configuration functionality in Firewall component and view
This commit is contained in:
@@ -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 ====================
|
||||
|
||||
/**
|
||||
|
||||
@@ -1473,6 +1473,9 @@
|
||||
<button type="button" wire:click="viewConfiguration({{ $config['id'] }})" class="p-2 text-info hover:bg-info/10 rounded-lg transition-colors" title="View Details">
|
||||
<x-ri-eye-line class="size-5" />
|
||||
</button>
|
||||
<button type="button" wire:click="openRenameConfigModal({{ $config['id'] }})" class="p-2 text-warning hover:bg-warning/10 rounded-lg transition-colors" title="Rename Configuration">
|
||||
<x-ri-edit-line class="size-5" />
|
||||
</button>
|
||||
<button type="button" wire:click="confirmDeleteConfiguration({{ $config['id'] }})" class="p-2 text-error hover:bg-error/10 rounded-lg transition-colors" title="Delete Configuration">
|
||||
<x-ri-delete-bin-line class="size-5" />
|
||||
</button>
|
||||
@@ -2369,6 +2372,49 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- Rename Configuration Modal --}}
|
||||
@if($showRenameConfigModal && $renamingConfigId)
|
||||
<div class="fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div class="relative w-full max-w-md bg-background-secondary rounded-xl border border-neutral/20 shadow-2xl p-6">
|
||||
<button wire:click="closeRenameConfigModal" class="absolute top-4 right-4 text-base/50 hover:text-base transition-colors">
|
||||
<x-ri-close-line class="size-5" />
|
||||
</button>
|
||||
<div class="flex items-start gap-4 mb-6">
|
||||
<div class="w-12 h-12 rounded-full bg-warning/10 flex items-center justify-center flex-shrink-0">
|
||||
<x-ri-edit-line class="size-6 text-warning" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="text-xl font-bold mb-1">Rename Configuration</h3>
|
||||
<p class="text-sm text-base/70">Enter a new name for this configuration</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-6">
|
||||
<label for="renameConfigName" class="block text-sm font-medium mb-2">Configuration Name</label>
|
||||
<input type="text"
|
||||
id="renameConfigName"
|
||||
wire:model="renameConfigName"
|
||||
class="w-full px-4 py-2 bg-background border border-neutral rounded-lg focus:border-primary focus:ring-1 focus:ring-primary transition-colors"
|
||||
placeholder="Enter configuration name"
|
||||
maxlength="255">
|
||||
@error('renameConfigName')
|
||||
<p class="mt-1 text-sm text-error">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3 justify-end">
|
||||
<button wire:click="closeRenameConfigModal" class="px-4 py-2 bg-background border border-neutral rounded-lg hover:bg-background-secondary transition-colors text-sm font-medium">
|
||||
Cancel
|
||||
</button>
|
||||
<button wire:click="renameConfiguration" wire:loading.attr="disabled" class="px-4 py-2 bg-warning text-white rounded-lg hover:bg-warning/90 transition-colors text-sm font-medium disabled:opacity-50">
|
||||
<span wire:loading.remove wire:target="renameConfiguration">Rename</span>
|
||||
<span wire:loading wire:target="renameConfiguration">Renaming...</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@script
|
||||
<script>
|
||||
// IP location helper functions
|
||||
|
||||
Reference in New Issue
Block a user