diff --git a/mscr-ui/public/locales/en/common.json b/mscr-ui/public/locales/en/common.json index 836740b16..e3c300e11 100644 --- a/mscr-ui/public/locales/en/common.json +++ b/mscr-ui/public/locales/en/common.json @@ -29,7 +29,7 @@ "finish-editing": "Finish editing", "invalidate-crosswalk": "Invalidate crosswalk", "invalidate-schema": "Invalidate schema", - "mscr-copy": "Covert to MSCR Format", + "mscr-copy": "Make a MSCR Copy", "publish-crosswalk": "Publish crosswalk", "publish-schema": "Publish schema", "revision": "Add new revision", @@ -91,7 +91,7 @@ "crosswalk-create": "Create Crosswalk", "crosswalk-register": "Register Crosswalk", "crosswalk-revision": "Register revision", - "mscr-copy": "Convert to MSCR Format", + "mscr-copy": "MSCR Copy", "schema-register": "Register Schema", "schema-revision": "Register revision" }, @@ -109,7 +109,7 @@ "crosswalk-mscr-copy": "Register MSCR copy of crosswalk", "crosswalk-register": "Register existing crosswalk", "crosswalk-revision": "Register revision of crosswalk", - "schema-mscr-copy": "Convert Schema to MSCR Format", + "schema-mscr-copy": "Make a MSCR copy", "schema-register": "Register schema", "schema-revision": "Register revision of schema" }, @@ -278,7 +278,7 @@ "add-schema": "New schema added", "add-schema-revision": "New schema version added", "copy-crosswalk": "MSCR copy of crosswalk added", - "copy-schema": "Schema is converted to MSCR format", + "copy-schema": "MSCR copy of schema added", "crosswalk-deleted": "Crosswalk was removed", "crosswalk-deprecated": "Crosswalk deprecated", "crosswalk-invalidated": "Crosswalk invalidated", diff --git a/mscr-ui/src/common/components/schema-info/index.tsx b/mscr-ui/src/common/components/schema-info/index.tsx index b6baff4ce..637ea0bea 100644 --- a/mscr-ui/src/common/components/schema-info/index.tsx +++ b/mscr-ui/src/common/components/schema-info/index.tsx @@ -71,8 +71,6 @@ export default function SchemaInfo(props: { generatedTree.then((res) => { if (res) { setTreeDataOriginal(res); - // Expand tree when data is loaded - setPartlyExpanded(); setTreeData(res); setTreeDataFetched(true); setNodeIdToNodeDictionary(nodeIdToShallowNode); @@ -82,11 +80,6 @@ export default function SchemaInfo(props: { } }, [getSchemaDataIsSuccess, getSchemaData]); - // Expand tree when data is loaded - useEffect(() => { - setPartlyExpanded(); - }, [isTreeDataFetched]); - // Expand and select nodes when input changed (from mappings accordion) useEffect(() => { if (props.treeSelection) { @@ -108,39 +101,32 @@ export default function SchemaInfo(props: { setSelectedTreeNodes(selectedNodes); }, [treeSelectedArray, nodeIdToNodeDictionary]); - const setPartlyExpanded = () => { + const setFullyExpanded = () => { const nodeIdsToExpand: string[] = []; - treeData.forEach(({ children, id }) => { - if (children && children.length > 0) { - nodeIdsToExpand.push(id); - if (children.length === 1) { - nodeIdsToExpand.push(children[0].id); - } - } + Object.entries(nodeIdToNodeDictionary).map(([nodeId, node]) => { + if (node.some((n) => n.children.length > 0)) nodeIdsToExpand.push(nodeId); }); setTreeExpandedArray(nodeIdsToExpand); }; function clearTreeSearch() { setTreeSelectedArray([]); - setPartlyExpanded(); setSelectedTreeNodes([]); } // Used by tree select and filtering function getAllNodeIdsOnPathToLeaf(nodeIds: string[]) { - const elementPaths: string[] = []; + let idsOnPath: string[] = []; nodeIds.forEach((nodeId) => { const nodes = nodeIdToNodeDictionary[nodeId]; - nodes.map((node) => elementPaths.push(node.elementPath)); + nodes.map((node) => { + idsOnPath = idsOnPath.concat(node.rootPathIds); + }); }); const nodesToSelect: Set = new Set(); - elementPaths.forEach((path) => { - const nodeIdsOnPath = path.split('.'); - nodeIdsOnPath.forEach((nodeId) => { - nodesToSelect.add(nodeId); - }); + idsOnPath.forEach((pathNodeId) => { + nodesToSelect.add(pathNodeId); }); return Array.from(nodesToSelect); @@ -148,7 +134,7 @@ export default function SchemaInfo(props: { const handleExpandClick = () => { if (treeExpandedArray.length === 0) { - setPartlyExpanded(); + setFullyExpanded(); } else { setTreeExpandedArray([]); } @@ -321,7 +307,7 @@ export default function SchemaInfo(props: { > {isTreeDataFetched && ( void; @@ -78,16 +78,7 @@ export default function SchemaTree({ defaultExpandIcon={} multiSelect > - - {Array.isArray(nodes.children) - ? nodes.children.map((node: RenderTree) => toTree(node, showQname)) - : null} - + {nodes.map((node: RenderTree) => toTree(node, showQname))} ); } diff --git a/mscr-ui/src/common/components/schema-info/schema-tree/node-info/index.tsx b/mscr-ui/src/common/components/schema-info/schema-tree/node-info/index.tsx index fd99692e7..a7400c67c 100644 --- a/mscr-ui/src/common/components/schema-info/schema-tree/node-info/index.tsx +++ b/mscr-ui/src/common/components/schema-info/schema-tree/node-info/index.tsx @@ -132,7 +132,6 @@ export default function NodeInfo(props: { )} {props.isNodeEditable && selectedNode && - selectedNode?.elementPath !== 'ROOT' && !isLeafNode && !props.hasCustomRoot && (