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 2022/04/05 00:27:32 UTC

[camel-karavan] branch main updated: Fix #269 (#270)

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 79184da  Fix #269 (#270)
79184da is described below

commit 79184dab8d82357cae5b46a39c297ae1ea7cb6ff
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Mon Apr 4 20:27:27 2022 -0400

    Fix #269 (#270)
---
 karavan-core/src/core/api/ComponentApi.ts | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/karavan-core/src/core/api/ComponentApi.ts b/karavan-core/src/core/api/ComponentApi.ts
index b8f8e13..6a1781c 100644
--- a/karavan-core/src/core/api/ComponentApi.ts
+++ b/karavan-core/src/core/api/ComponentApi.ts
@@ -96,17 +96,17 @@ export const ComponentApi = {
 
     getSyntaxSeparators: (syntax: string): string[] => {
         const result: string[] = [];
-            const parts: string[] = ComponentApi.parseSyntax(syntax);
-            let str = '';
-            parts.forEach((part, index) => {
-                if (index < parts.length -1){
-                    const start = syntax.indexOf(part, str.length) + part.length;
-                    const end = syntax.indexOf(parts[index + 1], start);
-                    const separator = syntax.substr(start, end - start);
-                    result.push(separator);
-                    str = str + part + separator;
-                }
-            })
+        const parts: string[] = ComponentApi.parseSyntax(syntax);
+        let str = '';
+        parts.forEach((part, index) => {
+            if (index < parts.length -1){
+                const start = syntax.indexOf(part, str.length) + part.length;
+                const end = syntax.indexOf(parts[index + 1], start);
+                const separator = syntax.substr(start, end - start);
+                result.push(separator);
+                str = str + part + separator;
+            }
+        })
         return result;
     },
 
@@ -162,6 +162,7 @@ export const ComponentApi = {
     },
 
     getComponentProperties: (componentName: string, type: 'consumer' | 'producer'): ComponentProperty[] => {
+        const invertedType = type === 'consumer' ? 'producer' : 'consumer';
         const component: Component | undefined = ComponentApi.findByName(componentName);
         const properties: ComponentProperty[] = [];
         try {
@@ -189,15 +190,15 @@ export const ComponentApi = {
             result.push(...properties.filter(p => p.kind === 'path'));
             result.push(...properties.filter(p => p.kind !== 'path' && p.required));
             result.push(...properties.filter(p => p.label.length === 0 && p.kind !== 'path' && !p.required));
-            result.push(...properties.filter(p => p.label.startsWith(type) && !p.label.includes("advanced") && !p.required));
+            result.push(...properties.filter(p => !p.label.includes(invertedType) && !p.label.includes("advanced") && !p.required));
             result.push(...properties.filter(p => p.label === "formatting" && !p.required));
-            result.push(...properties.filter(p => p.label.startsWith(type) &&
+            result.push(...properties.filter(p => !p.label.includes(invertedType) &&
                 (p.label.includes("scheduler") || p.label.includes("security") || p.label.includes("advanced"))
             ));
-            result.push(...properties.filter(p => !p.label.includes(type) &&
+            result.push(...properties.filter(p => !p.label.includes(invertedType) &&
                 (p.label.includes("scheduler") || p.label.includes("security") || p.label.includes("advanced"))
             ));
-            return result;
+            return Array.from(new Map(result.map(item => [item.name, item])).values());
         }
     }
 }
\ No newline at end of file