Skip to content

Commit e76f6c2

Browse files
committed
backward compatibility for datasnapshots without target systems
1 parent 0e88cc6 commit e76f6c2

3 files changed

Lines changed: 52 additions & 25 deletions

File tree

applications/sckanner/frontend/src/components/ConnectivityGrid.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ function ConnectivityGrid() {
276276
setFilteredXOrgans(filteredOrgans);
277277
setFilteredXAxis(filteredHierarchicalX);
278278
setFilteredConnectionsMap(filteredConnectionsMap);
279+
} else if (xAxis.length === 0 && yAxis.length > 0) {
280+
// When xAxis is empty (e.g., datasnapshot without target systems), clear filtered state
281+
setFilteredXAxis([]);
282+
setFilteredXOrgans([]);
279283
}
280284
}, [yAxis, connectionsMap, xAxisOrgans, xAxis, filters.EndOrgan]);
281285

applications/sckanner/frontend/src/components/common/Heatmap.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,26 @@ const HeatmapGrid: FC<HeatmapGridProps> = ({
322322

323323
if (!hasHierarchy || !heatmapContainerRef.current) {
324324
setHorizontalParents([]);
325+
326+
// Clear any leftover data attributes from previous datasnapshot
327+
if (heatmapContainerRef.current) {
328+
const xLabelsContainer = heatmapContainerRef.current.querySelector(
329+
'& > div:first-of-type > div:first-of-type',
330+
);
331+
if (xLabelsContainer) {
332+
const labelElements = Array.from(
333+
xLabelsContainer.querySelectorAll('& > div'),
334+
) as HTMLElement[];
335+
336+
// Clear attributes from all X-axis labels
337+
labelElements.slice(1).forEach((element) => {
338+
element.removeAttribute('data-x-label-index');
339+
element.removeAttribute('data-is-child');
340+
element.removeAttribute('data-is-collapsed');
341+
});
342+
}
343+
}
344+
325345
return;
326346
}
327347

applications/sckanner/frontend/src/services/heatmapService.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,34 +60,37 @@ export function getHierarchicalXAxis(
6060
// Get ordered target system IDs from endorgansOrder
6161
const orderedSystemIds = Object.keys(endorgansOrder);
6262

63-
// Build target system hierarchy
63+
// Build target system hierarchy - only include systems with actual organ children
6464
orderedSystemIds.forEach((systemId) => {
6565
const systemOrgans = targetSystems[systemId];
66-
if (systemOrgans && systemOrgans.length > 0) {
67-
// Get the system name from targetSystemNames
68-
const systemName =
69-
targetSystemNames[systemId] ||
70-
organs[systemId]?.name ||
71-
systemId.split('/').pop() ||
72-
systemId;
73-
74-
const children: HierarchicalItem[] = systemOrgans.map((organ) => {
75-
organsInSystems.add(organ.id);
76-
return {
77-
id: organ.id,
78-
label: organ.name,
79-
children: [],
80-
expanded: false,
81-
};
82-
});
83-
84-
result.push({
85-
id: systemId,
86-
label: systemName,
87-
children,
88-
expanded: false, // Start collapsed
89-
});
66+
// Skip if no organs exist for this target system or the array is empty
67+
if (!systemOrgans || systemOrgans.length === 0) {
68+
return;
9069
}
70+
71+
// Get the system name from targetSystemNames
72+
const systemName =
73+
targetSystemNames[systemId] ||
74+
organs[systemId]?.name ||
75+
systemId.split('/').pop() ||
76+
systemId;
77+
78+
const children: HierarchicalItem[] = systemOrgans.map((organ) => {
79+
organsInSystems.add(organ.id);
80+
return {
81+
id: organ.id,
82+
label: organ.name,
83+
children: [],
84+
expanded: false,
85+
};
86+
});
87+
88+
result.push({
89+
id: systemId,
90+
label: systemName,
91+
children,
92+
expanded: false, // Start collapsed
93+
});
9194
});
9295

9396
// Add organs that are not part of any target system

0 commit comments

Comments
 (0)