From ab760aa24379a0fd93350014e9c74f92c4f71c86 Mon Sep 17 00:00:00 2001 From: Marat Gubaidullin Date: Fri, 17 May 2024 10:42:26 -0400 Subject: [PATCH] Fix #1174 --- karavan-app/src/main/webui/package-lock.json | 2 +- .../webui/src/designer/icons/OtherIcons.tsx | 49 +++++++++++++++++++ .../src/designer/route/element/DslElement.css | 6 +++ .../src/designer/route/element/DslElement.tsx | 2 + .../route/element/DslElementHeader.tsx | 28 ++++++++--- .../src/designer/icons/OtherIcons.tsx | 49 +++++++++++++++++++ .../src/designer/route/element/DslElement.css | 6 +++ .../src/designer/route/element/DslElement.tsx | 2 + .../route/element/DslElementHeader.tsx | 28 ++++++++--- .../src/designer/icons/OtherIcons.tsx | 49 +++++++++++++++++++ .../src/designer/route/element/DslElement.css | 6 +++ .../src/designer/route/element/DslElement.tsx | 2 + .../route/element/DslElementHeader.tsx | 28 ++++++++--- 13 files changed, 235 insertions(+), 22 deletions(-) create mode 100644 karavan-app/src/main/webui/src/designer/icons/OtherIcons.tsx create mode 100644 karavan-designer/src/designer/icons/OtherIcons.tsx create mode 100644 karavan-space/src/designer/icons/OtherIcons.tsx diff --git a/karavan-app/src/main/webui/package-lock.json b/karavan-app/src/main/webui/package-lock.json index a15f3313c54..b77c8e644e9 100644 --- a/karavan-app/src/main/webui/package-lock.json +++ b/karavan-app/src/main/webui/package-lock.json @@ -74,7 +74,7 @@ } }, "../../../../karavan-core": { - "version": "4.5.1", + "version": "4.6.0", "license": "Apache-2.0", "dependencies": { "@types/js-yaml": "^4.0.7", diff --git a/karavan-app/src/main/webui/src/designer/icons/OtherIcons.tsx b/karavan-app/src/main/webui/src/designer/icons/OtherIcons.tsx new file mode 100644 index 00000000000..21368f3d0b8 --- /dev/null +++ b/karavan-app/src/main/webui/src/designer/icons/OtherIcons.tsx @@ -0,0 +1,49 @@ +/* + * 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. + */ +import React from 'react'; + +export function AutoStartupIcon() { + return ( + + + + + + ); +} + +export function ErrorHandlerIcon() { + return ( + + + + + + ); +} diff --git a/karavan-app/src/main/webui/src/designer/route/element/DslElement.css b/karavan-app/src/main/webui/src/designer/route/element/DslElement.css index edaebc54660..4f0109c54c0 100644 --- a/karavan-app/src/main/webui/src/designer/route/element/DslElement.css +++ b/karavan-app/src/main/webui/src/designer/route/element/DslElement.css @@ -125,6 +125,12 @@ align-items: center; } +.karavan .step-element .route-icons { + position: absolute; + top: 0; + display: flex; +} + .karavan .step-element .header .icon, .element-builder .header .icon { height: 20px; diff --git a/karavan-app/src/main/webui/src/designer/route/element/DslElement.tsx b/karavan-app/src/main/webui/src/designer/route/element/DslElement.tsx index 70befc336be..ae56605597d 100644 --- a/karavan-app/src/main/webui/src/designer/route/element/DslElement.tsx +++ b/karavan-app/src/main/webui/src/designer/route/element/DslElement.tsx @@ -181,6 +181,8 @@ export function DslElement(props: Props) { const cc = CamelDefinitionApiExt.getElementChildrenDefinition(child.className); return child.name === 'steps' || cc.filter(c => c.multiple).length > 0; }) + } else { + children = children.filter(child => child.className === 'FromDefinition') } if (step.dslName === 'CatchDefinition') { // exception children = children.filter(value => value.name !== 'onWhen') diff --git a/karavan-app/src/main/webui/src/designer/route/element/DslElementHeader.tsx b/karavan-app/src/main/webui/src/designer/route/element/DslElementHeader.tsx index 7c5bdd4c4f0..c047e846463 100644 --- a/karavan-app/src/main/webui/src/designer/route/element/DslElementHeader.tsx +++ b/karavan-app/src/main/webui/src/designer/route/element/DslElementHeader.tsx @@ -28,6 +28,7 @@ import {shallow} from "zustand/shallow"; import {useRouteDesignerHook} from "../useRouteDesignerHook"; import {AddElementIcon, DeleteElementIcon, InsertElementIcon} from "../../utils/ElementIcons"; import { RouteConfigurationDefinition} from "karavan-core/lib/model/CamelDefinition"; +import {AutoStartupIcon, ErrorHandlerIcon} from "../../icons/OtherIcons"; interface Props { headerRef: React.RefObject @@ -103,8 +104,8 @@ export function DslElementHeader(props: Props) { return [hasStepsField, stepsChildrenCount, hasNonStepsFields, nonStepChildrenCount, childrenCount] } - function hasWideChildrenElement() { - const [hasStepsField, stepsChildrenCount, hasNonStepsFields, nonStepChildrenCount, childrenCount] = getChildrenInfo(props.step); + function getHasWideChildrenElement(childrenInfo: [boolean, number, boolean, number, number]) { + const [hasStepsField, stepsChildrenCount, hasNonStepsFields, nonStepChildrenCount, childrenCount] = childrenInfo; if (props.step.dslName === 'SetHeadersDefinition') return false; else if (isHorizontal() && stepsChildrenCount > 1) return true; else if (hasStepsField && stepsChildrenCount > 0 && hasNonStepsFields && nonStepChildrenCount > 0) return true; @@ -169,6 +170,8 @@ export function DslElementHeader(props: Props) { !['FromDefinition', 'RouteConfigurationDefinition', 'RouteDefinition', 'CatchDefinition', 'FinallyDefinition', 'WhenDefinition', 'OtherwiseDefinition'].includes(step.dslName) && !inRouteConfiguration; const headerClasses = getHeaderClasses(); + const childrenInfo = getChildrenInfo(props.step) || []; + const hasWideChildrenElement = getHasWideChildrenElement(childrenInfo) return (
{!['RouteConfigurationDefinition', 'RouteDefinition'].includes(props.step.dslName) && @@ -178,9 +181,20 @@ export function DslElementHeader(props: Props) { {CamelUi.getIconForElement(step)}
} -
- {hasWideChildrenElement() &&
} - {getHeaderTextWithTooltip(step)} + {'RouteDefinition' === step.dslName&& +
+ {(step as any).autoStartup !== false && } + {(step as any).errorHandler !== undefined && } +
+ } + {'RouteConfigurationDefinition' === step.dslName&& +
+ {(step as any).errorHandler !== undefined && } +
+ } +
+ {hasWideChildrenElement &&
} + {getHeaderTextWithTooltip(step, hasWideChildrenElement)}
{showInsertButton && getInsertElementButton()} {getDeleteButton()} @@ -199,10 +213,10 @@ export function DslElementHeader(props: Props) { } } - function getHeaderTextWithTooltip(step: CamelElement) { + function getHeaderTextWithTooltip(step: CamelElement, hasWideChildrenElement: boolean) { const title = getHeaderText(step); const checkRequired = CamelUtil.checkRequired(step); - let className = hasWideChildrenElement() ? "text text-right" : "text text-bottom"; + let className = hasWideChildrenElement ? "text text-right" : "text text-bottom"; if (!checkRequired[0]) className = className + " header-text-required"; if (checkRequired[0]) { return {title} diff --git a/karavan-designer/src/designer/icons/OtherIcons.tsx b/karavan-designer/src/designer/icons/OtherIcons.tsx new file mode 100644 index 00000000000..21368f3d0b8 --- /dev/null +++ b/karavan-designer/src/designer/icons/OtherIcons.tsx @@ -0,0 +1,49 @@ +/* + * 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. + */ +import React from 'react'; + +export function AutoStartupIcon() { + return ( + + + + + + ); +} + +export function ErrorHandlerIcon() { + return ( + + + + + + ); +} diff --git a/karavan-designer/src/designer/route/element/DslElement.css b/karavan-designer/src/designer/route/element/DslElement.css index edaebc54660..4f0109c54c0 100644 --- a/karavan-designer/src/designer/route/element/DslElement.css +++ b/karavan-designer/src/designer/route/element/DslElement.css @@ -125,6 +125,12 @@ align-items: center; } +.karavan .step-element .route-icons { + position: absolute; + top: 0; + display: flex; +} + .karavan .step-element .header .icon, .element-builder .header .icon { height: 20px; diff --git a/karavan-designer/src/designer/route/element/DslElement.tsx b/karavan-designer/src/designer/route/element/DslElement.tsx index 70befc336be..ae56605597d 100644 --- a/karavan-designer/src/designer/route/element/DslElement.tsx +++ b/karavan-designer/src/designer/route/element/DslElement.tsx @@ -181,6 +181,8 @@ export function DslElement(props: Props) { const cc = CamelDefinitionApiExt.getElementChildrenDefinition(child.className); return child.name === 'steps' || cc.filter(c => c.multiple).length > 0; }) + } else { + children = children.filter(child => child.className === 'FromDefinition') } if (step.dslName === 'CatchDefinition') { // exception children = children.filter(value => value.name !== 'onWhen') diff --git a/karavan-designer/src/designer/route/element/DslElementHeader.tsx b/karavan-designer/src/designer/route/element/DslElementHeader.tsx index 7c5bdd4c4f0..c047e846463 100644 --- a/karavan-designer/src/designer/route/element/DslElementHeader.tsx +++ b/karavan-designer/src/designer/route/element/DslElementHeader.tsx @@ -28,6 +28,7 @@ import {shallow} from "zustand/shallow"; import {useRouteDesignerHook} from "../useRouteDesignerHook"; import {AddElementIcon, DeleteElementIcon, InsertElementIcon} from "../../utils/ElementIcons"; import { RouteConfigurationDefinition} from "karavan-core/lib/model/CamelDefinition"; +import {AutoStartupIcon, ErrorHandlerIcon} from "../../icons/OtherIcons"; interface Props { headerRef: React.RefObject @@ -103,8 +104,8 @@ export function DslElementHeader(props: Props) { return [hasStepsField, stepsChildrenCount, hasNonStepsFields, nonStepChildrenCount, childrenCount] } - function hasWideChildrenElement() { - const [hasStepsField, stepsChildrenCount, hasNonStepsFields, nonStepChildrenCount, childrenCount] = getChildrenInfo(props.step); + function getHasWideChildrenElement(childrenInfo: [boolean, number, boolean, number, number]) { + const [hasStepsField, stepsChildrenCount, hasNonStepsFields, nonStepChildrenCount, childrenCount] = childrenInfo; if (props.step.dslName === 'SetHeadersDefinition') return false; else if (isHorizontal() && stepsChildrenCount > 1) return true; else if (hasStepsField && stepsChildrenCount > 0 && hasNonStepsFields && nonStepChildrenCount > 0) return true; @@ -169,6 +170,8 @@ export function DslElementHeader(props: Props) { !['FromDefinition', 'RouteConfigurationDefinition', 'RouteDefinition', 'CatchDefinition', 'FinallyDefinition', 'WhenDefinition', 'OtherwiseDefinition'].includes(step.dslName) && !inRouteConfiguration; const headerClasses = getHeaderClasses(); + const childrenInfo = getChildrenInfo(props.step) || []; + const hasWideChildrenElement = getHasWideChildrenElement(childrenInfo) return (
{!['RouteConfigurationDefinition', 'RouteDefinition'].includes(props.step.dslName) && @@ -178,9 +181,20 @@ export function DslElementHeader(props: Props) { {CamelUi.getIconForElement(step)}
} -
- {hasWideChildrenElement() &&
} - {getHeaderTextWithTooltip(step)} + {'RouteDefinition' === step.dslName&& +
+ {(step as any).autoStartup !== false && } + {(step as any).errorHandler !== undefined && } +
+ } + {'RouteConfigurationDefinition' === step.dslName&& +
+ {(step as any).errorHandler !== undefined && } +
+ } +
+ {hasWideChildrenElement &&
} + {getHeaderTextWithTooltip(step, hasWideChildrenElement)}
{showInsertButton && getInsertElementButton()} {getDeleteButton()} @@ -199,10 +213,10 @@ export function DslElementHeader(props: Props) { } } - function getHeaderTextWithTooltip(step: CamelElement) { + function getHeaderTextWithTooltip(step: CamelElement, hasWideChildrenElement: boolean) { const title = getHeaderText(step); const checkRequired = CamelUtil.checkRequired(step); - let className = hasWideChildrenElement() ? "text text-right" : "text text-bottom"; + let className = hasWideChildrenElement ? "text text-right" : "text text-bottom"; if (!checkRequired[0]) className = className + " header-text-required"; if (checkRequired[0]) { return {title} diff --git a/karavan-space/src/designer/icons/OtherIcons.tsx b/karavan-space/src/designer/icons/OtherIcons.tsx new file mode 100644 index 00000000000..21368f3d0b8 --- /dev/null +++ b/karavan-space/src/designer/icons/OtherIcons.tsx @@ -0,0 +1,49 @@ +/* + * 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. + */ +import React from 'react'; + +export function AutoStartupIcon() { + return ( + + + + + + ); +} + +export function ErrorHandlerIcon() { + return ( + + + + + + ); +} diff --git a/karavan-space/src/designer/route/element/DslElement.css b/karavan-space/src/designer/route/element/DslElement.css index edaebc54660..4f0109c54c0 100644 --- a/karavan-space/src/designer/route/element/DslElement.css +++ b/karavan-space/src/designer/route/element/DslElement.css @@ -125,6 +125,12 @@ align-items: center; } +.karavan .step-element .route-icons { + position: absolute; + top: 0; + display: flex; +} + .karavan .step-element .header .icon, .element-builder .header .icon { height: 20px; diff --git a/karavan-space/src/designer/route/element/DslElement.tsx b/karavan-space/src/designer/route/element/DslElement.tsx index 70befc336be..ae56605597d 100644 --- a/karavan-space/src/designer/route/element/DslElement.tsx +++ b/karavan-space/src/designer/route/element/DslElement.tsx @@ -181,6 +181,8 @@ export function DslElement(props: Props) { const cc = CamelDefinitionApiExt.getElementChildrenDefinition(child.className); return child.name === 'steps' || cc.filter(c => c.multiple).length > 0; }) + } else { + children = children.filter(child => child.className === 'FromDefinition') } if (step.dslName === 'CatchDefinition') { // exception children = children.filter(value => value.name !== 'onWhen') diff --git a/karavan-space/src/designer/route/element/DslElementHeader.tsx b/karavan-space/src/designer/route/element/DslElementHeader.tsx index 7c5bdd4c4f0..c047e846463 100644 --- a/karavan-space/src/designer/route/element/DslElementHeader.tsx +++ b/karavan-space/src/designer/route/element/DslElementHeader.tsx @@ -28,6 +28,7 @@ import {shallow} from "zustand/shallow"; import {useRouteDesignerHook} from "../useRouteDesignerHook"; import {AddElementIcon, DeleteElementIcon, InsertElementIcon} from "../../utils/ElementIcons"; import { RouteConfigurationDefinition} from "karavan-core/lib/model/CamelDefinition"; +import {AutoStartupIcon, ErrorHandlerIcon} from "../../icons/OtherIcons"; interface Props { headerRef: React.RefObject @@ -103,8 +104,8 @@ export function DslElementHeader(props: Props) { return [hasStepsField, stepsChildrenCount, hasNonStepsFields, nonStepChildrenCount, childrenCount] } - function hasWideChildrenElement() { - const [hasStepsField, stepsChildrenCount, hasNonStepsFields, nonStepChildrenCount, childrenCount] = getChildrenInfo(props.step); + function getHasWideChildrenElement(childrenInfo: [boolean, number, boolean, number, number]) { + const [hasStepsField, stepsChildrenCount, hasNonStepsFields, nonStepChildrenCount, childrenCount] = childrenInfo; if (props.step.dslName === 'SetHeadersDefinition') return false; else if (isHorizontal() && stepsChildrenCount > 1) return true; else if (hasStepsField && stepsChildrenCount > 0 && hasNonStepsFields && nonStepChildrenCount > 0) return true; @@ -169,6 +170,8 @@ export function DslElementHeader(props: Props) { !['FromDefinition', 'RouteConfigurationDefinition', 'RouteDefinition', 'CatchDefinition', 'FinallyDefinition', 'WhenDefinition', 'OtherwiseDefinition'].includes(step.dslName) && !inRouteConfiguration; const headerClasses = getHeaderClasses(); + const childrenInfo = getChildrenInfo(props.step) || []; + const hasWideChildrenElement = getHasWideChildrenElement(childrenInfo) return (
{!['RouteConfigurationDefinition', 'RouteDefinition'].includes(props.step.dslName) && @@ -178,9 +181,20 @@ export function DslElementHeader(props: Props) { {CamelUi.getIconForElement(step)}
} -
- {hasWideChildrenElement() &&
} - {getHeaderTextWithTooltip(step)} + {'RouteDefinition' === step.dslName&& +
+ {(step as any).autoStartup !== false && } + {(step as any).errorHandler !== undefined && } +
+ } + {'RouteConfigurationDefinition' === step.dslName&& +
+ {(step as any).errorHandler !== undefined && } +
+ } +
+ {hasWideChildrenElement &&
} + {getHeaderTextWithTooltip(step, hasWideChildrenElement)}
{showInsertButton && getInsertElementButton()} {getDeleteButton()} @@ -199,10 +213,10 @@ export function DslElementHeader(props: Props) { } } - function getHeaderTextWithTooltip(step: CamelElement) { + function getHeaderTextWithTooltip(step: CamelElement, hasWideChildrenElement: boolean) { const title = getHeaderText(step); const checkRequired = CamelUtil.checkRequired(step); - let className = hasWideChildrenElement() ? "text text-right" : "text text-bottom"; + let className = hasWideChildrenElement ? "text text-right" : "text text-bottom"; if (!checkRequired[0]) className = className + " header-text-required"; if (checkRequired[0]) { return {title}