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/04/24 15:16:00 UTC
[camel-karavan] branch main updated: Fix #734
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 872f5e6a Fix #734
872f5e6a is described below
commit 872f5e6a50ea03b38eb97a152ebd3e6f209f57bb
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Mon Apr 24 11:15:52 2023 -0400
Fix #734
---
karavan-core/src/core/api/CamelUtil.ts | 9 +++++----
karavan-core/src/core/api/ComponentApi.ts | 22 +++++++++++++++-------
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/karavan-core/src/core/api/CamelUtil.ts b/karavan-core/src/core/api/CamelUtil.ts
index 831b38e6..aa63af27 100644
--- a/karavan-core/src/core/api/CamelUtil.ts
+++ b/karavan-core/src/core/api/CamelUtil.ts
@@ -176,13 +176,14 @@ export class CamelUtil {
}
static getComponentProperties = (element: any): ComponentProperty[] => {
- const dslName: string = (element as any).dslName;
- if (['ToDynamicDefinition', 'ToDefinition'].includes(dslName)){
+ const dslName: string = (element as any).dslName;
const component = ComponentApi.findByName(dslName);
- return component ? ComponentApi.getComponentProperties(component?.component.name,'producer') : [];
- } else {
const uri: string = (element as any).uri;
const name = ComponentApi.getComponentNameFromUri(uri);
+ if (['ToDynamicDefinition'].includes(dslName)){
+ const component = ComponentApi.findByName(dslName);
+ return component ? ComponentApi.getComponentProperties(component?.component.name,'producer') : [];
+ } else {
if (name){
const component = ComponentApi.findByName(name);
return component ? ComponentApi.getComponentProperties(component?.component.name, element.dslName === 'FromDefinition' ? 'consumer' : 'producer') : [];
diff --git a/karavan-core/src/core/api/ComponentApi.ts b/karavan-core/src/core/api/ComponentApi.ts
index 4176ffcc..a50a00a3 100644
--- a/karavan-core/src/core/api/ComponentApi.ts
+++ b/karavan-core/src/core/api/ComponentApi.ts
@@ -87,19 +87,27 @@ export const ComponentApi = {
},
getComponentNameFromUri: (uri: string): string | undefined => {
- return uri.split(":")[0];
+ return uri !== undefined ? uri.split(":")[0] : undefined;
},
getComponentTitleFromUri: (uri: string): string | undefined => {
- const componentName = uri.split(":")[0];
- const title = ComponentApi.findByName(componentName)?.component.title;
- return title ? title : componentName;
+ if (uri !== undefined) {
+ const componentName = uri.split(":")[0];
+ const title = ComponentApi.findByName(componentName)?.component.title;
+ return title ? title : componentName;
+ } else {
+ return undefined;
+ }
},
getComponentDescriptionFromUri: (uri: string): string | undefined => {
- const componentName = uri.split(":")[0];
- const description = ComponentApi.findByName(componentName)?.component.description;
- return description ? description : componentName;
+ if (uri !== undefined) {
+ const componentName = uri.split(":")[0];
+ const description = ComponentApi.findByName(componentName)?.component.description;
+ return description ? description : componentName;
+ } else {
+ return undefined;
+ }
},
getUriParts: (uri: string): Map<string, string> => {