feat(api, web): enhance policy rule handling with list name integration
Build and Push EvoFirewall Docker Image / build-and-push (push) Successful in 1m57s
Build and Push EvoFirewall Docker Image / create-release (push) Skipped

- Updated the `sourceMeta` function to accept a database parameter, allowing for dynamic retrieval of list names based on list IDs.
- Modified the `ruleTarget` and `ruleSubtitle` functions to utilize the new list name mapping, improving the readability of policy rules in the UI.
- Introduced memoization for list names in the `PolicySetDetailPage`, optimizing performance and ensuring accurate display of list names in the policy rules sortable component.

These changes enhance the user experience by providing clearer and more informative labels for policy rules, facilitating better understanding and management of policies.
This commit is contained in:
Denozordec
2026-07-23 11:46:51 +07:00
parent fac2ed4d2d
commit d8567205e2
3 changed files with 59 additions and 17 deletions
+22 -3
View File
@@ -180,6 +180,23 @@ function PolicySetDetailPage() {
const rules = rulesQ.data?.items ?? []
const listNameById = useMemo(() => {
const m = new Map<string, string>()
for (const l of listsQ.data?.items ?? []) {
m.set(l.id, l.name)
}
return m
}, [listsQ.data?.items])
const listSelectItems = useMemo(
() =>
(listsQ.data?.items ?? []).map((l) => ({
value: l.id,
label: l.name,
})),
[listsQ.data?.items],
)
const agentColumns: ColumnDef<Agent>[] = useMemo(
() => [
{
@@ -336,6 +353,7 @@ function PolicySetDetailPage() {
<PolicyRulesSortable
setId={setId}
rules={rules}
listNames={listNameById}
onDelete={(id) => setDeleteRuleId(id)}
onAdd={() => setRuleOpen(true)}
/>
@@ -441,6 +459,7 @@ function PolicySetDetailPage() {
<Field>
<FieldLabel>Список</FieldLabel>
<Select
items={listSelectItems}
value={listId || null}
onValueChange={(v) => setListId(v ?? '')}
>
@@ -448,9 +467,9 @@ function PolicySetDetailPage() {
<SelectValue placeholder="Выберите список" />
</SelectTrigger>
<SelectContent>
{(listsQ.data?.items ?? []).map((l) => (
<SelectItem key={l.id} value={l.id}>
{l.name}
{listSelectItems.map((l) => (
<SelectItem key={l.value} value={l.value}>
{l.label}
</SelectItem>
))}
</SelectContent>