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 94ea60fc Fix #1232 94ea60fc is described below commit 94ea60fc890c277f430e8f493ab1ebfe1d3cf880 Author: Marat Gubaidullin <ma...@talismancloud.io> AuthorDate: Sun Apr 21 10:36:10 2024 -0400 Fix #1232 --- karavan-designer/public/example/demo.camel.yaml | 66 +--------------------- karavan-designer/src/App.tsx | 5 +- karavan-designer/src/designer/KaravanDesigner.tsx | 9 ++- .../src/designer/editor/CodeEditor.tsx | 4 +- 4 files changed, 14 insertions(+), 70 deletions(-) diff --git a/karavan-designer/public/example/demo.camel.yaml b/karavan-designer/public/example/demo.camel.yaml index fc1cbb19..0637a088 100644 --- a/karavan-designer/public/example/demo.camel.yaml +++ b/karavan-designer/public/example/demo.camel.yaml @@ -1,65 +1 @@ -- route: - id: second_direct - from: - id: from-7ce0 - uri: direct - parameters: - name: second_direct - steps: - - setVariable: - id: setVariable-75ca - name: global:data1 - expression: - simple: - id: simple-009e - - convertVariableTo: - id: convertVariableTo-c0b8 - - removeVariable: - id: removeVariable-2cae - - to: - id: to-4711 - uri: metrics - - aggregate: - id: aggregate-2870 -- route: - id: route-18e5 - nodePrefixId: route-656 - from: - id: from-9468 - uri: amqp - variableReceive: global:variable1 - steps: - - doTry: - id: doTry-8bb0 - doCatch: - - id: doCatch-19a9 - steps: - - convertVariableTo: - id: convertVariableTo-b0e5 - name: xxx - toName: yyy - steps: - - multicast: - id: multicast-ad44 - steps: - - to: - id: to-0c20 - variableSend: send1 - variableReceive: receive1 - uri: activemq - - to: - id: to-e79a - variableSend: route:aran1 - variableReceive: route:aran1 - uri: arangodb - - setVariable: - id: setVariable-957d - name: varrr - expression: - simple: - id: simple-cd4b - - to: - id: to-60f8 - variableSend: hello - variableReceive: world - uri: amqp +[] \ No newline at end of file diff --git a/karavan-designer/src/App.tsx b/karavan-designer/src/App.tsx index 80f2d927..5d70a72c 100644 --- a/karavan-designer/src/App.tsx +++ b/karavan-designer/src/App.tsx @@ -70,8 +70,8 @@ export function App() { fetch("components/components.json"), fetch("snippets/org.apache.camel.AggregationStrategy"), fetch("snippets/org.apache.camel.Processor"), - // fetch("example/demo.camel.yaml"), - fetch("example/avro-serialize-action.kamelet.yaml"), + fetch("example/demo.camel.yaml"), + // fetch("example/avro-serialize-action.kamelet.yaml"), // fetch("components/blocked-components.properties"), // fetch("kamelets/blocked-kamelets.properties") // fetch("example/plc4x-ads-source.kamelet.yaml") @@ -181,6 +181,7 @@ export function App() { onClickAddRoute={() => {}} onClickAddREST={() => {}} onClickAddBean={() => {}} + onClickAddKamelet={() => {}} hideToolbar={false} /> ) diff --git a/karavan-designer/src/designer/KaravanDesigner.tsx b/karavan-designer/src/designer/KaravanDesigner.tsx index cee6fbc4..ea97a7e1 100644 --- a/karavan-designer/src/designer/KaravanDesigner.tsx +++ b/karavan-designer/src/designer/KaravanDesigner.tsx @@ -128,8 +128,13 @@ export function KaravanDesigner(props: Props) { } function getCode(integration: Integration): string { - const clone = CamelUtil.cloneIntegration(integration); - return CamelDefinitionYaml.integrationToYaml(clone); + try { + const clone = CamelUtil.cloneIntegration(integration); + return CamelDefinitionYaml.integrationToYaml(clone); + } catch (e) { + EventBus.sendAlert('Error parsing Yaml', (e as Error).message, 'danger'); + return ''; + } } function getTab(title: string, tooltip: string, icon: string, showBadge: boolean = false) { diff --git a/karavan-designer/src/designer/editor/CodeEditor.tsx b/karavan-designer/src/designer/editor/CodeEditor.tsx index d833148e..4bb4e3c5 100644 --- a/karavan-designer/src/designer/editor/CodeEditor.tsx +++ b/karavan-designer/src/designer/editor/CodeEditor.tsx @@ -20,6 +20,7 @@ import Editor from "@monaco-editor/react"; import {shallow} from "zustand/shallow"; import {useDesignerStore, useIntegrationStore} from "../DesignerStore"; import {CamelDefinitionYaml} from "karavan-core/lib/api/CamelDefinitionYaml"; +import {CamelUtil} from "karavan-core/lib/api/CamelUtil"; export function CodeEditor () { @@ -29,7 +30,8 @@ export function CodeEditor () { useEffect(() => { try { - const c = CamelDefinitionYaml.integrationToYaml(integration); + const clone = CamelUtil.cloneIntegration(integration); + const c = CamelDefinitionYaml.integrationToYaml(clone); setCode(c); } catch (e: any) { const message: string = e?.message ? e.message : e.reason;