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 a03d1c58 Kamelet for project a03d1c58 is described below commit a03d1c582a84a622247a86c474eb3f5a476625a0 Author: Marat Gubaidullin <ma...@talismancloud.io> AuthorDate: Fri Apr 19 16:41:37 2024 -0400 Kamelet for project --- .../example/avro-serialize-action.kamelet.yaml | 70 ++++++++++++++++++++++ karavan-designer/src/App.tsx | 3 +- .../src/designer/property/DslProperties.tsx | 2 +- karavan-designer/src/topology/TopologyTab.tsx | 2 + karavan-designer/src/topology/TopologyToolbar.tsx | 16 ++++- 5 files changed, 89 insertions(+), 4 deletions(-) diff --git a/karavan-designer/public/example/avro-serialize-action.kamelet.yaml b/karavan-designer/public/example/avro-serialize-action.kamelet.yaml new file mode 100644 index 00000000..71a80e1a --- /dev/null +++ b/karavan-designer/public/example/avro-serialize-action.kamelet.yaml @@ -0,0 +1,70 @@ +# --------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# --------------------------------------------------------------------------- + +apiVersion: camel.apache.org/v1 +kind: Kamelet +metadata: + name: avro-serialize-action + annotations: + camel.apache.org/kamelet.support.level: "Stable" + camel.apache.org/catalog.version: "4.6.0-SNAPSHOT" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.group: "Actions" + camel.apache.org/kamelet.namespace: "Transformation" + labels: + camel.apache.org/kamelet.type: "action" +spec: + definition: + title: "Avro Serialize Action" + description: "Serialize payload to Avro" + type: object + properties: + schema: + title: Schema + description: The Avro schema to use during serialization (as single-line, using JSON format) + type: string + example: '{"type": "record", "namespace": "com.example", "name": "FullName", "fields": [{"name": "first", "type": "string"},{"name": "last", "type": "string"}]}' + validate: + title: Validate + description: Indicates if the content must be validated against the schema + type: boolean + default: true + dependencies: + - "camel:kamelet" + - "camel:core" + - "camel:jackson-avro" + template: + beans: + - name: schemaResolver + type: "#class:org.apache.camel.component.jackson.avro.transform.AvroSchemaResolver" + property: + - key: validate + value: '{{validate}}' + - key: schema + value: '{{schema:}}' + from: + uri: kamelet:source + steps: + - marshal: + avro: + library: Jackson + unmarshalType: com.fasterxml.jackson.databind.JsonNode + schemaResolver: "#bean:{{schemaResolver}}" + - setHeader: + name: "Content-Type" + constant: "application/avro" \ No newline at end of file diff --git a/karavan-designer/src/App.tsx b/karavan-designer/src/App.tsx index b6b5e9e6..80f2d927 100644 --- a/karavan-designer/src/App.tsx +++ b/karavan-designer/src/App.tsx @@ -70,7 +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/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") diff --git a/karavan-designer/src/designer/property/DslProperties.tsx b/karavan-designer/src/designer/property/DslProperties.tsx index 7448351c..a8ce0076 100644 --- a/karavan-designer/src/designer/property/DslProperties.tsx +++ b/karavan-designer/src/designer/property/DslProperties.tsx @@ -62,7 +62,7 @@ export function DslProperties(props: Props) { const [showAdvanced, setShowAdvanced] = useState<boolean>(false); - function getClonableElementHeader(): JSX.Element { + function getClonableElementHeader(): React.JSX.Element { const title = selectedStep && CamelDisplayUtil.getTitle(selectedStep); const description = selectedStep?.dslName ? CamelMetadataApi.getCamelModelMetadataByClassName(selectedStep?.dslName)?.description : title; const descriptionLines: string [] = description ? description?.split("\n") : [""]; diff --git a/karavan-designer/src/topology/TopologyTab.tsx b/karavan-designer/src/topology/TopologyTab.tsx index 694eeb64..e9587444 100644 --- a/karavan-designer/src/topology/TopologyTab.tsx +++ b/karavan-designer/src/topology/TopologyTab.tsx @@ -43,6 +43,7 @@ interface Props { hideToolbar: boolean onClickAddRoute: () => void onClickAddREST: () => void + onClickAddKamelet: () => void onClickAddBean: () => void } @@ -144,6 +145,7 @@ export function TopologyTab(props: Props) { contextToolbar={!props.hideToolbar ? <TopologyToolbar onClickAddRoute={props.onClickAddRoute} onClickAddBean={props.onClickAddBean} + onClickAddKamelet={props.onClickAddKamelet} onClickAddREST={props.onClickAddREST}/> : undefined} sideBar={<TopologyPropertiesPanel onSetFile={props.onSetFile}/>} diff --git a/karavan-designer/src/topology/TopologyToolbar.tsx b/karavan-designer/src/topology/TopologyToolbar.tsx index 667cf8f5..5dbe4949 100644 --- a/karavan-designer/src/topology/TopologyToolbar.tsx +++ b/karavan-designer/src/topology/TopologyToolbar.tsx @@ -25,6 +25,7 @@ import PlusIcon from "@patternfly/react-icons/dist/esm/icons/plus-icon"; interface Props { onClickAddRoute: () => void onClickAddREST: () => void + onClickAddKamelet: () => void onClickAddBean: () => void } @@ -46,7 +47,7 @@ export function TopologyToolbar (props: Props) { <ToolbarItem align={{default:"alignRight"}}> <Tooltip content={"Add REST API"} position={"bottom"}> <Button className="dev-action-button" size="sm" - variant={"primary"} + variant={"secondary"} icon={<PlusIcon/>} onClick={e => props.onClickAddREST()} > @@ -54,10 +55,21 @@ export function TopologyToolbar (props: Props) { </Button> </Tooltip> </ToolbarItem> + <ToolbarItem align={{default:"alignRight"}}> + <Tooltip content={"Add Kamelet"} position={"bottom"}> + <Button className="dev-action-button" size="sm" + variant={"secondary"} + icon={<PlusIcon/>} + onClick={e => props.onClickAddKamelet()} + > + Kamelet + </Button> + </Tooltip> + </ToolbarItem> <ToolbarItem align={{default:"alignRight"}}> <Tooltip content={"Add Bean"} position={"bottom"}> <Button className="dev-action-button" size="sm" - variant={"primary"} + variant={"secondary"} icon={<PlusIcon/>} onClick={e => props.onClickAddBean()} >