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 2023/08/09 15:39:21 UTC

[camel-karavan] 02/02: Fix #842

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

commit b00187c22a17e77668d1a9776b32f6221069be17
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Wed Aug 9 11:39:06 2023 -0400

    Fix #842
---
 karavan-core/package-lock.json                       |  4 ++--
 karavan-core/src/core/api/CamelDefinitionApiExt.ts   | 20 ++++++++------------
 .../src/designer/route/DslConnections.tsx            |  4 ++--
 .../src/designer/route/DslProperties.tsx             | 13 +++++++++----
 4 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/karavan-core/package-lock.json b/karavan-core/package-lock.json
index 0a0b426f..2cbf7bc4 100644
--- a/karavan-core/package-lock.json
+++ b/karavan-core/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "karavan-core",
-  "version": "3.21.1-SNAPSHOT",
+  "version": "4.0.0-RC2",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "karavan-core",
-      "version": "3.21.1-SNAPSHOT",
+      "version": "4.0.0-RC2",
       "license": "Apache-2.0",
       "dependencies": {
         "@types/js-yaml": "^4.0.5",
diff --git a/karavan-core/src/core/api/CamelDefinitionApiExt.ts b/karavan-core/src/core/api/CamelDefinitionApiExt.ts
index 9ff5f563..954c613f 100644
--- a/karavan-core/src/core/api/CamelDefinitionApiExt.ts
+++ b/karavan-core/src/core/api/CamelDefinitionApiExt.ts
@@ -568,19 +568,15 @@ export class CamelDefinitionApiExt {
     };
 
     static getDataFormat = (element: CamelElement | undefined): ElementMeta | undefined => {
-        if (!element) {
-            return undefined;
-        }
-
-        for (const fieldName in element) {
-            const df = CamelMetadataApi.getCamelDataFormatMetadataByName(fieldName);
-            if (df) {
-                return df;
-            }
+        let result: ElementMeta | undefined = undefined;
+        if (element) {
+            Object.keys(element).forEach(fieldName => {
+                const df = CamelMetadataApi.getCamelDataFormatMetadataByName(fieldName);
+                result =  (element as any)[fieldName] ? df : result;
+            });
         }
-
-        return undefined;
-    };
+        return result;
+    }
 
     static getExpressionValue = (expression: ExpressionDefinition | undefined): CamelElement | undefined => {
         const language = CamelDefinitionApiExt.getExpressionLanguageName(expression);
diff --git a/karavan-designer/src/designer/route/DslConnections.tsx b/karavan-designer/src/designer/route/DslConnections.tsx
index 5280bc12..938042d4 100644
--- a/karavan-designer/src/designer/route/DslConnections.tsx
+++ b/karavan-designer/src/designer/route/DslConnections.tsx
@@ -126,7 +126,7 @@ export class DslConnections extends React.Component<Props, State> {
             const imageX = incomingX - r + 5;
             const imageY = fromY - r + 5;
             return (
-                <div style={{display: "block", position: "absolute", top: imageY, left: imageX}}>
+                <div key={pos.step.uuid + "-icon"} style={{display: "block", position: "absolute", top: imageY, left: imageX}}>
                     {CamelUi.getConnectionIcon(pos.step)}
                 </div>
             )
@@ -212,7 +212,7 @@ export class DslConnections extends React.Component<Props, State> {
             const imageX = outgoingX - r + 5;
             const imageY = outgoingY - r + 5;
             return (
-                <div style={{display: "block", position: "absolute", top: imageY, left: imageX}}>
+                <div key={pos.step.uuid + "-icon"} style={{display: "block", position: "absolute", top: imageY, left: imageX}}>
                     {CamelUi.getConnectionIcon(pos.step)}
                 </div>
             )
diff --git a/karavan-designer/src/designer/route/DslProperties.tsx b/karavan-designer/src/designer/route/DslProperties.tsx
index 435480de..f10a0eec 100644
--- a/karavan-designer/src/designer/route/DslProperties.tsx
+++ b/karavan-designer/src/designer/route/DslProperties.tsx
@@ -33,7 +33,7 @@ import {Integration, CamelElement} from "karavan-core/lib/model/IntegrationDefin
 import {CamelDefinitionApiExt} from "karavan-core/lib/api/CamelDefinitionApiExt";
 import {CamelUtil} from "karavan-core/lib/api/CamelUtil";
 import {CamelUi, RouteToCreate} from "../utils/CamelUi";
-import {CamelMetadataApi, PropertyMeta} from "karavan-core/lib/model/CamelMetadata";
+import {CamelMetadataApi, DataFormats, PropertyMeta} from "karavan-core/lib/model/CamelMetadata";
 import {IntegrationHeader} from "../utils/KaravanComponents";
 import CloneIcon from "@patternfly/react-icons/dist/esm/icons/clone-icon";
 
@@ -170,7 +170,7 @@ export class DslProperties extends React.Component<Props, State> {
 
     getPropertyFields = (properties: PropertyMeta[]) => {
         return (<>
-            {this.state.step && !['MarshalDefinition', 'UnmarshalDefinition'].includes(this.state.step.dslName) && properties.map((property: PropertyMeta) =>
+            {properties.map((property: PropertyMeta) =>
                 <DslPropertyField key={property.name}
                                   integration={this.props.integration}
                                   property={property}
@@ -186,7 +186,11 @@ export class DslProperties extends React.Component<Props, State> {
     }
 
     render() {
-        const properties = this.getProperties();
+        const dataFormats = DataFormats.map(value => value[0]);
+        const dataFormatElement = this.state.step !== undefined && ['MarshalDefinition', 'UnmarshalDefinition'].includes(this.state.step.dslName);
+        const properties = !dataFormatElement
+                    ? this.getProperties()
+                    : this.getProperties().filter(p => !dataFormats.includes(p.name));
         const propertiesMain = properties.filter(p => !p.label.includes("advanced"));
         const propertiesAdvanced = properties.filter(p => p.label.includes("advanced"));
         return (
@@ -196,7 +200,8 @@ export class DslProperties extends React.Component<Props, State> {
                     {this.state.step === undefined && <IntegrationHeader integration={this.props.integration}/>}
                     {this.state.step && this.getComponentHeader()}
                     {this.getPropertyFields(propertiesMain)}
-                    {propertiesAdvanced.length > 0 &&
+                    {this.state.step && !['MarshalDefinition', 'UnmarshalDefinition'].includes(this.state.step.dslName)
+                        && propertiesAdvanced.length > 0 &&
                         <ExpandableSection
                             toggleText={'Advanced properties'}
                             onToggle={isExpanded => this.setState({isShowAdvanced: !this.state.isShowAdvanced})}