Improve network filter item

This commit is contained in:
Pierre HUBERT 2024-01-04 16:21:26 +01:00
parent dcf6cdab9b
commit ff66a5cf97

View File

@ -18,6 +18,18 @@ export function NWFilterItem(p: {
dense?: boolean;
onDelete?: () => void;
}): React.ReactElement {
const specs = [];
if (p.value) {
if (p.value.rules.length === 1) specs.push(`1 rule`);
else if (p.value.rules.length > 1)
specs.push(`${p.value.rules.length} rules`);
if (p.value.join_filters.length === 1) specs.push(`1 joint filter`);
else if (p.value.join_filters.length > 1)
specs.push(`${p.value.join_filters.length} joint filters`);
if (p.value.priority) specs.push(`priority: ${p.value.priority}`);
}
const inner = (
<>
<ListItemAvatar>
@ -31,10 +43,7 @@ export function NWFilterItem(p: {
? `${p.value.name} (${p.value.chain?.protocol ?? "unspecified"})`
: "Unspecified"
}
secondary={
p.value &&
`${p.value.rules.length} rules - ${p.value.join_filters.length} joint filters`
}
secondary={specs.join(" / ")}
/>
</>
);