MCPcopy
hub / github.com/opentrace/opentrace / shouldHideNode

Function shouldHideNode

ui/src/components/graph/useGraphFilters.ts:27–63  ·  view source on GitHub ↗
(
  node: GraphNode,
  filterState: FilterState,
  communityAssignments: Record<string, number>,
  availableSubTypes: Map<string, { subType: string; count: number }[]>,
  getSubType: GetSubTypeFn,
)

Source from the content-addressed store, hash-verified

25 * Exported so it can be reused by other components.
26 */
27export function shouldHideNode(
28 node: GraphNode,
29 filterState: FilterState,
30 communityAssignments: Record<string, number>,
31 availableSubTypes: Map<string, { subType: string; count: number }[]>,
32 getSubType: GetSubTypeFn,
33): boolean {
34 // Community filter
35 const communityId = communityAssignments[node.id];
36 if (
37 communityId !== undefined &&
38 filterState.hiddenCommunities.has(communityId)
39 ) {
40 return true;
41 }
42
43 // Sub-type filter: when the node type has sub-types, sub-type visibility
44 // takes precedence over the top-level type filter (matching filteredGraphData).
45 const subTypes = availableSubTypes.get(node.type);
46 if (subTypes && subTypes.length > 0) {
47 const subType = getSubType(node);
48 if (subType) {
49 return filterState.hiddenSubTypes.has(`${node.type}:${subType}`);
50 }
51 // Node has no sub-type — hide only if ALL sub-types are hidden
52 return subTypes.every((s) =>
53 filterState.hiddenSubTypes.has(`${node.type}:${s.subType}`),
54 );
55 }
56
57 // Type filter (only for types without sub-types)
58 if (filterState.hiddenNodeTypes.has(node.type)) {
59 return true;
60 }
61
62 return false;
63}
64
65// ─── Hook ───────────────────────────────────────────────────────────────
66

Callers 3

useGraphFiltersFunction · 0.85

Calls 2

getSubTypeFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected