Group ProxyHosts table by base domain#5707
Open
jiemCode wants to merge 1 commit into
Open
Conversation
Cluster proxy hosts under collapsible group headers keyed by the registrable domain (PSL via tldts). Grouping is always on; row order within groups still honors column sorting. Multi-domain hosts group by the first domain.
|
Docker Image for build 1 is available on DockerHub: Note Ensure you backup your NPM instance before testing this image! Especially if there are database changes. Warning Changes and additions to DNS Providers require verification by at least 2 members of the community! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Groups the Proxy Hosts listing under collapsible headers keyed by each host's base domain (registrable domain). Once you get more than a handful of proxy hosts, the flat alphabetical list becomes hard to scan — related domains like
api.booze.picsandbooze.picssit far from each other, mixed with unrelated ones likebooze.app. Clustering by base domain makes related hosts visually adjacent and hides bulk behind expandable groups.Grouping is always on, all groups expanded by default, and toggling any column header still sorts rows within their group.
Screenshot
How base domain is computed
Base domain is extracted from
domainNames[0](the first entry in a host'sdomainNamesarray) usingtldts, which is backed by the Mozilla Public Suffix List. This handles multi-level TLDs correctly:api.booze.picsbooze.picsbooze.picsbooze.picsweb.booze.picsbooze.picsapi.school.co.ukschool.co.ukschool.co.ukschool.co.ukblog.github.ioblog.github.ioservice.localservice.localThe helper (
frontend/src/pages/Nginx/ProxyHosts/baseDomain.ts):```ts
import { getDomain } from "tldts";
export function getBaseDomain(domain: string | undefined): string {
if (!domain) return "";
return getDomain(domain) ?? domain;
}
```
getDomainreturnsnullfor IPs / non-PSL suffixes; we fall back to the raw string so those hosts still cluster deterministically by their exact hostname.Why
domainNames[0]?A single proxy host can serve multiple domains — the
domainNamesfield isstring[]. Almost always they share a base (example.com+www.example.com), but occasionally a host serves domains from different bases (e.g.,['booze.app', 'booze.site', 'm.booze.pics']— visible in the screenshot). We use the first domain only to pick the group, matching the existing sort behavior on the Source column (which already sorts bydomainNames?.[0]). The full list still renders in the row, so the extra domains remain visible; they're just not indexed for grouping. Duplicating the row under every base group was rejected as more confusing than helpful (same record showing multiple times).Implementation notes
@tanstack/react-table's built-ingetGroupedRowModel+getExpandedRowModel— no new table library.baseDomainis added as a hidden accessor column (columnVisibility: { baseDomain: false }) so it drives grouping without occupying screen space.groupingandcolumnVisibilitylive ininitialState(uncontrolled), whileexpandedis controlled so a future "collapse all" toggle can hook in.tableDatais memoized inTableWrapper.tsxto avoid re-computing baseDomains on every render.table-activeclass so contrast works in both light and dark themes.TableBody.tsxnow branches onrow.getIsGrouped(); leaf-row rendering is unchanged, so every other table (Redirection Hosts, Streams, Dead Hosts, Access Lists) is unaffected.Files changed
frontend/package.json— addstldts(~small, tree-shakeable PSL lib)frontend/src/pages/Nginx/ProxyHosts/baseDomain.ts(new) —getBaseDomainhelperfrontend/src/pages/Nginx/ProxyHosts/TableWrapper.tsx— injectsbaseDomaininto each row via memoized map, hooks reordered to satisfy rules-of-hooksfrontend/src/pages/Nginx/ProxyHosts/Table.tsx— hiddenbaseDomainaccessor column + TanStack grouping/expansion configfrontend/src/components/Table/TableBody.tsx— renders group header rows (chevron + base domain + subrow count, click to toggle)