Sync blocked table and remove whitelist edit

This commit is contained in:
root
2026-01-31 00:57:07 +02:00
parent 135e71d563
commit 36da25a336
2 changed files with 9 additions and 22 deletions

View File

@@ -419,6 +419,7 @@ class Waf extends Page implements HasForms, HasTable
$this->loadAuditLogs(false);
$this->resetTable();
$this->dispatch('waf-whitelist-updated');
$this->dispatch('waf-blocked-updated');
Notification::make()
->title(__('Rule whitelisted'))
@@ -474,6 +475,7 @@ class Waf extends Page implements HasForms, HasTable
$this->loadAuditLogs(false);
$this->resetTable();
$this->dispatch('waf-whitelist-updated');
$this->dispatch('waf-blocked-updated');
Notification::make()
->title(__('Whitelist removed'))
@@ -598,6 +600,13 @@ class Waf extends Page implements HasForms, HasTable
]);
}
#[\Livewire\Attributes\On('waf-blocked-updated')]
public function refreshBlockedTable(): void
{
$this->loadAuditLogs(false);
$this->resetTable();
}
protected function filterRecords(array $records, ?string $search): array
{
if (! $search) {

View File

@@ -86,28 +86,6 @@ class WafWhitelistTable extends Component implements HasTable, HasSchemas, HasAc
}),
])
->actions([
Action::make('edit')
->label(__('Edit'))
->icon('heroicon-o-pencil-square')
->form($this->whitelistRuleForm())
->fillForm(fn (array $record) => Arr::only($record, ['label', 'match_type', 'match_value', 'rule_ids']))
->action(function (array $data, array $record): void {
$rules = $this->getWhitelistRules();
foreach ($rules as &$rule) {
if (($rule['__key'] ?? '') === ($record['__key'] ?? '')) {
$rule = array_merge($rule, $this->normalizeRule($data));
break;
}
}
$this->persistWhitelistRules($rules);
Notification::make()
->title(__('Whitelist rule updated'))
->success()
->send();
}),
Action::make('delete')
->label(__('Delete'))
->icon('heroicon-o-trash')