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
+12 -7
View File
@@ -82,18 +82,23 @@ function resolveDefaultAction(agentDefaultAction: string | null | undefined): De
return defaultActionFromLegacyMode(agentDefaultAction)
}
function sourceMeta(rule: {
cidr: string | null
listId: string | null
hostname: string | null
}): { kind: 'list' | 'cidr' | 'hostname'; label: string } {
function sourceMeta(
db: Db,
rule: {
cidr: string | null
listId: string | null
hostname: string | null
},
): { kind: 'list' | 'cidr' | 'hostname'; label: string } {
if (rule.cidr?.trim()) {
return { kind: 'cidr', label: rule.cidr.trim() }
}
if (rule.hostname?.trim()) {
return { kind: 'hostname', label: rule.hostname.trim() }
}
return { kind: 'list', label: rule.listId ?? 'list' }
const listId = rule.listId?.trim() || ''
const name = listId ? repos.getIpList(db, listId)?.name : null
return { kind: 'list', label: name || listId || 'list' }
}
/** Evaluate allow/deny sets for an agent from assigned policy sets. */
@@ -125,7 +130,7 @@ export function evaluateAgentPolicy(db: Db, agentId: string): EvaluatedPolicy {
allow.push(...cidrs)
rulesAllow += 1
}
const src = sourceMeta(rule)
const src = sourceMeta(db, rule)
const setName =
assignedSets.find((s) => s.setId === rule.setId)?.name ?? null
chain.push({