Skip to content

Commit d6bccd5

Browse files
committed
loosened label matching on structureData
1 parent 6908d93 commit d6bccd5

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/AiidaExplorer/VisualiserPane/index.jsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,24 @@ const RICH_TYPES = {
1717
CalcJobNode: CalcJobVisualiser,
1818
};
1919

20+
/**
21+
* Returns the appropriate visualiser component for a node.
22+
*
23+
* Selection priority:
24+
* 1. Exact match via RICH_TYPES
25+
* 2. Fallback pattern matching (e.g. labels ending with "StructureData")
26+
*
27+
* @param {string} restApiUrl
28+
* @param {Object} selectedNode
29+
* @returns {JSX.Element|null}
30+
*/
2031
function geRichVisualiser(restApiUrl, selectedNode) {
21-
if (!selectedNode) return null;
22-
if (!selectedNode.data) return null;
32+
if (!selectedNode?.data) return null;
2333
const { label, aiida } = selectedNode.data;
24-
const VisualiserComponent = RICH_TYPES[label];
34+
let VisualiserComponent = RICH_TYPES[label];
35+
if (!VisualiserComponent && label?.endsWith("StructureData")) {
36+
VisualiserComponent = StructureDataVisualiser;
37+
}
2538
if (VisualiserComponent) {
2639
return (
2740
<VisualiserComponent
@@ -44,7 +57,7 @@ export default function VisualiserPane({
4457
// memo the richVisualiser to only update if state changes - perf ++
4558
const richVisualiser = useMemo(
4659
() => geRichVisualiser(restApiUrl, selectedNode),
47-
[restApiUrl, selectedNode?.data?.label, selectedNode?.data?.aiida?.uuid]
60+
[restApiUrl, selectedNode?.data?.label, selectedNode?.data?.aiida?.uuid],
4861
);
4962
const [activeTab, setActiveTab] = useState(richVisualiser ? "rich" : "raw");
5063

0 commit comments

Comments
 (0)