Skip to content

Commit

Permalink
Merge pull request #241 from CSCfi/develop
Browse files Browse the repository at this point in the history
rahti Deployment from current develop
  • Loading branch information
rquazi authored Jan 8, 2025
2 parents d78724b + df14a39 commit 62cd6fc
Show file tree
Hide file tree
Showing 16 changed files with 248 additions and 411 deletions.
8 changes: 4 additions & 4 deletions mscr-ui/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
},
Expand All @@ -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"
},
Expand Down Expand Up @@ -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",
Expand Down
36 changes: 11 additions & 25 deletions mscr-ui/src/common/components/schema-info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -108,47 +101,40 @@ 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<string> = 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);
}

const handleExpandClick = () => {
if (treeExpandedArray.length === 0) {
setPartlyExpanded();
setFullyExpanded();
} else {
setTreeExpandedArray([]);
}
Expand Down Expand Up @@ -321,7 +307,7 @@ export default function SchemaInfo(props: {
>
{isTreeDataFetched && (
<SchemaTree
nodes={treeData[0]}
nodes={treeData}
treeSelectedArray={treeSelectedArray}
treeExpanded={treeExpandedArray}
performTreeAction={performCallbackFromTreeAction}
Expand Down
13 changes: 2 additions & 11 deletions mscr-ui/src/common/components/schema-info/schema-tree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function SchemaTree({
showQname,
isSourceTree,
}: {
nodes: RenderTree;
nodes: RenderTree[];
treeSelectedArray: string[];
treeExpanded: string[];
performTreeAction: (action: string, nodeIds: string[]) => void;
Expand Down Expand Up @@ -78,16 +78,7 @@ export default function SchemaTree({
defaultExpandIcon={<ChevronRightIcon />}
multiSelect
>
<TreeItem
key={nodes.visualTreeId}
nodeId={nodes.id}
label={nodes.name}
className="linked-tree-item"
>
{Array.isArray(nodes.children)
? nodes.children.map((node: RenderTree) => toTree(node, showQname))
: null}
</TreeItem>
{nodes.map((node: RenderTree) => toTree(node, showQname))}
</TreeView>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export default function NodeInfo(props: {
)}
{props.isNodeEditable &&
selectedNode &&
selectedNode?.elementPath !== 'ROOT' &&
!isLeafNode &&
!props.hasCustomRoot && (
<Button
Expand Down
Loading

0 comments on commit 62cd6fc

Please sign in to comment.