Skip to content

Commit 1407f58

Browse files
revers hide hypernode to show hypernode (for better consistance in settings names)
1 parent 91a5aa2 commit 1407f58

9 files changed

Lines changed: 40 additions & 39 deletions

File tree

packages/app-builder/src/components/Graph/GraphImpl.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function personRefFromNodeId(nodes: GraphRfNode[], key: string): GraphObjectRef
5656
export function GraphImpl({ data, dataModel }: GraphImplProps) {
5757
const { t } = useTranslation(graphI18n);
5858
const theme = useTheme();
59-
const { showEdgeLabels, setShowEdgeLabels, hideHypernodes } = useGraphViewSettings();
59+
const { showEdgeLabels, setShowEdgeLabels, showHypernodes } = useGraphViewSettings();
6060
const selectedObject = useSelectedObject();
6161
const setSelectedObject = useSetSelectedObject();
6262
const { hiddenNodeIds } = useGraphStructure();
@@ -75,7 +75,7 @@ export function GraphImpl({ data, dataModel }: GraphImplProps) {
7575
// this component and never see the node arrays.
7676
const graphStats = useMemo(() => {
7777
const countWith = (hidden: Set<string>) =>
78-
applyVisibilityFilters(flatGraph.nodes, flatGraph.edges, hidden, flatGraph.startKey, hideHypernodes).nodes.length;
78+
applyVisibilityFilters(flatGraph.nodes, flatGraph.edges, hidden, flatGraph.startKey, showHypernodes).nodes.length;
7979

8080
const unhiddenCount = hiddenNodeIds.size === 0 ? visibleGraph.nodes.length : countWith(new Set());
8181
const hiddenCount = unhiddenCount - visibleGraph.nodes.length;
@@ -84,7 +84,7 @@ export function GraphImpl({ data, dataModel }: GraphImplProps) {
8484
const withChecked = countWith(new Set([...hiddenNodeIds, ...checkedNodeIds]));
8585
const removed = visibleGraph.nodes.length - withChecked;
8686
return { hiddenCount, hidePreviewOrphans: Math.max(0, removed - checkedNodeIds.size) };
87-
}, [flatGraph, hiddenNodeIds, checkedNodeIds, visibleGraph, hideHypernodes]);
87+
}, [flatGraph, hiddenNodeIds, checkedNodeIds, visibleGraph, showHypernodes]);
8888

8989
useEffect(() => {
9090
setGraphStats(graphStats);
@@ -116,7 +116,7 @@ export function GraphImpl({ data, dataModel }: GraphImplProps) {
116116
}, [connectedPersonsForNode, nodes, selectedObject, setSelectedObject]);
117117

118118
useEffect(() => {
119-
if (!hideHypernodes || selectedObject?.nodeType !== 'hypernode') return;
119+
if (showHypernodes || selectedObject?.nodeType !== 'hypernode') return;
120120

121121
const startNode = flatGraph.nodes.find(
122122
(n): n is Extract<GraphRfNode, { type: 'person' }> => n.id === flatGraph.startKey && n.type === 'person',
@@ -128,7 +128,7 @@ export function GraphImpl({ data, dataModel }: GraphImplProps) {
128128
...personRefFromRfNode(startNode),
129129
persons: connectedPersonsForNode(startNode.id),
130130
});
131-
}, [hideHypernodes, selectedObject, flatGraph, connectedPersonsForNode, setSelectedObject]);
131+
}, [showHypernodes, selectedObject, flatGraph, connectedPersonsForNode, setSelectedObject]);
132132

