You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2021/11/12 19:01:44 UTC
[camel-karavan] branch main updated: Fix reorder issues (#86)
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new 1e6d5a8 Fix reorder issues (#86)
1e6d5a8 is described below
commit 1e6d5a8a324c49f346f9edde326ad6326eb7d17f
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Fri Nov 12 14:00:42 2021 -0500
Fix reorder issues (#86)
---
karavan-designer/src/designer/api/CamelApiExt.tsx | 14 ++++++++++----
karavan-designer/src/designer/ui/DslElement.tsx | 2 +-
karavan-designer/src/designer/ui/KaravanDesigner.tsx | 13 +++++++++++--
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/karavan-designer/src/designer/api/CamelApiExt.tsx b/karavan-designer/src/designer/api/CamelApiExt.tsx
index d0bf432..a845fd6 100644
--- a/karavan-designer/src/designer/api/CamelApiExt.tsx
+++ b/karavan-designer/src/designer/api/CamelApiExt.tsx
@@ -31,7 +31,12 @@ export class CamelApiExt {
return integration;
}
- static moveElement = (integration: Integration, source: string, target: string) => {
+ static findElement = (integration: Integration, uuid: string): CamelElement | undefined => {
+ const step = CamelApi.findStep(integration.spec.flows, uuid, undefined);
+ return step.step;
+ }
+
+ static moveElement = (integration: Integration, source: string, target: string): Integration => {
const sourceFindStep = CamelApi.findStep(integration.spec.flows, source, undefined);
const sourceStep = sourceFindStep.step;
const sourceUuid = sourceStep?.uuid;
@@ -41,16 +46,17 @@ export class CamelApiExt {
CamelApiExt.deleteStepFromIntegration(integration, sourceUuid);
switch (targetFindStep.step?.dslName) {
case 'when':
- CamelApiExt.addStepToIntegration(integration, sourceStep, targetFindStep.step?.uuid, undefined);
+ return CamelApiExt.addStepToIntegration(integration, sourceStep, targetFindStep.step?.uuid, undefined);
break;
case 'otherwise':
- CamelApiExt.addStepToIntegration(integration, sourceStep, targetFindStep.step?.uuid, undefined);
+ return CamelApiExt.addStepToIntegration(integration, sourceStep, targetFindStep.step?.uuid, undefined);
break;
default:
- CamelApiExt.addStepToIntegration(integration, sourceStep, parentUuid, targetFindStep.position);
+ return CamelApiExt.addStepToIntegration(integration, sourceStep, parentUuid, targetFindStep.position);
break;
}
}
+ return integration;
}
static deleteStepFromIntegration = (integration: Integration, uuidToDelete: string): Integration => {
diff --git a/karavan-designer/src/designer/ui/DslElement.tsx b/karavan-designer/src/designer/ui/DslElement.tsx
index 1f33e66..5d20fbc 100644
--- a/karavan-designer/src/designer/ui/DslElement.tsx
+++ b/karavan-designer/src/designer/ui/DslElement.tsx
@@ -181,7 +181,7 @@ export class DslElement extends React.Component<Props, State> {
borderColor: this.isSelected() ? this.props.borderColorSelected : this.props.borderColor,
marginTop: this.isRoot() ? "16px" : "",
zIndex: this.state.step.dslName === 'toStep' ? 20 : 10,
- boxShadow: this.state.isDraggedOver ? "0px 0px 1px 2px " + this.props.borderColor : "none",
+ boxShadow: this.state.isDraggedOver ? "0px 0px 1px 2px " + this.props.borderColorSelected : "none",
}}
onClick={event => this.selectElement(event)}
onDragStart={event => {
diff --git a/karavan-designer/src/designer/ui/KaravanDesigner.tsx b/karavan-designer/src/designer/ui/KaravanDesigner.tsx
index 3541482..96b05ae 100644
--- a/karavan-designer/src/designer/ui/KaravanDesigner.tsx
+++ b/karavan-designer/src/designer/ui/KaravanDesigner.tsx
@@ -158,7 +158,7 @@ export class KaravanDesigner extends React.Component<Props, State> {
showSelector: false,
selectedStep: step,
selectedUuid: step.uuid
- })
+ });
}
onIntegrationUpdate = (i: Integration) => {
@@ -166,7 +166,16 @@ export class KaravanDesigner extends React.Component<Props, State> {
}
moveElement = (source: string, target: string) => {
- CamelApiExt.moveElement(this.state.integration, source, target);
+ const i = CamelApiExt.moveElement(this.state.integration, source, target);
+ const clone = CamelYaml.cloneIntegration(i);
+ const selectedStep = CamelApiExt.findElement(clone, source);
+ this.setState({
+ integration: clone,
+ key: Math.random().toString(),
+ showSelector: false,
+ selectedStep: selectedStep,
+ selectedUuid: source
+ });
}
render() {