You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "Code-breaker1998 (via GitHub)" <gi...@apache.org> on 2024/03/12 10:27:17 UTC
[PR] issue: Resolve issue related to autolayout in seata-statemachine-desi… [incubator-seata]
Code-breaker1998 opened a new pull request, #6415:
URL: https://github.com/apache/incubator-seata/pull/6415
…gner
<!-- Please make sure you have read and understood the contributing guidelines -->
- [ ] I have registered the PR [changes](../changes).
### Ⅰ. Describe what this PR did
These PR resolve the issue of autolayout in apache seata statemachine diagram
### Ⅱ. Does this pull request fix one issue?
<!-- If that, add "fixes #xxx" below in the next line, for example, fixes #97. -->
fixes #6136
### Ⅲ. Why don't you add test cases (unit test/integration test)?
following are the test cases under which I perform testing
[sega1.json](https://github.com/apache/incubator-seata/files/14570725/sega1.json)
[sega2.json](https://github.com/apache/incubator-seata/files/14570726/sega2.json)
[sega3.json](https://github.com/apache/incubator-seata/files/14570727/sega3.json)
[sega4.json](https://github.com/apache/incubator-seata/files/14570758/sega4.json)
[StateMachine-6grdofu.json](https://github.com/apache/incubator-seata/files/14570759/StateMachine-6grdofu.json)
### Ⅳ. Describe how to verify it
Click on import option , select the file which does not contain property like style,edge and waypoints . check whether they are able to import in statemachine diagram
### Ⅴ. Special notes for reviews
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1998980321
@Code-breaker1998 Hi, are you working on it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on code in PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#discussion_r1525840676
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
@@ -24,9 +24,381 @@ export default class Node extends BaseSpec {
style = new NodeStyle();
importJson(json) {
+ if (json.style === undefined) {
+ json.style = {};
+ json.style.bounds = {
+ x: 200,
+ y: 200,
+ width: 36,
+ height: 36,
+ };
+ }
assign(this.style.bounds, json.style.bounds);
}
+ isElementPresent(visited, target) {
+ for (const element of visited) {
+ if (element[0] === target[0] && element[1] === target[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ ) {
+ const sourceX = definitions.States[source].style.bounds.x;
+ const sourceY = definitions.States[source].style.bounds.y;
+ const targetX = definitions.States[target].style.bounds.x;
+ const targetY = definitions.States[target].style.bounds.y;
+ let waypoints1 = [];
+ if (type === 'Transition') {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ } else if (type === 'Compensation') {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceX === targetX) {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceY === targetY) {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ }
+
+ return {
+ style: {
+ waypoints: waypoints1,
+ source,
+ target,
+ },
+ Type: type,
+ };
+ }
+
+ importEdges(definitions, startState) {
+ if (startState.Next) {
+ this.addEdge(startState.Name, startState.Next, definitions, 'Transition', startState);
+ }
+
+ if (startState.CompensateState) {
+ this.addEdge(startState.Name, startState.CompensateState, definitions, 'Compensation', startState);
+ }
+
+ if (startState.Choices) {
+ for (const option of startState.Choices) {
+ this.addEdge(startState.Name, option.Next, definitions, 'ChoiceEntry', startState);
+ }
+ }
+
+ this.importJson(startState);
+ }
+
+ addEdge(source, target, definitions, type, startState) {
+ const sourceWidth = this.calculateWidth(definitions.States[source]);
+ const sourceHeight = this.calculateHeight(definitions.States[source]);
+ const targetWidth = this.calculateWidth(definitions.States[target]);
+ const targetHeight = this.calculateHeight(definitions.States[target]);
+
+ const elementJson = this.addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ );
+ startState.edge = Object.assign(startState.edge || {}, { [target]: elementJson });
+ }
+
+ calculateWidth(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 100 : 36;
+ }
+
+ calculateHeight(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 80 : 36;
+ }
+
+ importJsonEdges(json) {
+ if (json.States) {
+ const targetX = json.States[json.StartState].style.bounds.x;
+ const targetY = json.States[json.StartState].style.bounds.y;
+ json.edge = {
+ style: {
+ waypoints: [{
+ x: 200 + 36,
+ y: 200 + 18,
+ }, {
+ x: targetX - 20,
+ y: targetY + 40,
+ }, {
+ x: targetX,
+ y: targetY + 40,
+ }],
+ target: json.StartState,
+ },
+ Type: 'Transition',
+ };
+ }
+ this.importJson(json);
+ }
+
+ importCatchesEdges(definitions, startState) {
+ const catchEdges = startState.Catch;
+ for (const option of catchEdges) {
+ const sourceX = definitions.States[startState.Name].catch.style.bounds.x;
+ const sourceY = definitions.States[startState.Name].catch.style.bounds.y;
+ const targetX = definitions.States[option.Next].style.bounds.x;
+ const targetY = definitions.States[option.Next].style.bounds.y;
+ let waypoints1 = [];
+ if ((definitions.States[option.Next].Type === 'ServiceTask')
+ || (definitions.States[option.Next].Type === 'ScriptTask')
+ || (definitions.States[option.Next].Type === 'SubStateMachine')) {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 50,
+ y: targetY + 100,
+ }, {
+ x: targetX + 50,
+ y: (targetY + 100) - 20,
+ }];
+ } else {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 18,
+ y: (targetY + 36) + 20,
+ }, {
+ x: targetX + 18,
+ y: targetY + 36,
+ }];
+ }
+ startState.catch.edge = assign(startState.catch.edge || {}, {
+ [option.Next]: {
+ style: {
+ waypoints: waypoints1,
+ source: startState.Name,
+ target: option.Next,
+ },
+ Type: 'ExceptionMatch',
+ },
+ });
+ }
+ this.importJson(startState.catch);
+ }
+
+ addCatch(definitions, node, catchList, adjList) {
+ node.catch = {};
+ if (node.Catch) {
+ const {
+ style: {
+ bounds: {
+ x,
+ y,
+ },
+ },
+ } = node;
+ const newX = x;
+ const newY = y;
+ node.catch.style = {};
+ node.catch.style.bounds = {
+ x: newX + 50,
+ y: newY - 20,
+ width: 36,
+ height: 36,
+ };
+ }
+ this.importJson(node.catch);
+
+ let prev = node.catch;
+ let width1;
+ let height1;
+ catchList.get(node).forEach((semantic) => {
+ if ((semantic.Type === 'ServiceTask') || (semantic.Type === 'ScriptTask') || (semantic.Type === 'SubStateMachine')) {
+ width1 = 100;
+ height1 = 80;
+ } else {
+ width1 = 36;
+ height1 = 36;
+ }
+ semantic.style = {};
+ semantic.style.bounds = {
+ x: prev.style.bounds.x - 50,
+ y: prev.style.bounds.y - 100,
+ width: width1,
+ height: height1,
+ };
+ prev = semantic;
+
+ this.importStates(definitions, semantic, null, adjList);
+ });
+ }
+
+ importStates(definitions, startState, begin, adjList) {
+ const visited = [];
+ const queue = [];
+ if (begin !== null) {
+ if (startState.style === undefined) {
+ startState.style = {};
+ if (startState.style.bounds === undefined) {
+ startState.style.bounds = {
+ x: begin.style.bounds.x + 150, // Adjust x-coordinate
+ y: begin.style.bounds.y, // Adjust y-coordinate
+ width: 100,
+ height: 80,
+ };
+ }
+ }
+ this.importJson(startState);
+ }
+ queue.push(startState);
+
+ function setBounds(neighbor, x, y, width1, height1) {
+ if (neighbor.style.bounds === undefined) {
+ neighbor.style.bounds = {
+ x, // Adjust x-coordinate
+ y, // Adjust y-coordinate
+ width: width1,
+ height: height1,
+ };
+ visited.push([x, y]);
+ }
+ }
+
+ while (queue.length) {
+ const currentState = queue.shift();
+
+ adjList.get(currentState).forEach((neighbor) => {
+ if (neighbor.style === undefined) {
+ neighbor.style = {};
+ if ((neighbor.Type === 'Fail') || (neighbor.Type === 'Succeed')) {
Review Comment:
Here we cant use is function as it has only three conditions related to task
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] issue: Resolve issue related to autolayout in seata-statemachine-desi… [incubator-seata]
Posted by "liuqiufeng (via GitHub)" <gi...@apache.org>.
liuqiufeng commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1991346816
plz ignore .
> should i submit new PR or Will be fine with these...
可以直接在关联分支上改,提交后pr会同步生效
You can change it directly on the associated branch, and pr will be synchronized after the commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin merged PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on code in PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#discussion_r1523548140
##########
saga/seata-saga-statemachine-designer/package-lock.json:
##########
Review Comment:
You deleted this file in the PR. We need it back.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] issue: Resolve issue related to autolayout in seata-statemachine-desi… [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1991342519
should i submit new PR or Will be fine with these...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1999454783
@ptyin , done with the changes , please go through it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] issue: Resolve issue related to autolayout in seata-statemachine-desi… [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1991331749
@ptyin ,
Can you go through this PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] issue: Resolve issue related to autolayout in seata-statemachine-desi… [incubator-seata]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1991395074
## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/6415?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 50.46%. Comparing base [(`f93a721`)](https://app.codecov.io/gh/apache/incubator-seata/commit/f93a721c997d4e1d8021905e0b1f13e2dade6284?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`b52d4e2`)](https://app.codecov.io/gh/apache/incubator-seata/pull/6415?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> :exclamation: Current head b52d4e2 differs from pull request most recent head 0d506ce. Consider uploading reports for the commit 0d506ce to get more accurate results
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/incubator-seata/pull/6415?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## 2.x #6415 +/- ##
============================================
+ Coverage 50.43% 50.46% +0.03%
- Complexity 5253 5259 +6
============================================
Files 941 941
Lines 33279 33279
Branches 4035 4035
============================================
+ Hits 16783 16794 +11
+ Misses 14871 14867 -4
+ Partials 1625 1618 -7
```
[see 4 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/6415/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on code in PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#discussion_r1523560680
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
@@ -24,9 +24,381 @@ export default class Node extends BaseSpec {
style = new NodeStyle();
importJson(json) {
+ if (json.style === undefined) {
+ json.style = {};
+ json.style.bounds = {
+ x: 200,
+ y: 200,
+ width: 36,
+ height: 36,
+ };
+ }
assign(this.style.bounds, json.style.bounds);
}
+ isElementPresent(visited, target) {
+ for (const element of visited) {
+ if (element[0] === target[0] && element[1] === target[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ ) {
+ const sourceX = definitions.States[source].style.bounds.x;
+ const sourceY = definitions.States[source].style.bounds.y;
+ const targetX = definitions.States[target].style.bounds.x;
+ const targetY = definitions.States[target].style.bounds.y;
+ let waypoints1 = [];
+ if (type === 'Transition') {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ } else if (type === 'Compensation') {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceX === targetX) {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceY === targetY) {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ }
+
+ return {
+ style: {
+ waypoints: waypoints1,
+ source,
+ target,
+ },
+ Type: type,
+ };
+ }
+
+ importEdges(definitions, startState) {
+ if (startState.Next) {
+ this.addEdge(startState.Name, startState.Next, definitions, 'Transition', startState);
+ }
+
+ if (startState.CompensateState) {
+ this.addEdge(startState.Name, startState.CompensateState, definitions, 'Compensation', startState);
+ }
+
+ if (startState.Choices) {
+ for (const option of startState.Choices) {
+ this.addEdge(startState.Name, option.Next, definitions, 'ChoiceEntry', startState);
+ }
+ }
+
+ this.importJson(startState);
+ }
+
+ addEdge(source, target, definitions, type, startState) {
+ const sourceWidth = this.calculateWidth(definitions.States[source]);
+ const sourceHeight = this.calculateHeight(definitions.States[source]);
+ const targetWidth = this.calculateWidth(definitions.States[target]);
+ const targetHeight = this.calculateHeight(definitions.States[target]);
+
+ const elementJson = this.addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ );
+ startState.edge = Object.assign(startState.edge || {}, { [target]: elementJson });
+ }
+
+ calculateWidth(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 100 : 36;
+ }
+
+ calculateHeight(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 80 : 36;
+ }
+
+ importJsonEdges(json) {
+ if (json.States) {
+ const targetX = json.States[json.StartState].style.bounds.x;
+ const targetY = json.States[json.StartState].style.bounds.y;
+ json.edge = {
+ style: {
+ waypoints: [{
+ x: 200 + 36,
+ y: 200 + 18,
+ }, {
+ x: targetX - 20,
+ y: targetY + 40,
+ }, {
+ x: targetX,
+ y: targetY + 40,
+ }],
+ target: json.StartState,
+ },
+ Type: 'Transition',
+ };
+ }
+ this.importJson(json);
+ }
+
+ importCatchesEdges(definitions, startState) {
+ const catchEdges = startState.Catch;
+ for (const option of catchEdges) {
+ const sourceX = definitions.States[startState.Name].catch.style.bounds.x;
+ const sourceY = definitions.States[startState.Name].catch.style.bounds.y;
+ const targetX = definitions.States[option.Next].style.bounds.x;
+ const targetY = definitions.States[option.Next].style.bounds.y;
+ let waypoints1 = [];
+ if ((definitions.States[option.Next].Type === 'ServiceTask')
+ || (definitions.States[option.Next].Type === 'ScriptTask')
+ || (definitions.States[option.Next].Type === 'SubStateMachine')) {
Review Comment:
Use `is(state, 'Task')` from utills to substitute the conditions.
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
@@ -24,9 +24,381 @@ export default class Node extends BaseSpec {
style = new NodeStyle();
importJson(json) {
+ if (json.style === undefined) {
+ json.style = {};
+ json.style.bounds = {
+ x: 200,
+ y: 200,
+ width: 36,
+ height: 36,
+ };
+ }
assign(this.style.bounds, json.style.bounds);
}
+ isElementPresent(visited, target) {
+ for (const element of visited) {
+ if (element[0] === target[0] && element[1] === target[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ ) {
+ const sourceX = definitions.States[source].style.bounds.x;
+ const sourceY = definitions.States[source].style.bounds.y;
+ const targetX = definitions.States[target].style.bounds.x;
+ const targetY = definitions.States[target].style.bounds.y;
+ let waypoints1 = [];
+ if (type === 'Transition') {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ } else if (type === 'Compensation') {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceX === targetX) {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceY === targetY) {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ }
+
+ return {
+ style: {
+ waypoints: waypoints1,
+ source,
+ target,
+ },
+ Type: type,
+ };
+ }
+
+ importEdges(definitions, startState) {
+ if (startState.Next) {
+ this.addEdge(startState.Name, startState.Next, definitions, 'Transition', startState);
+ }
+
+ if (startState.CompensateState) {
+ this.addEdge(startState.Name, startState.CompensateState, definitions, 'Compensation', startState);
+ }
+
+ if (startState.Choices) {
+ for (const option of startState.Choices) {
+ this.addEdge(startState.Name, option.Next, definitions, 'ChoiceEntry', startState);
+ }
+ }
+
+ this.importJson(startState);
+ }
+
+ addEdge(source, target, definitions, type, startState) {
+ const sourceWidth = this.calculateWidth(definitions.States[source]);
+ const sourceHeight = this.calculateHeight(definitions.States[source]);
+ const targetWidth = this.calculateWidth(definitions.States[target]);
+ const targetHeight = this.calculateHeight(definitions.States[target]);
+
+ const elementJson = this.addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ );
+ startState.edge = Object.assign(startState.edge || {}, { [target]: elementJson });
+ }
+
+ calculateWidth(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 100 : 36;
+ }
+
+ calculateHeight(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 80 : 36;
+ }
+
+ importJsonEdges(json) {
+ if (json.States) {
+ const targetX = json.States[json.StartState].style.bounds.x;
+ const targetY = json.States[json.StartState].style.bounds.y;
+ json.edge = {
+ style: {
+ waypoints: [{
+ x: 200 + 36,
+ y: 200 + 18,
+ }, {
+ x: targetX - 20,
+ y: targetY + 40,
+ }, {
+ x: targetX,
+ y: targetY + 40,
+ }],
+ target: json.StartState,
+ },
+ Type: 'Transition',
+ };
+ }
+ this.importJson(json);
+ }
+
+ importCatchesEdges(definitions, startState) {
+ const catchEdges = startState.Catch;
+ for (const option of catchEdges) {
+ const sourceX = definitions.States[startState.Name].catch.style.bounds.x;
+ const sourceY = definitions.States[startState.Name].catch.style.bounds.y;
+ const targetX = definitions.States[option.Next].style.bounds.x;
+ const targetY = definitions.States[option.Next].style.bounds.y;
+ let waypoints1 = [];
+ if ((definitions.States[option.Next].Type === 'ServiceTask')
+ || (definitions.States[option.Next].Type === 'ScriptTask')
+ || (definitions.States[option.Next].Type === 'SubStateMachine')) {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 50,
+ y: targetY + 100,
+ }, {
+ x: targetX + 50,
+ y: (targetY + 100) - 20,
+ }];
+ } else {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 18,
+ y: (targetY + 36) + 20,
+ }, {
+ x: targetX + 18,
+ y: targetY + 36,
+ }];
+ }
+ startState.catch.edge = assign(startState.catch.edge || {}, {
+ [option.Next]: {
+ style: {
+ waypoints: waypoints1,
+ source: startState.Name,
+ target: option.Next,
+ },
+ Type: 'ExceptionMatch',
+ },
+ });
+ }
+ this.importJson(startState.catch);
+ }
+
+ addCatch(definitions, node, catchList, adjList) {
+ node.catch = {};
+ if (node.Catch) {
+ const {
+ style: {
+ bounds: {
+ x,
+ y,
+ },
+ },
+ } = node;
+ const newX = x;
+ const newY = y;
+ node.catch.style = {};
+ node.catch.style.bounds = {
+ x: newX + 50,
+ y: newY - 20,
+ width: 36,
+ height: 36,
+ };
+ }
+ this.importJson(node.catch);
+
+ let prev = node.catch;
+ let width1;
+ let height1;
+ catchList.get(node).forEach((semantic) => {
+ if ((semantic.Type === 'ServiceTask') || (semantic.Type === 'ScriptTask') || (semantic.Type === 'SubStateMachine')) {
+ width1 = 100;
+ height1 = 80;
+ } else {
+ width1 = 36;
+ height1 = 36;
+ }
+ semantic.style = {};
+ semantic.style.bounds = {
+ x: prev.style.bounds.x - 50,
+ y: prev.style.bounds.y - 100,
+ width: width1,
+ height: height1,
+ };
+ prev = semantic;
+
+ this.importStates(definitions, semantic, null, adjList);
+ });
+ }
+
+ importStates(definitions, startState, begin, adjList) {
+ const visited = [];
+ const queue = [];
+ if (begin !== null) {
+ if (startState.style === undefined) {
+ startState.style = {};
+ if (startState.style.bounds === undefined) {
+ startState.style.bounds = {
+ x: begin.style.bounds.x + 150, // Adjust x-coordinate
+ y: begin.style.bounds.y, // Adjust y-coordinate
+ width: 100,
+ height: 80,
+ };
+ }
+ }
+ this.importJson(startState);
+ }
+ queue.push(startState);
+
+ function setBounds(neighbor, x, y, width1, height1) {
+ if (neighbor.style.bounds === undefined) {
+ neighbor.style.bounds = {
+ x, // Adjust x-coordinate
+ y, // Adjust y-coordinate
+ width: width1,
+ height: height1,
+ };
+ visited.push([x, y]);
+ }
+ }
+
+ while (queue.length) {
+ const currentState = queue.shift();
+
+ adjList.get(currentState).forEach((neighbor) => {
+ if (neighbor.style === undefined) {
+ neighbor.style = {};
+ if ((neighbor.Type === 'Fail') || (neighbor.Type === 'Succeed')) {
+ const target = [];
+ target.push(currentState.style.bounds.x + 150, currentState.style.bounds.y);
+ if (this.isElementPresent(visited, target)) {
+ setBounds(
+ neighbor,
+ currentState.style.bounds.x + 150,
+ currentState.style.bounds.y,
+ 36,
+ 36,
+ );
+ } else {
+ setBounds(
+ neighbor,
+ currentState.style.bounds.x,
+ currentState.style.bounds.y + 150,
+ 36,
+ 36,
+ );
+ }
+ }
+
+ if ((neighbor.Type === 'ServiceTask' && !neighbor.IsForCompensation) || (neighbor.Type === 'ScriptTask' && !neighbor.IsForCompensation) || (neighbor.Type === 'SubStateMachine' && !neighbor.IsForCompensation)) {
Review Comment:
Use `is(neighbor, 'Task') && !neighbor.IsForCompensate`.
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
@@ -24,9 +24,381 @@ export default class Node extends BaseSpec {
style = new NodeStyle();
importJson(json) {
+ if (json.style === undefined) {
+ json.style = {};
+ json.style.bounds = {
+ x: 200,
+ y: 200,
+ width: 36,
+ height: 36,
+ };
+ }
assign(this.style.bounds, json.style.bounds);
}
+ isElementPresent(visited, target) {
+ for (const element of visited) {
+ if (element[0] === target[0] && element[1] === target[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ ) {
+ const sourceX = definitions.States[source].style.bounds.x;
+ const sourceY = definitions.States[source].style.bounds.y;
+ const targetX = definitions.States[target].style.bounds.x;
+ const targetY = definitions.States[target].style.bounds.y;
+ let waypoints1 = [];
+ if (type === 'Transition') {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ } else if (type === 'Compensation') {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceX === targetX) {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceY === targetY) {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ }
+
+ return {
+ style: {
+ waypoints: waypoints1,
+ source,
+ target,
+ },
+ Type: type,
+ };
+ }
+
+ importEdges(definitions, startState) {
+ if (startState.Next) {
+ this.addEdge(startState.Name, startState.Next, definitions, 'Transition', startState);
+ }
+
+ if (startState.CompensateState) {
+ this.addEdge(startState.Name, startState.CompensateState, definitions, 'Compensation', startState);
+ }
+
+ if (startState.Choices) {
+ for (const option of startState.Choices) {
+ this.addEdge(startState.Name, option.Next, definitions, 'ChoiceEntry', startState);
+ }
+ }
+
+ this.importJson(startState);
+ }
+
+ addEdge(source, target, definitions, type, startState) {
+ const sourceWidth = this.calculateWidth(definitions.States[source]);
+ const sourceHeight = this.calculateHeight(definitions.States[source]);
+ const targetWidth = this.calculateWidth(definitions.States[target]);
+ const targetHeight = this.calculateHeight(definitions.States[target]);
+
+ const elementJson = this.addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ );
+ startState.edge = Object.assign(startState.edge || {}, { [target]: elementJson });
+ }
+
+ calculateWidth(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 100 : 36;
+ }
+
+ calculateHeight(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 80 : 36;
Review Comment:
Use `state.DEFAULT_SIZE.height` to replace this one.
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
@@ -24,9 +24,381 @@ export default class Node extends BaseSpec {
style = new NodeStyle();
importJson(json) {
+ if (json.style === undefined) {
+ json.style = {};
+ json.style.bounds = {
+ x: 200,
+ y: 200,
+ width: 36,
+ height: 36,
+ };
+ }
assign(this.style.bounds, json.style.bounds);
}
+ isElementPresent(visited, target) {
+ for (const element of visited) {
+ if (element[0] === target[0] && element[1] === target[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ ) {
+ const sourceX = definitions.States[source].style.bounds.x;
+ const sourceY = definitions.States[source].style.bounds.y;
+ const targetX = definitions.States[target].style.bounds.x;
+ const targetY = definitions.States[target].style.bounds.y;
+ let waypoints1 = [];
+ if (type === 'Transition') {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ } else if (type === 'Compensation') {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceX === targetX) {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceY === targetY) {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ }
+
+ return {
+ style: {
+ waypoints: waypoints1,
+ source,
+ target,
+ },
+ Type: type,
+ };
+ }
+
+ importEdges(definitions, startState) {
+ if (startState.Next) {
+ this.addEdge(startState.Name, startState.Next, definitions, 'Transition', startState);
+ }
+
+ if (startState.CompensateState) {
+ this.addEdge(startState.Name, startState.CompensateState, definitions, 'Compensation', startState);
+ }
+
+ if (startState.Choices) {
+ for (const option of startState.Choices) {
+ this.addEdge(startState.Name, option.Next, definitions, 'ChoiceEntry', startState);
+ }
+ }
+
+ this.importJson(startState);
+ }
+
+ addEdge(source, target, definitions, type, startState) {
+ const sourceWidth = this.calculateWidth(definitions.States[source]);
+ const sourceHeight = this.calculateHeight(definitions.States[source]);
+ const targetWidth = this.calculateWidth(definitions.States[target]);
+ const targetHeight = this.calculateHeight(definitions.States[target]);
+
+ const elementJson = this.addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ );
+ startState.edge = Object.assign(startState.edge || {}, { [target]: elementJson });
+ }
+
+ calculateWidth(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 100 : 36;
+ }
+
+ calculateHeight(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 80 : 36;
+ }
+
+ importJsonEdges(json) {
+ if (json.States) {
+ const targetX = json.States[json.StartState].style.bounds.x;
+ const targetY = json.States[json.StartState].style.bounds.y;
+ json.edge = {
+ style: {
+ waypoints: [{
+ x: 200 + 36,
+ y: 200 + 18,
+ }, {
+ x: targetX - 20,
+ y: targetY + 40,
+ }, {
+ x: targetX,
+ y: targetY + 40,
Review Comment:
Can you make these literals be constants respectively? Declare them above.
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
@@ -24,9 +24,381 @@ export default class Node extends BaseSpec {
style = new NodeStyle();
importJson(json) {
+ if (json.style === undefined) {
+ json.style = {};
+ json.style.bounds = {
+ x: 200,
+ y: 200,
+ width: 36,
+ height: 36,
+ };
+ }
assign(this.style.bounds, json.style.bounds);
}
+ isElementPresent(visited, target) {
+ for (const element of visited) {
+ if (element[0] === target[0] && element[1] === target[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ ) {
+ const sourceX = definitions.States[source].style.bounds.x;
+ const sourceY = definitions.States[source].style.bounds.y;
+ const targetX = definitions.States[target].style.bounds.x;
+ const targetY = definitions.States[target].style.bounds.y;
+ let waypoints1 = [];
+ if (type === 'Transition') {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ } else if (type === 'Compensation') {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceX === targetX) {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceY === targetY) {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ }
+
+ return {
+ style: {
+ waypoints: waypoints1,
+ source,
+ target,
+ },
+ Type: type,
+ };
+ }
+
+ importEdges(definitions, startState) {
+ if (startState.Next) {
+ this.addEdge(startState.Name, startState.Next, definitions, 'Transition', startState);
+ }
+
+ if (startState.CompensateState) {
+ this.addEdge(startState.Name, startState.CompensateState, definitions, 'Compensation', startState);
+ }
+
+ if (startState.Choices) {
+ for (const option of startState.Choices) {
+ this.addEdge(startState.Name, option.Next, definitions, 'ChoiceEntry', startState);
+ }
+ }
+
+ this.importJson(startState);
+ }
+
+ addEdge(source, target, definitions, type, startState) {
+ const sourceWidth = this.calculateWidth(definitions.States[source]);
+ const sourceHeight = this.calculateHeight(definitions.States[source]);
+ const targetWidth = this.calculateWidth(definitions.States[target]);
+ const targetHeight = this.calculateHeight(definitions.States[target]);
+
+ const elementJson = this.addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ );
+ startState.edge = Object.assign(startState.edge || {}, { [target]: elementJson });
+ }
+
+ calculateWidth(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 100 : 36;
+ }
+
+ calculateHeight(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 80 : 36;
+ }
+
+ importJsonEdges(json) {
+ if (json.States) {
+ const targetX = json.States[json.StartState].style.bounds.x;
+ const targetY = json.States[json.StartState].style.bounds.y;
+ json.edge = {
+ style: {
+ waypoints: [{
+ x: 200 + 36,
+ y: 200 + 18,
+ }, {
+ x: targetX - 20,
+ y: targetY + 40,
+ }, {
+ x: targetX,
+ y: targetY + 40,
+ }],
+ target: json.StartState,
+ },
+ Type: 'Transition',
+ };
+ }
+ this.importJson(json);
+ }
+
+ importCatchesEdges(definitions, startState) {
+ const catchEdges = startState.Catch;
+ for (const option of catchEdges) {
+ const sourceX = definitions.States[startState.Name].catch.style.bounds.x;
+ const sourceY = definitions.States[startState.Name].catch.style.bounds.y;
+ const targetX = definitions.States[option.Next].style.bounds.x;
+ const targetY = definitions.States[option.Next].style.bounds.y;
+ let waypoints1 = [];
+ if ((definitions.States[option.Next].Type === 'ServiceTask')
+ || (definitions.States[option.Next].Type === 'ScriptTask')
+ || (definitions.States[option.Next].Type === 'SubStateMachine')) {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 50,
+ y: targetY + 100,
+ }, {
+ x: targetX + 50,
+ y: (targetY + 100) - 20,
+ }];
+ } else {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 18,
+ y: (targetY + 36) + 20,
+ }, {
+ x: targetX + 18,
+ y: targetY + 36,
+ }];
+ }
+ startState.catch.edge = assign(startState.catch.edge || {}, {
+ [option.Next]: {
+ style: {
+ waypoints: waypoints1,
+ source: startState.Name,
+ target: option.Next,
+ },
+ Type: 'ExceptionMatch',
+ },
+ });
+ }
+ this.importJson(startState.catch);
+ }
+
+ addCatch(definitions, node, catchList, adjList) {
+ node.catch = {};
+ if (node.Catch) {
+ const {
+ style: {
+ bounds: {
+ x,
+ y,
+ },
+ },
+ } = node;
+ const newX = x;
+ const newY = y;
+ node.catch.style = {};
+ node.catch.style.bounds = {
+ x: newX + 50,
+ y: newY - 20,
+ width: 36,
+ height: 36,
+ };
+ }
+ this.importJson(node.catch);
+
+ let prev = node.catch;
+ let width1;
+ let height1;
+ catchList.get(node).forEach((semantic) => {
+ if ((semantic.Type === 'ServiceTask') || (semantic.Type === 'ScriptTask') || (semantic.Type === 'SubStateMachine')) {
+ width1 = 100;
+ height1 = 80;
+ } else {
+ width1 = 36;
+ height1 = 36;
+ }
+ semantic.style = {};
+ semantic.style.bounds = {
+ x: prev.style.bounds.x - 50,
+ y: prev.style.bounds.y - 100,
+ width: width1,
+ height: height1,
+ };
+ prev = semantic;
+
+ this.importStates(definitions, semantic, null, adjList);
+ });
+ }
+
+ importStates(definitions, startState, begin, adjList) {
+ const visited = [];
+ const queue = [];
+ if (begin !== null) {
+ if (startState.style === undefined) {
+ startState.style = {};
+ if (startState.style.bounds === undefined) {
+ startState.style.bounds = {
+ x: begin.style.bounds.x + 150, // Adjust x-coordinate
+ y: begin.style.bounds.y, // Adjust y-coordinate
+ width: 100,
+ height: 80,
+ };
+ }
+ }
+ this.importJson(startState);
+ }
+ queue.push(startState);
+
+ function setBounds(neighbor, x, y, width1, height1) {
+ if (neighbor.style.bounds === undefined) {
+ neighbor.style.bounds = {
+ x, // Adjust x-coordinate
+ y, // Adjust y-coordinate
+ width: width1,
+ height: height1,
+ };
+ visited.push([x, y]);
+ }
+ }
+
+ while (queue.length) {
+ const currentState = queue.shift();
+
+ adjList.get(currentState).forEach((neighbor) => {
+ if (neighbor.style === undefined) {
+ neighbor.style = {};
+ if ((neighbor.Type === 'Fail') || (neighbor.Type === 'Succeed')) {
Review Comment:
Use `is`
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
@@ -24,9 +24,381 @@ export default class Node extends BaseSpec {
style = new NodeStyle();
importJson(json) {
+ if (json.style === undefined) {
+ json.style = {};
+ json.style.bounds = {
+ x: 200,
+ y: 200,
+ width: 36,
+ height: 36,
+ };
+ }
assign(this.style.bounds, json.style.bounds);
}
+ isElementPresent(visited, target) {
+ for (const element of visited) {
+ if (element[0] === target[0] && element[1] === target[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ ) {
+ const sourceX = definitions.States[source].style.bounds.x;
+ const sourceY = definitions.States[source].style.bounds.y;
+ const targetX = definitions.States[target].style.bounds.x;
+ const targetY = definitions.States[target].style.bounds.y;
+ let waypoints1 = [];
+ if (type === 'Transition') {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ } else if (type === 'Compensation') {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceX === targetX) {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceY === targetY) {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ }
+
+ return {
+ style: {
+ waypoints: waypoints1,
+ source,
+ target,
+ },
+ Type: type,
+ };
+ }
+
+ importEdges(definitions, startState) {
+ if (startState.Next) {
+ this.addEdge(startState.Name, startState.Next, definitions, 'Transition', startState);
+ }
+
+ if (startState.CompensateState) {
+ this.addEdge(startState.Name, startState.CompensateState, definitions, 'Compensation', startState);
+ }
+
+ if (startState.Choices) {
+ for (const option of startState.Choices) {
+ this.addEdge(startState.Name, option.Next, definitions, 'ChoiceEntry', startState);
+ }
+ }
+
+ this.importJson(startState);
+ }
+
+ addEdge(source, target, definitions, type, startState) {
+ const sourceWidth = this.calculateWidth(definitions.States[source]);
+ const sourceHeight = this.calculateHeight(definitions.States[source]);
+ const targetWidth = this.calculateWidth(definitions.States[target]);
+ const targetHeight = this.calculateHeight(definitions.States[target]);
+
+ const elementJson = this.addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ );
+ startState.edge = Object.assign(startState.edge || {}, { [target]: elementJson });
+ }
+
+ calculateWidth(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 100 : 36;
Review Comment:
Just use `state.DEFAULT_SIZE.width` to replace the statment.
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
@@ -24,9 +24,381 @@ export default class Node extends BaseSpec {
style = new NodeStyle();
importJson(json) {
+ if (json.style === undefined) {
+ json.style = {};
+ json.style.bounds = {
+ x: 200,
+ y: 200,
+ width: 36,
+ height: 36,
+ };
+ }
assign(this.style.bounds, json.style.bounds);
}
+ isElementPresent(visited, target) {
+ for (const element of visited) {
+ if (element[0] === target[0] && element[1] === target[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ ) {
+ const sourceX = definitions.States[source].style.bounds.x;
+ const sourceY = definitions.States[source].style.bounds.y;
+ const targetX = definitions.States[target].style.bounds.x;
+ const targetY = definitions.States[target].style.bounds.y;
+ let waypoints1 = [];
+ if (type === 'Transition') {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ } else if (type === 'Compensation') {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceX === targetX) {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceY === targetY) {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ }
+
+ return {
+ style: {
+ waypoints: waypoints1,
+ source,
+ target,
+ },
+ Type: type,
+ };
+ }
+
+ importEdges(definitions, startState) {
+ if (startState.Next) {
+ this.addEdge(startState.Name, startState.Next, definitions, 'Transition', startState);
+ }
+
+ if (startState.CompensateState) {
+ this.addEdge(startState.Name, startState.CompensateState, definitions, 'Compensation', startState);
+ }
+
+ if (startState.Choices) {
+ for (const option of startState.Choices) {
+ this.addEdge(startState.Name, option.Next, definitions, 'ChoiceEntry', startState);
+ }
+ }
+
+ this.importJson(startState);
+ }
+
+ addEdge(source, target, definitions, type, startState) {
+ const sourceWidth = this.calculateWidth(definitions.States[source]);
+ const sourceHeight = this.calculateHeight(definitions.States[source]);
+ const targetWidth = this.calculateWidth(definitions.States[target]);
+ const targetHeight = this.calculateHeight(definitions.States[target]);
+
+ const elementJson = this.addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ );
+ startState.edge = Object.assign(startState.edge || {}, { [target]: elementJson });
+ }
+
+ calculateWidth(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 100 : 36;
+ }
+
+ calculateHeight(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 80 : 36;
+ }
+
+ importJsonEdges(json) {
+ if (json.States) {
+ const targetX = json.States[json.StartState].style.bounds.x;
+ const targetY = json.States[json.StartState].style.bounds.y;
+ json.edge = {
+ style: {
+ waypoints: [{
+ x: 200 + 36,
+ y: 200 + 18,
+ }, {
+ x: targetX - 20,
+ y: targetY + 40,
+ }, {
+ x: targetX,
+ y: targetY + 40,
+ }],
+ target: json.StartState,
+ },
+ Type: 'Transition',
+ };
+ }
+ this.importJson(json);
+ }
+
+ importCatchesEdges(definitions, startState) {
+ const catchEdges = startState.Catch;
+ for (const option of catchEdges) {
+ const sourceX = definitions.States[startState.Name].catch.style.bounds.x;
+ const sourceY = definitions.States[startState.Name].catch.style.bounds.y;
+ const targetX = definitions.States[option.Next].style.bounds.x;
+ const targetY = definitions.States[option.Next].style.bounds.y;
+ let waypoints1 = [];
+ if ((definitions.States[option.Next].Type === 'ServiceTask')
+ || (definitions.States[option.Next].Type === 'ScriptTask')
+ || (definitions.States[option.Next].Type === 'SubStateMachine')) {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 50,
+ y: targetY + 100,
+ }, {
+ x: targetX + 50,
+ y: (targetY + 100) - 20,
+ }];
+ } else {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 18,
+ y: (targetY + 36) + 20,
+ }, {
+ x: targetX + 18,
+ y: targetY + 36,
+ }];
Review Comment:
Same. Make these literals be constants and eclare them above.
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
@@ -24,9 +24,381 @@ export default class Node extends BaseSpec {
style = new NodeStyle();
importJson(json) {
+ if (json.style === undefined) {
+ json.style = {};
+ json.style.bounds = {
+ x: 200,
+ y: 200,
+ width: 36,
+ height: 36,
+ };
+ }
assign(this.style.bounds, json.style.bounds);
}
+ isElementPresent(visited, target) {
+ for (const element of visited) {
+ if (element[0] === target[0] && element[1] === target[1]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ ) {
+ const sourceX = definitions.States[source].style.bounds.x;
+ const sourceY = definitions.States[source].style.bounds.y;
+ const targetX = definitions.States[target].style.bounds.x;
+ const targetY = definitions.States[target].style.bounds.y;
+ let waypoints1 = [];
+ if (type === 'Transition') {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ } else if (type === 'Compensation') {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceX === targetX) {
+ waypoints1 = [{
+ x: sourceX + (sourceWidth / 2),
+ y: sourceY + sourceHeight,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY - 20,
+ }, {
+ x: targetX + (targetWidth / 2),
+ y: targetY,
+ }];
+ } else if (sourceY === targetY) {
+ waypoints1 = [{
+ x: sourceX + sourceWidth,
+ y: sourceY + (sourceHeight / 2),
+ }, {
+ x: targetX - 20,
+ y: targetY + (targetHeight / 2),
+ }, {
+ x: targetX,
+ y: targetY + (targetHeight / 2),
+ }];
+ }
+
+ return {
+ style: {
+ waypoints: waypoints1,
+ source,
+ target,
+ },
+ Type: type,
+ };
+ }
+
+ importEdges(definitions, startState) {
+ if (startState.Next) {
+ this.addEdge(startState.Name, startState.Next, definitions, 'Transition', startState);
+ }
+
+ if (startState.CompensateState) {
+ this.addEdge(startState.Name, startState.CompensateState, definitions, 'Compensation', startState);
+ }
+
+ if (startState.Choices) {
+ for (const option of startState.Choices) {
+ this.addEdge(startState.Name, option.Next, definitions, 'ChoiceEntry', startState);
+ }
+ }
+
+ this.importJson(startState);
+ }
+
+ addEdge(source, target, definitions, type, startState) {
+ const sourceWidth = this.calculateWidth(definitions.States[source]);
+ const sourceHeight = this.calculateHeight(definitions.States[source]);
+ const targetWidth = this.calculateWidth(definitions.States[target]);
+ const targetHeight = this.calculateHeight(definitions.States[target]);
+
+ const elementJson = this.addWaypoints(
+ source,
+ target,
+ definitions,
+ type,
+ targetWidth,
+ targetHeight,
+ sourceWidth,
+ sourceHeight,
+ );
+ startState.edge = Object.assign(startState.edge || {}, { [target]: elementJson });
+ }
+
+ calculateWidth(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 100 : 36;
+ }
+
+ calculateHeight(state) {
+ return (state.Type === 'ServiceTask' || state.Type === 'ScriptTask' || state.Type === 'SubStateMachine') ? 80 : 36;
+ }
+
+ importJsonEdges(json) {
+ if (json.States) {
+ const targetX = json.States[json.StartState].style.bounds.x;
+ const targetY = json.States[json.StartState].style.bounds.y;
+ json.edge = {
+ style: {
+ waypoints: [{
+ x: 200 + 36,
+ y: 200 + 18,
+ }, {
+ x: targetX - 20,
+ y: targetY + 40,
+ }, {
+ x: targetX,
+ y: targetY + 40,
+ }],
+ target: json.StartState,
+ },
+ Type: 'Transition',
+ };
+ }
+ this.importJson(json);
+ }
+
+ importCatchesEdges(definitions, startState) {
+ const catchEdges = startState.Catch;
+ for (const option of catchEdges) {
+ const sourceX = definitions.States[startState.Name].catch.style.bounds.x;
+ const sourceY = definitions.States[startState.Name].catch.style.bounds.y;
+ const targetX = definitions.States[option.Next].style.bounds.x;
+ const targetY = definitions.States[option.Next].style.bounds.y;
+ let waypoints1 = [];
+ if ((definitions.States[option.Next].Type === 'ServiceTask')
+ || (definitions.States[option.Next].Type === 'ScriptTask')
+ || (definitions.States[option.Next].Type === 'SubStateMachine')) {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 50,
+ y: targetY + 100,
+ }, {
+ x: targetX + 50,
+ y: (targetY + 100) - 20,
+ }];
+ } else {
+ waypoints1 = [{
+ x: sourceX + 18,
+ y: sourceY,
+ }, {
+ x: targetX + 18,
+ y: (targetY + 36) + 20,
+ }, {
+ x: targetX + 18,
+ y: targetY + 36,
+ }];
+ }
+ startState.catch.edge = assign(startState.catch.edge || {}, {
+ [option.Next]: {
+ style: {
+ waypoints: waypoints1,
+ source: startState.Name,
+ target: option.Next,
+ },
+ Type: 'ExceptionMatch',
+ },
+ });
+ }
+ this.importJson(startState.catch);
+ }
+
+ addCatch(definitions, node, catchList, adjList) {
+ node.catch = {};
+ if (node.Catch) {
+ const {
+ style: {
+ bounds: {
+ x,
+ y,
+ },
+ },
+ } = node;
+ const newX = x;
+ const newY = y;
+ node.catch.style = {};
+ node.catch.style.bounds = {
+ x: newX + 50,
+ y: newY - 20,
+ width: 36,
+ height: 36,
+ };
+ }
+ this.importJson(node.catch);
+
+ let prev = node.catch;
+ let width1;
+ let height1;
+ catchList.get(node).forEach((semantic) => {
+ if ((semantic.Type === 'ServiceTask') || (semantic.Type === 'ScriptTask') || (semantic.Type === 'SubStateMachine')) {
Review Comment:
Use `is` from utills to substitute the conditions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on code in PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#discussion_r1521610454
##########
saga/seata-saga-statemachine-designer/src/modeling/SagaExporter.js:
##########
Review Comment:
i will add it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1994803060
I will go over this PR again. There are some other minor necessary changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1994856766
sure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1994667652
@ptyin
We can surely improve layout more , but for only can you accept these feature , if in future some one found difficulty in reading layout I will try once again .
I have resolved the changes can you check it once again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1998998920
> Yes I am working on it . Give me 1 hour I will submit it
No hurry, take your time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-2001099528
@Code-breaker1998 Congratz! Your first PR has been successfully merged. Thanks for your work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on code in PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#discussion_r1523548888
##########
saga/seata-saga-statemachine-designer/package-lock.json:
##########
Review Comment:
Do not worry about it. I added it back.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-2001197962
Thanks, for your cooperation
But I have one question why you were telling me to use 'is' function , as without that also thing were getting done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on code in PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#discussion_r1521333275
##########
saga/seata-saga-statemachine-designer/src/modeling/SagaExporter.js:
##########
Review Comment:
Is this a mistake? Deleting this file would cause compilation failure.
##########
saga/seata-saga-statemachine-designer/src/modeling/SagaImporter.js:
##########
@@ -69,50 +116,86 @@ SagaImporter.$inject = [
SagaImporter.prototype.import = function (definitions) {
let error = [];
const warnings = [];
-
+
this.eventBus.fire('import.start', { definitions });
try {
const root = this.sagaFactory.create('StateMachine');
root.importJson(definitions);
this.root(root);
-
// Add start state
let start = this.sagaFactory.create('StartState');
+ let stateArrayList=new Map();
start.importJson(definitions);
+ let begin = start;
start = this.add(start);
-
const edges = [];
const catches = [];
forEach(definitions.States, (semantic) => {
const state = this.sagaFactory.create(semantic.Type);
- state.importJson(semantic);
- const host = this.add(state);
- if (semantic.edge) {
- edges.push(...Object.values(semantic.edge));
+
+ if(semantic.style === undefined){
+ stateArrayList=addArrayList(definitions);
+ state.importStates(definitions,semantic,begin,stateArrayList);
+ }else{
+ state.importJson(semantic);
+ begin=state;
}
- if (semantic.catch) {
- const node = this.sagaFactory.create('Catch');
- node.importJson(semantic.catch);
- const source = this.add(node);
- if (semantic.catch.edge) {
+ const host = this.add(state);
+
+ if (semantic.edge === undefined) {
+ state.importEdges(definitions,semantic);
+ if(semantic.edge){
+ edges.push(...Object.values(semantic.edge));
+ }
+ }else{
+ edges.push(...Object.values(semantic.edge));
+ }
+
+ if(semantic.Catch) {
+ let source;
+ if(semantic.catch === undefined){
+ const node = this.sagaFactory.create('Catch');
+ const catchList=addCatchList(definitions,semantic);
+ node.addCatch(definitions,semantic,catchList,stateArrayList);
+ source = this.add(node);
+ }else
+ {
+ const node = this.sagaFactory.create('Catch');
+ node.importJson(semantic.catch);
+ source = this.add(node);
+ }
+
+ if (semantic.catch.edge === undefined) {
+ state.importCatchesEdges(definitions,semantic);
+ console.log(semantic);
Review Comment:
Same
##########
saga/seata-saga-statemachine-designer/src/spec/style/Edge.js:
##########
@@ -27,6 +27,20 @@ export default class Edge extends BaseSpec {
this.style.target = json.style.target;
assign(this.style.waypoints, json.style.waypoints);
}
+
+ importJsonEdges(json){
+ if(json.edge === undefined){
+ debugger
+ json.edge={};
+ if(json.edge.style === undefined){
+ let targetx=json.States[json.StartState].style.bounds.x;
+ let targety=json.States[json.StartState].style.bounds.y;
Review Comment:
`json.States` can probably be `undefined` causing throw, add a check would be nice
##########
saga/seata-saga-statemachine-designer/src/spec/style/Edge.js:
##########
@@ -27,6 +27,20 @@ export default class Edge extends BaseSpec {
this.style.target = json.style.target;
assign(this.style.waypoints, json.style.waypoints);
}
+
+ importJsonEdges(json){
+ if(json.edge === undefined){
+ debugger
Review Comment:
The final version should not include any `debugger` or `console.log`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on code in PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#discussion_r1523494523
##########
saga/seata-saga-statemachine-designer/src/modeling/SagaExporter.js:
##########
Review Comment:
Make sure the line break style be **LF**
##########
saga/seata-saga-statemachine-designer/package-lock.json:
##########
Review Comment:
Plz revert it
##########
saga/seata-saga-statemachine-designer/src/spec/style/Node.js:
##########
Review Comment:
1003 eslint problems
##########
saga/seata-saga-statemachine-designer/src/modeling/SagaImporter.js:
##########
Review Comment:
There are 197 eslint problems including tab indent and trailing spaces
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on code in PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#discussion_r1523545108
##########
saga/seata-saga-statemachine-designer/package-lock.json:
##########
Review Comment:
@ptyin
Are you requesting to package-lock.json to added in PR? or you are requesting to remove changes in them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "Code-breaker1998 (via GitHub)" <gi...@apache.org>.
Code-breaker1998 commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-1998989910
Yes I am working on it . Give me 1 hour I will submit it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: support autolayout in seata-statemachine-designer [incubator-seata]
Posted by "ptyin (via GitHub)" <gi...@apache.org>.
ptyin commented on PR #6415:
URL: https://github.com/apache/incubator-seata/pull/6415#issuecomment-2001601906
Using 'is' function is helpful to centralize calls and extend in the future work. Suppose we want to extend a Task called 'ParallelTask'. Without 'is', then we have to modify all conditions scattered all around code.
获取Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: Durgesh Kadwe ***@***.***>
Sent: Saturday, March 16, 2024 10:26:52 AM
To: apache/incubator-seata ***@***.***>
Cc: Xiangkun Yin ***@***.***>; State change ***@***.***>
Subject: Re: [apache/incubator-seata] feature: support autolayout in seata-statemachine-designer (PR #6415)
Thanks, for your cooperation
But I have one question why you were telling me to use 'is' function , as without that also thing were getting done.
―
Reply to this email directly, view it on GitHub<https://github.com/apache/incubator-seata/pull/6415#issuecomment-2001197962>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AHYVFSN5ZZUA4PJQZHLQQ33YYOUWZAVCNFSM6AAAAABER6GNT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBRGE4TOOJWGI>.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org