133133
const onNodeClick = useCallback<NodeMouseHandler<GraphRfNode>>(
134134
(_event, node) => {

packages/app-builder/src/components/Graph/GraphSettingsPanel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export function GraphSettingsPanel() {
325325
refreshGraph,
326326
isGeneratingGraph,
327327
} = useGraphSession();
328-
const { showRiskScore, setShowRiskScore, showTags, setShowTags, hideHypernodes, setHideHypernodes } =
328+
const { showRiskScore, setShowRiskScore, showTags, setShowTags, showHypernodes, setShowHypernodes } =
329329
useGraphViewSettings();
330330
const selectedObject = useSelectedObject();
331331
const { restoreHiddenNodes } = useGraphStructureActions();
@@ -498,9 +498,9 @@ export function GraphSettingsPanel() {
498498
</div>
499499
<div className="flex items-center justify-between gap-sm">
500500
<label htmlFor="hide-hyper-connected-nodes" className="text-grey-primary cursor-pointer text-sm">
501-
{t('graph:panel.hide_hyper_connected_nodes')}
501+
{t('graph:panel.show_hyper_connected_nodes')}
502502
</label>
503-
<Switch id="hide-hyper-connected-nodes" checked={hideHypernodes} onCheckedChange={setHideHypernodes} />
503+
<Switch id="hide-hyper-connected-nodes" checked={showHypernodes} onCheckedChange={setShowHypernodes} />
504504
</div>
505505
<ClusterThresholdControl />
506506
</div>

packages/app-builder/src/components/Graph/contexts/GraphSessionContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export function GraphSessionProvider({
9797
);
9898
const [showRiskScore, setShowRiskScore] = useState(true);
9999
const [showTags, setShowTags] = useState(false);
100-
const [hideHypernodes, setHideHypernodes] = useState(false);
100+
const [showHypernodes, setShowHypernodes] = useState(true);
101101
const [showEdgeLabels, setShowEdgeLabels] = useState(false);
102102
const [clusterThreshold, setClusterThreshold] = useState<ClusterThreshold>(DEFAULT_CLUSTER_THRESHOLD);
103103
const [layoutMode, setLayoutMode] = useState<GraphLayoutMode>('polarPetal');
@@ -186,16 +186,16 @@ export function GraphSessionProvider({
186186
onShowRiskScoreChange: setShowRiskScore,
187187
showTags,
188188
onShowTagsChange: setShowTags,
189-
hideHypernodes,
190-
onHideHypernodesChange: setHideHypernodes,
189+
showHypernodes,
190+
onShowHypernodesChange: setShowHypernodes,
191191
showEdgeLabels,
192192
onShowEdgeLabelsChange: setShowEdgeLabels,
193193
clusterThreshold,
194194
onClusterThresholdChange: setClusterThreshold,
195195
layoutMode,
196196
onLayoutModeChange: setLayoutMode,
197197
}),
198-
[showRiskScore, showTags, hideHypernodes, showEdgeLabels, clusterThreshold, layoutMode],
198+
[showRiskScore, showTags, showHypernodes, showEdgeLabels, clusterThreshold, layoutMode],
199199
);
200200

201201
const value = useMemo(

packages/app-builder/src/components/Graph/contexts/GraphViewSettingsContext.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export type ControlledGraphSettings = {
1919
onShowRiskScoreChange: (value: boolean) => void;
2020
showTags: boolean;
2121
onShowTagsChange: (value: boolean) => void;
22-
hideHypernodes: boolean;
23-
onHideHypernodesChange: (value: boolean) => void;
22+
showHypernodes: boolean;
23+
onShowHypernodesChange: (value: boolean) => void;
2424
showEdgeLabels: boolean;
2525
onShowEdgeLabelsChange: (value: boolean) => void;
2626
clusterThreshold: ClusterThreshold;
@@ -42,8 +42,8 @@ export type GraphViewSettings = {
4242
maxRiskLevel: MaxRiskLevel | undefined;
4343
showTags: boolean;
4444
setShowTags: (value: boolean) => void;
45-
hideHypernodes: boolean;
46-
setHideHypernodes: (value: boolean) => void;
45+
showHypernodes: boolean;
46+
setShowHypernodes: (value: boolean) => void;
4747
showEdgeLabels: boolean;
4848
setShowEdgeLabels: (value: boolean) => void;
4949
layoutMode: GraphLayoutMode;
@@ -63,8 +63,8 @@ export function GraphViewSettingsProvider({
6363
onShowRiskScoreChange,
6464
showTags: controlledShowTags,
6565
onShowTagsChange,
66-
hideHypernodes: controlledHideHypernodes,
67-
onHideHypernodesChange,
66+
showHypernodes: controlledShowHypernodes,
67+
onShowHypernodesChange,
6868
showEdgeLabels: controlledShowEdgeLabels,
6969
onShowEdgeLabelsChange,
7070
clusterThreshold: controlledClusterThreshold,
@@ -78,10 +78,10 @@ export function GraphViewSettingsProvider({
7878
const rawMaxRiskLevel = scoringSettings?.maxRiskLevel;
7979
const maxRiskLevel = rawMaxRiskLevel != null && isMaxRiskLevelInRange(rawMaxRiskLevel) ? rawMaxRiskLevel : undefined;
8080
const [showTags, setShowTags] = useControllableState(false, controlledShowTags, onShowTagsChange);
81-
const [hideHypernodes, setHideHypernodes] = useControllableState(
82-
false,
83-
controlledHideHypernodes,
84-
onHideHypernodesChange,
81+
const [showHypernodes, setShowHypernodes] = useControllableState(
82+
true,
83+
controlledShowHypernodes,
84+
onShowHypernodesChange,
8585
);
8686
const [showEdgeLabels, setShowEdgeLabels] = useControllableState(
8787
false,
@@ -107,8 +107,8 @@ export function GraphViewSettingsProvider({
107107
maxRiskLevel,
108108
showTags,
109109
setShowTags,
110-
hideHypernodes,
111-
setHideHypernodes,
110+
showHypernodes,
111+
setShowHypernodes,
112112
showEdgeLabels,
113113
setShowEdgeLabels,
114114
layoutMode,
@@ -123,8 +123,8 @@ export function GraphViewSettingsProvider({
123123
maxRiskLevel,
124124
showTags,
125125
setShowTags,
126-
hideHypernodes,
127-
setHideHypernodes,
126+
showHypernodes,
127+
setShowHypernodes,
128128
showEdgeLabels,
129129
setShowEdgeLabels,
130130
layoutMode,

packages/app-builder/src/components/Graph/lib/use-laid-out-graph.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,26 @@ describe('applyVisibilityFilters', () => {
5656
expect(visible.edges).toEqual([]);
5757
});
5858

59-
it('drops hypernodes and their edges when hideHypernodes is set', () => {
59+
it('drops hypernodes and their edges when showHypernodes is unset', () => {
6060
const visible = applyVisibilityFilters(
6161
[person('start', true), hypernode('h1'), person('a')],
6262
[edge('start', 'h1'), edge('start', 'a')],
6363
new Set(),
6464
'start',
65-
true,
65+
false,
6666
);
6767

6868
expect(visible.nodes.map((node) => node.id)).toEqual(['start', 'a']);
6969
expect(visible.edges.map((item) => item.id)).toEqual(['start->a']);
7070
});
7171

72-
it('keeps hypernodes when hideHypernodes is unset', () => {
72+
it('keeps hypernodes when showHypernodes is set', () => {
7373
const visible = applyVisibilityFilters(
7474
[person('start', true), hypernode('h1')],
7575
[edge('start', 'h1')],
7676
new Set(),
7777
'start',
78+
true,
7879
);
7980

8081
expect(visible.nodes.map((node) => node.id)).toEqual(['start', 'h1']);

packages/app-builder/src/components/Graph/lib/use-laid-out-graph.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ function resolveStartKey(nodes: GraphRfNode[], fallback: string): string {
3030
return start?.id ?? fallback;
3131
}
3232

33-
function isNodeVisible(node: GraphRfNode, hiddenNodeIds: Set<string>, hideHypernodes: boolean) {
33+
function isNodeVisible(node: GraphRfNode, hiddenNodeIds: Set<string>, showHypernodes: boolean) {
3434
if (node.type === 'person' && node.data.isStart) return true;
35-
if (hideHypernodes && node.type === 'hypernode') return false;
35+
if (!showHypernodes && node.type === 'hypernode') return false;
3636
return !hiddenNodeIds.has(node.id);
3737
}
3838

@@ -41,9 +41,9 @@ export function applyVisibilityFilters(
4141
edges: GraphRfEdge[],
4242
hiddenNodeIds: Set<string>,
4343
startKey: string,
44-
hideHypernodes = false,
44+
showHypernodes = true,
4545
) {
46-
const typeVisibleNodes = nodes.filter((node) => isNodeVisible(node, hiddenNodeIds, hideHypernodes));
46+
const typeVisibleNodes = nodes.filter((node) => isNodeVisible(node, hiddenNodeIds, showHypernodes));
4747
const typeVisibleIds = new Set(typeVisibleNodes.map((node) => node.id));
4848
const typeVisibleEdges = edges.filter((edge) => typeVisibleIds.has(edge.source) && typeVisibleIds.has(edge.target));
4949

@@ -62,15 +62,15 @@ export function applyVisibilityFilters(
6262

6363
export function useLaidOutGraph({ data, dataModel }: { data: GraphData; dataModel: DataModel }) {
6464
const { hiddenNodeIds, expandedRootIds } = useGraphStructure();
65-
const { clusterThreshold, layoutMode, hideHypernodes } = useGraphViewSettings();
65+
const { clusterThreshold, layoutMode, showHypernodes } = useGraphViewSettings();
6666

6767
const typeHelpers = useMemo(() => createGraphTypeHelpers(dataModel), [dataModel]);
6868

6969
const flatGraph = useMemo(() => toFlatFlowElements(data, typeHelpers), [data, typeHelpers]);
7070

7171
const visibleGraph = useMemo(
72-
() => applyVisibilityFilters(flatGraph.nodes, flatGraph.edges, hiddenNodeIds, flatGraph.startKey, hideHypernodes),
73-
[flatGraph, hiddenNodeIds, hideHypernodes],
72+
() => applyVisibilityFilters(flatGraph.nodes, flatGraph.edges, hiddenNodeIds, flatGraph.startKey, showHypernodes),
73+
[flatGraph, hiddenNodeIds, showHypernodes],
7474
);
7575

7676
const filteredLayout = useMemo(() => {

packages/app-builder/src/locales/ar/graph.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"node.too_many": "هذا الجزء من الرسم البياني متصل بشكل مفرط وتم تجاهله ≈ {{count}} عقد تم تجاهلها",
3434
"panel.connected_nodes": "العقد المتصلة",
3535
"panel.grouped_branch": "فرع مجمّع",
36-
"panel.hide_hyper_connected_nodes": "إخفاء العقد فائقة الاتصال",
3736
"panel.hypernode": "عقدة فائقة",
3837
"panel.items_one": "عنصر {{count}}",
3938
"panel.items_other": "{{count}} عناصر",
@@ -43,6 +42,7 @@
4342
"panel.select_node": "حدد عقدة لعرض التفاصيل.",
4443
"panel.show_hidden_nodes_one": "إظهار عقدة مخفية واحدة",
4544
"panel.show_hidden_nodes_other": "إظهار {{count}} عقد مخفية",
45+
"panel.show_hyper_connected_nodes": "إظهار العقد المتصلة بشكل مفرط",
4646
"panel.show_less": "عرض أقل",
4747
"panel.show_more": "عرض المزيد",
4848
"panel.show_risk_score": "إظهار درجة المخاطر",

packages/app-builder/src/locales/en/graph.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"node.too_many": "This part of the graph is hyperconnected and has been discarded ≈ {{count}} nodes ignored",
2626
"panel.connected_nodes": "Connected nodes",
2727
"panel.grouped_branch": "Grouped branch",
28-
"panel.hide_hyper_connected_nodes": "Hide hyper connected nodes",
2928
"panel.hypernode": "Hypernode",
3029
"panel.items_one": "{{count}} item",
3130
"panel.items_other": "{{count}} items",
@@ -35,6 +34,7 @@
3534
"panel.select_node": "Select a node to see details.",
3635
"panel.show_hidden_nodes_one": "Show {{count}} hidden node",
3736
"panel.show_hidden_nodes_other": "Show {{count}} hidden nodes",
37+
"panel.show_hyper_connected_nodes": "Show hyper connected nodes",
3838
"panel.show_less": "Show less",
3939
"panel.show_more": "Show more",
4040
"panel.show_risk_score": "Show risk score",

packages/app-builder/src/locales/fr/graph.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"node.too_many": "Cette partie du graphe est hyperconnectée et a été ignorée ≈ {{count}} nœuds ignorés",
2626
"panel.connected_nodes": "Nœuds connectés",
2727
"panel.grouped_branch": "Branche regroupée",
28-
"panel.hide_hyper_connected_nodes": "Masquer les nœuds hyperconnectés",
2928
"panel.hypernode": "Hypernœud",
3029
"panel.items_one": "{{count}} élément",
3130
"panel.items_other": "{{count}} éléments",
@@ -35,6 +34,7 @@
3534
"panel.select_node": "Sélectionnez un nœud pour voir les détails.",
3635
"panel.show_hidden_nodes_one": "Afficher {{count}} nœud masqué",
3736
"panel.show_hidden_nodes_other": "Afficher {{count}} nœuds masqués",
37+
"panel.show_hyper_connected_nodes": "Afficher les nœuds hyper connectés",
3838
"panel.show_less": "Afficher moins",
3939
"panel.show_more": "Afficher plus",
4040
"panel.show_risk_score": "Afficher le score de risque",

0 commit comments

Comments
 (0)