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 960118472b423a600e6ebbf596d430c4e3076a76 Author: Marat Gubaidullin <marat.gubaidul...@gmail.com> AuthorDate: Mon Jan 9 20:30:49 2023 -0500 RouteConfiguration in Route tab UI #596 --- karavan-core/src/core/api/CamelDefinitionApiExt.ts | 4 +- karavan-core/src/core/api/CamelUtil.ts | 2 +- karavan-designer/src/designer/route/DslElement.tsx | 6 +- .../src/designer/route/RouteDesigner.tsx | 2 + karavan-designer/src/designer/utils/CamelUi.tsx | 15 +++- .../src/designer/utils/KaravanIcons.tsx | 99 ++++++++++++++++++++++ 6 files changed, 123 insertions(+), 5 deletions(-) diff --git a/karavan-core/src/core/api/CamelDefinitionApiExt.ts b/karavan-core/src/core/api/CamelDefinitionApiExt.ts index ea080d1..f1f6458 100644 --- a/karavan-core/src/core/api/CamelDefinitionApiExt.ts +++ b/karavan-core/src/core/api/CamelDefinitionApiExt.ts @@ -48,9 +48,11 @@ export class CamelDefinitionApiExt { integration.spec.flows?.push(step as RouteDefinition); } else { const flows: any[] = []; - integration.spec.flows?.filter(flow => flow.dslName !== 'RouteDefinition').forEach(bean => flows.push(bean)); + integration.spec.flows?.filter(flow => !['RouteConfigurationDefinition', 'RouteDefinition'].includes(flow.dslName)).forEach(bean => flows.push(bean)); const routes = CamelDefinitionApiExt.addStepToSteps(integration.spec.flows?.filter(flow => flow.dslName === 'RouteDefinition') || [], step, parentId, position); flows.push(...routes); + const routeConfigurations = CamelDefinitionApiExt.addStepToSteps(integration.spec.flows?.filter(flow => flow.dslName === 'RouteConfigurationDefinition') || [], step, parentId, position); + flows.push(...routeConfigurations); integration.spec.flows = flows; } return integration; diff --git a/karavan-core/src/core/api/CamelUtil.ts b/karavan-core/src/core/api/CamelUtil.ts index 914ac57..d827f94 100644 --- a/karavan-core/src/core/api/CamelUtil.ts +++ b/karavan-core/src/core/api/CamelUtil.ts @@ -191,7 +191,7 @@ export class CamelUtil { if (elementMeta === undefined && className.endsWith("Expression")) elementMeta = CamelMetadataApi.getCamelLanguageMetadataByClassName(className); elementMeta?.properties.filter(p => p.required).forEach(p => { const value = (element as any)[p.name]; - if (p.type === 'string' && (value === undefined || value.trim().length === 0)){ + if (p.type === 'string' && !p.isArray && (value === undefined || value.trim().length === 0)) { result[0] = false; result[1].push(p.displayName + " is required"); } else if (p.type === 'ExpressionDefinition'){ diff --git a/karavan-designer/src/designer/route/DslElement.tsx b/karavan-designer/src/designer/route/DslElement.tsx index ccf15e8..868f3e2 100644 --- a/karavan-designer/src/designer/route/DslElement.tsx +++ b/karavan-designer/src/designer/route/DslElement.tsx @@ -228,9 +228,13 @@ export class DslElement extends React.Component<Props, State> { getHeader = () => { const step: CamelElement = this.props.step; + const parent = this.props.parent; + const inRouteConfiguration = parent !== undefined && parent.dslName === 'RouteConfigurationDefinition'; const availableModels = CamelUi.getSelectorModelsForParent(step.dslName, false); const showAddButton = !['CatchDefinition', 'RouteDefinition'].includes(step.dslName) && availableModels.length > 0; - const showInsertButton = !['FromDefinition', 'RouteConfigurationDefinition', 'RouteDefinition', 'CatchDefinition', 'FinallyDefinition', 'WhenDefinition', 'OtherwiseDefinition'].includes(step.dslName); + const showInsertButton = + !['FromDefinition', 'RouteConfigurationDefinition', 'RouteDefinition', 'CatchDefinition', 'FinallyDefinition', 'WhenDefinition', 'OtherwiseDefinition'].includes(step.dslName) + && !inRouteConfiguration; const headerClass = ['RouteConfigurationDefinition', 'RouteDefinition'].includes(step.dslName) ? "header-route" : "header" const headerClasses = this.isSelected() ? headerClass + " selected" : headerClass; return ( diff --git a/karavan-designer/src/designer/route/RouteDesigner.tsx b/karavan-designer/src/designer/route/RouteDesigner.tsx index 01c02f7..d8495d8 100644 --- a/karavan-designer/src/designer/route/RouteDesigner.tsx +++ b/karavan-designer/src/designer/route/RouteDesigner.tsx @@ -259,7 +259,9 @@ export class RouteDesigner extends React.Component<Props, State> { addStep = (step: CamelElement, parentId: string, position?: number | undefined) => { const i = CamelDefinitionApiExt.addStepToIntegration(this.state.integration, step, parentId, position); + console.log(i) const clone = CamelUtil.cloneIntegration(i); + console.log(clone) this.setState({ integration: clone, key: Math.random().toString(), diff --git a/karavan-designer/src/designer/utils/CamelUi.tsx b/karavan-designer/src/designer/utils/CamelUi.tsx index f4e33c5..ab015ea 100644 --- a/karavan-designer/src/designer/utils/CamelUi.tsx +++ b/karavan-designer/src/designer/utils/CamelUi.tsx @@ -21,9 +21,16 @@ import {ComponentApi} from "karavan-core/lib/api/ComponentApi"; import {CamelMetadataApi} from "karavan-core/lib/model/CamelMetadata"; import {CamelUtil} from "karavan-core/lib/api/CamelUtil"; import {CamelDefinitionApiExt} from "karavan-core/lib/api/CamelDefinitionApiExt"; -import {NamedBeanDefinition, RouteConfigurationDefinition, RouteDefinition, SagaDefinition, ToDefinition} from "karavan-core/lib/model/CamelDefinition"; +import { + InterceptSendToEndpointDefinition, + NamedBeanDefinition, + RouteConfigurationDefinition, + RouteDefinition, + SagaDefinition, + ToDefinition +} from "karavan-core/lib/model/CamelDefinition"; import {CamelElement, Integration} from "karavan-core/lib/model/IntegrationDefinition"; -import {AggregateIcon, ChoiceIcon, FilterIcon, SagaIcon, SortIcon, SplitIcon} from "./KaravanIcons"; +import {AggregateIcon, ChoiceIcon, FilterIcon, Intercept, InterceptFrom, InterceptSendToEndpoint, OnCompletion, SagaIcon, SortIcon, SplitIcon} from "./KaravanIcons"; import React from "react"; const StepElements: string[] = [ @@ -489,6 +496,10 @@ export class CamelUi { case 'SagaDefinition' :return <SagaIcon/>; case 'FilterDefinition' :return <FilterIcon/>; case 'SortDefinition' :return <SortIcon/>; + case 'OnCompletionDefinition' :return <OnCompletion/>; + case 'InterceptDefinition' :return <Intercept/>; + case 'InterceptFromDefinition' :return <InterceptFrom/>; + case 'InterceptSendToEndpointDefinition' :return <InterceptSendToEndpoint/>; default: return this.getIconFromSource(CamelUi.getIconSrcForName(dslName)) } } diff --git a/karavan-designer/src/designer/utils/KaravanIcons.tsx b/karavan-designer/src/designer/utils/KaravanIcons.tsx index 33206f4..63bb26d 100644 --- a/karavan-designer/src/designer/utils/KaravanIcons.tsx +++ b/karavan-designer/src/designer/utils/KaravanIcons.tsx @@ -450,6 +450,105 @@ export function SortIcon() { ); } +export function OnCompletion() { + return ( + <svg + className="icon" width="32px" height="32px" + xmlns="http://www.w3.org/2000/svg" + id="icon" + fill="#000" + viewBox="0 0 32 32" + > + <defs> + <style>{".cls-1 { fill: none; }"}</style> + </defs> + <path d="M22 26.59L19.41 24 18 25.41 22 29.41 30 21.41 28.59 20 22 26.59z"></path> + <circle cx="16" cy="16" r="2"></circle> + <path d="M16 22a6 6 0 116-6 6.007 6.007 0 01-6 6zm0-10a4 4 0 104 4 4.005 4.005 0 00-4-4z"></path> + <path d="M28 16a12 12 0 10-12 12v-2a10 10 0 1110-10z"></path> + <path + id="_Transparent_Rectangle_" + d="M0 0H32V32H0z" + className="cls-1" + data-name="<Transparent Rectangle>" + ></path> + </svg> + ); +} + +export function Intercept() { + return ( + <svg + className="icon" width="32px" height="32px" + xmlns="http://www.w3.org/2000/svg" + id="icon" + fill="#000" + viewBox="0 0 32 32" + > + <defs> + <style>{".cls-1 { fill: none; }"}</style> + </defs> + <path d="M15 4H17V28H15z"></path> + <path d="M10 7v18H4V7h6m0-2H4a2 2 0 00-2 2v18a2 2 0 002 2h6a2 2 0 002-2V7a2 2 0 00-2-2zM28 7v18h-6V7h6m0-2h-6a2 2 0 00-2 2v18a2 2 0 002 2h6a2 2 0 002-2V7a2 2 0 00-2-2z"></path> + <path + id="_Transparent_Rectangle_" + d="M0 0H32V32H0z" + className="cls-1" + data-name="<Transparent Rectangle>" + ></path> + </svg> + ); +} + +export function InterceptFrom() { + return ( + <svg + className="icon" width="32px" height="32px" + xmlns="http://www.w3.org/2000/svg" + id="icon" + fill="#000" + viewBox="0 0 32 32" + > + <defs> + <style>{".cls-1 { fill: none; }"}</style> + </defs> + <path d="M26 30H14a2 2 0 01-2-2v-3h2v3h12V4H14v3h-2V4a2 2 0 012-2h12a2 2 0 012 2v24a2 2 0 01-2 2z"></path> + <path d="M14.59 20.59L18.17 17 4 17 4 15 18.17 15 14.59 11.41 16 10 22 16 16 22 14.59 20.59z"></path> + <path + id="_Transparent_Rectangle_" + d="M0 0H32V32H0z" + className="cls-1" + data-name="<Transparent Rectangle>" + ></path> + </svg> + ); +} + +export function InterceptSendToEndpoint() { + return ( + <svg + className="icon" width="32px" height="32px" + xmlns="http://www.w3.org/2000/svg" + id="icon" + fill="#000" + viewBox="0 0 32 32" + > + <defs> + <style>{".cls-1 { fill: none; }"}</style> + </defs> + <path d="M6 30h12a2.002 2.002 0 002-2v-3h-2v3H6V4h12v3h2V4a2.002 2.002 0 00-2-2H6a2.002 2.002 0 00-2 2v24a2.002 2.002 0 002 2z"></path> + <path d="M20.586 20.586L24.172 17 10 17 10 15 24.172 15 20.586 11.414 22 10 28 16 22 22 20.586 20.586z"></path> + <path + id="_Transparent_Rectangle_" + d="M0 0H32V32H0z" + className="cls-1" + data-name="<Transparent Rectangle>" + ></path> + </svg> + ); +} + + export function SpringIcon() { return ( <svg