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 9d0961aa Fix #733
9d0961aa is described below
commit 9d0961aad84e00b8c836ee2bee8e003a3963a990
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Sat Apr 22 09:44:29 2023 -0400
Fix #733
---
karavan-designer/src/App.tsx | 2 +-
karavan-designer/src/components/ComponentCard.tsx | 2 +-
.../src/designer/route/DslConnections.tsx | 7 ++---
.../src/designer/route/RouteDesignerLogic.tsx | 3 +-
.../route/property/ComponentParameterField.tsx | 32 ++++++++++++++++------
5 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/karavan-designer/src/App.tsx b/karavan-designer/src/App.tsx
index e536a093..eec9ce55 100644
--- a/karavan-designer/src/App.tsx
+++ b/karavan-designer/src/App.tsx
@@ -173,7 +173,7 @@ class App extends React.Component<Props, State> {
}
getPage() {
- const {key, name, yaml, pageId} = this.state;
+ const { name, yaml, pageId} = this.state;
const dark = document.body.className.includes('vscode-dark');
switch (pageId) {
case "designer":
diff --git a/karavan-designer/src/components/ComponentCard.tsx
b/karavan-designer/src/components/ComponentCard.tsx
index c2a07924..9305a086 100644
--- a/karavan-designer/src/components/ComponentCard.tsx
+++ b/karavan-designer/src/components/ComponentCard.tsx
@@ -16,7 +16,7 @@
*/
import React from 'react';
import {
- CardHeader, Card, CardTitle, CardBody, CardFooter, Badge, Text
+ CardHeader, Card, CardTitle, CardBody, CardFooter, Badge
} from '@patternfly/react-core';
import '../designer/karavan.css';
import {camelIcon, CamelUi} from "../designer/utils/CamelUi";
diff --git a/karavan-designer/src/designer/route/DslConnections.tsx
b/karavan-designer/src/designer/route/DslConnections.tsx
index 6dc1ced3..f18866e1 100644
--- a/karavan-designer/src/designer/route/DslConnections.tsx
+++ b/karavan-designer/src/designer/route/DslConnections.tsx
@@ -32,7 +32,6 @@ interface Props {
interface State {
integration: Integration
- sub?: Subscription
steps: Map<string, DslPosition>
}
@@ -46,14 +45,14 @@ export class DslConnections extends React.Component<Props,
State> {
integration: this.props.integration,
steps: new Map<string, DslPosition>(),
};
+ sub?: Subscription;
componentDidMount() {
- const sub = EventBus.onPosition()?.subscribe((evt: DslPosition) =>
this.setPosition(evt));
- this.setState({sub: sub});
+ this.sub = EventBus.onPosition()?.subscribe((evt: DslPosition) =>
this.setPosition(evt));
}
componentWillUnmount() {
- this.state.sub?.unsubscribe();
+ this.sub?.unsubscribe();
}
setPosition(evt: DslPosition) {
diff --git a/karavan-designer/src/designer/route/RouteDesignerLogic.tsx
b/karavan-designer/src/designer/route/RouteDesignerLogic.tsx
index 92d1f414..7dc03980 100644
--- a/karavan-designer/src/designer/route/RouteDesignerLogic.tsx
+++ b/karavan-designer/src/designer/route/RouteDesignerLogic.tsx
@@ -301,7 +301,8 @@ export class RouteDesignerLogic {
setDslDefaults(step: CamelElement): CamelElement {
if (step.dslName === 'LogDefinition') {
- (step as LogDefinition).message = '${body}'
+ // eslint-disable-next-line no-template-curly-in-string
+ (step as LogDefinition).message = "${body}";
}
if (step.dslName === 'ChoiceDefinition') {
(step as
ChoiceDefinition).when?.push(CamelDefinitionApi.createStep('WhenDefinition',
undefined));
diff --git
a/karavan-designer/src/designer/route/property/ComponentParameterField.tsx
b/karavan-designer/src/designer/route/property/ComponentParameterField.tsx
index 67dd8165..faad51c8 100644
--- a/karavan-designer/src/designer/route/property/ComponentParameterField.tsx
+++ b/karavan-designer/src/designer/route/property/ComponentParameterField.tsx
@@ -39,6 +39,7 @@ import {KubernetesAPI} from "../../utils/KubernetesAPI";
import KubernetesIcon from
"@patternfly/react-icons/dist/js/icons/openshift-icon";
import ShowIcon from "@patternfly/react-icons/dist/js/icons/eye-icon";
import HideIcon from "@patternfly/react-icons/dist/js/icons/eye-slash-icon";
+import PlusIcon from "@patternfly/react-icons/dist/esm/icons/plus-icon";
const prefix = "parameters";
const beanPrefix = "#bean:";
@@ -131,12 +132,17 @@ export class ComponentParameterField extends
React.Component<Props, State> {
getInternalUriSelect = (property: ComponentProperty, value: any) => {
const selectOptions: JSX.Element[] = [];
const componentName = this.getInternalComponentName(property);
- const urls = CamelUi.getInternalRouteUris(this.props.integration,
componentName, false);
- if (urls && urls.length > 0) {
- selectOptions.push(...urls.map((value: string) =>
+ const internalUris =
CamelUi.getInternalRouteUris(this.props.integration, componentName, false);
+ const uris: string [] = [];
+ uris.push(...internalUris);
+ if (value.length > 0 && !uris.includes(value)) {
+ uris.unshift(value);
+ }
+ if (uris && uris.length > 0) {
+ selectOptions.push(...uris.map((value: string) =>
<SelectOption key={value} value={value.trim()}/>));
}
- return (
+ return <InputGroup>
<Select
placeholderText="Select or type an URI"
variant={SelectVariant.typeahead}
@@ -145,19 +151,27 @@ export class ComponentParameterField extends
React.Component<Props, State> {
this.openSelect(property.name, isExpanded)
}}
onSelect={(e, value, isPlaceholder) => {
- const newRoute = !urls.includes(value.toString()) ? new
RouteToCreate(componentName, value.toString()) : undefined;
- this.parametersChanged(property.name, (!isPlaceholder ?
value : undefined), property.kind === 'path', newRoute);
+ this.parametersChanged(property.name, (!isPlaceholder ?
value : undefined), property.kind === 'path', undefined);
}}
selections={value}
isOpen={this.isSelectOpen(property.name)}
isCreatable={true}
+ createText=""
isInputFilterPersisted={true}
aria-labelledby={property.name}
direction={SelectDirection.down}
>
{selectOptions}
</Select>
- )
+ <Tooltip position="bottom-end" content={"Create route"}>
+ <Button variant="control" onClick={e => {
+ const newRoute = !internalUris.includes(value.toString())
? new RouteToCreate(componentName, value.toString()) : undefined;
+ this.parametersChanged(property.name, value, property.kind
=== 'path', newRoute);
+ }}>
+ {<PlusIcon/>}
+ </Button>
+ </Tooltip>
+ </InputGroup>
}
selectKubernetes = (value: string) => {
@@ -280,7 +294,7 @@ export class ComponentParameterField extends
React.Component<Props, State> {
id={id} name={id}
value={value?.toString()}
aria-label={id}
- isChecked={value !== undefined ? Boolean(value) === true :
property.defaultValue !== undefined && property.defaultValue === 'true'}
+ isChecked={value !== undefined ? Boolean(value) :
property.defaultValue !== undefined && property.defaultValue === 'true'}
onChange={e => this.parametersChanged(property.name,
!Boolean(value))}/>
)
}
@@ -303,7 +317,7 @@ export class ComponentParameterField extends
React.Component<Props, State> {
footerContent={
<div>
{property.defaultValue !== undefined &&
<div>{"Default: " + property.defaultValue}</div>}
- {property.required === true &&
<div>{property.displayName + " is required"}</div>}
+ {property.required &&
<div>{property.displayName + " is required"}</div>}
</div>
}>
<button type="button" aria-label="More info"
onClick={e => e.preventDefault()}