Skip to content

Commit d1abe66

Browse files
DHFPROD-8070: Fix for the issue where large number of new nodes were being arranged as a circle
1 parent d88a920 commit d1abe66

File tree

1 file changed

+13
-9
lines changed
  • marklogic-data-hub-central/ui/src/components/modeling/graph-view/graph-vis

1 file changed

+13
-9
lines changed

marklogic-data-hub-central/ui/src/components/modeling/graph-view/graph-vis/graph-vis.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ const GraphVis: React.FC<Props> = (props) => {
4444
const {modelingOptions, setSelectedEntity} = useContext(ModelingContext);
4545

4646
const entitiesConfigExist = () => {
47-
return !props.hubCentralConfig?.modeling?.entities ? false : true;
47+
return !props.hubCentralConfig?.modeling?.entities ? false : (!Object.keys(props.hubCentralConfig?.modeling?.entities).length ? false : true);
4848
};
4949

5050
const coordinatesExist = () => {
51-
let coordsExist = false;
51+
let coordsExist = true;
5252
if (entitiesConfigExist()) {
5353
let allEntityCoordinates = props.hubCentralConfig["modeling"]["entities"];
54-
for (const entity of Object.keys(allEntityCoordinates)) {
55-
if (allEntityCoordinates[entity]) {
56-
if (allEntityCoordinates[entity].graphX && allEntityCoordinates[entity].graphY) {
57-
coordsExist = true;
58-
break;
59-
}
54+
for (const entity of props.entityTypes) {
55+
if (!allEntityCoordinates[entity.entityName]) {
56+
coordsExist = false;
57+
break;
6058
}
6159
}
60+
} else {
61+
coordsExist = false;
6262
}
6363
return coordsExist;
6464
};
@@ -145,6 +145,10 @@ const GraphVis: React.FC<Props> = (props) => {
145145
if (physicsEnabled) {
146146
setPhysicsEnabled(false);
147147
}
148+
} else {
149+
if (!physicsEnabled) {
150+
setPhysicsEnabled(true);
151+
}
148152
}
149153

150154
setGraphData({
@@ -726,7 +730,7 @@ const GraphVis: React.FC<Props> = (props) => {
726730
if (network) {
727731
let positions = network.getPositions();
728732
// When graph is stabilized, nodePositions no longer empty
729-
if (positions && Object.keys(positions).length && !Object.keys(coords).length) {
733+
if (positions && Object.keys(positions).length) {
730734
saveUnsavedCoords();
731735
setHasStabilized(true);
732736
if (physicsEnabled) {

0 commit comments

Comments
 (0)