Skip to content

Commit e2a0969

Browse files
committed
issues with beans
1 parent 389b732 commit e2a0969

File tree

6 files changed

+126
-135
lines changed

6 files changed

+126
-135
lines changed

karavan-app/src/main/webui/src/designer/property/property/DslPropertyField.tsx

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ export function DslPropertyField(props: Props) {
470470
}
471471

472472
function showCode(name: string, javaType: string) {
473+
console.log(name, javaType)
473474
const {property} = props;
474475
InfrastructureAPI.onGetCustomCode?.(name, property.javaType).then(value => {
475476
if (value === undefined) {
@@ -487,6 +488,7 @@ export function DslPropertyField(props: Props) {
487488
const {dslLanguage} = props;
488489
const selectOptions: SelectOptionProps[] = [];
489490
if (beans) {
491+
console.log(beans)
490492
selectOptions.push(...beans.map((bean) => {
491493
return {value: beanPrefix + bean.name, children: bean.name}
492494
}));
@@ -497,51 +499,46 @@ export function DslPropertyField(props: Props) {
497499
})
498500
);
499501
}
502+
if (selectOptions.filter(o => o.value === value?.toString()).length === 0) {
503+
selectOptions.push({
504+
value: value, children: value, description: 'Custom Bean'
505+
})
506+
}
500507
return (
501-
<SelectField
502-
id={property.name}
503-
name={property.name}
504-
placeholder='Select bean'
505-
selectOptions={selectOptions}
506-
value={value?.toString()}
507-
onChange={(name, value) => propertyChanged(property.name, value)}
508-
/>
509-
// <InputGroup>
510-
// <InputGroupItem isFill>
511-
// <TextInput
512-
// ref={ref}
513-
// className="text-field" isRequired
514-
// type="text"
515-
// id={property.name} name={property.name}
516-
// value={value?.toString()}
517-
// onChange={(_, value) => {
518-
// propertyChanged(property.name, CamelUtil.capitalizeName(value?.replace(/\s/g, '')))
519-
// }}
520-
// readOnlyVariant={isUriReadOnly(property) ? "default" : undefined}/>
521-
// </InputGroupItem>
522-
// <InputGroupItem>
523-
// <Tooltip position="bottom-end" content={"Create Java Class"}>
524-
// <Button isDisabled={value?.length === 0} variant="control"
525-
// onClick={e => showCode(value, property.javaType)}>
526-
// <PlusIcon/>
527-
// </Button>
528-
// </Tooltip>
529-
// </InputGroupItem>
530-
// {showEditor && <InputGroupItem>
531-
// <ExpressionModalEditor name={property.name}
532-
// customCode={customCode}
533-
// showEditor={showEditor}
534-
// dark={dark}
535-
// dslLanguage={dslLanguage}
536-
// title="Java Class"
537-
// onClose={() => setShowEditor(false)}
538-
// onSave={(fieldId, value1) => {
539-
// propertyChanged(fieldId, value);
540-
// InfrastructureAPI.onSaveCustomCode?.(value, value1);
541-
// setShowEditor(false)
542-
// }}/>
543-
// </InputGroupItem>}
544-
// </InputGroup>
508+
<InputGroup>
509+
<InputGroupItem isFill>
510+
<SelectField
511+
id={property.name}
512+
name={property.name}
513+
placeholder='Select bean'
514+
selectOptions={selectOptions}
515+
value={value?.toString()}
516+
onChange={(name, value) => propertyChanged(property.name, value)}
517+
/>
518+
</InputGroupItem>
519+
<InputGroupItem>
520+
<Tooltip position="bottom-end" content={"Create Java Class"}>
521+
<Button isDisabled={value?.length === 0} variant="control"
522+
onClick={e => showCode(value, property.javaType)}>
523+
<PlusIcon/>
524+
</Button>
525+
</Tooltip>
526+
</InputGroupItem>
527+
{showEditor && <InputGroupItem>
528+
<ExpressionModalEditor name={property.name}
529+
customCode={customCode}
530+
showEditor={showEditor}
531+
dark={dark}
532+
dslLanguage={dslLanguage}
533+
title="Java Class"
534+
onClose={() => setShowEditor(false)}
535+
onSave={(fieldId, value1) => {
536+
propertyChanged(fieldId, value);
537+
InfrastructureAPI.onSaveCustomCode?.(value, value1);
538+
setShowEditor(false)
539+
}}/>
540+
</InputGroupItem>}
541+
</InputGroup>
545542
)
546543
}
547544

karavan-app/src/main/webui/src/designer/property/property/SelectField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function SelectField(props: Props) {
8282
setSelectOptions(newSelectOptions);
8383
}, [filterValue]);
8484

85-
const createItemId = (value: any) => `select-typeahead-${value.replace(' ', '-')}`;
85+
const createItemId = (value: any) => `select-typeahead-${value?.replace(' ', '-')}`;
8686

8787
const setActiveAndFocusedItem = (itemIndex: number) => {
8888
setFocusedItemIndex(itemIndex);

karavan-designer/src/designer/property/property/DslPropertyField.tsx

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ export function DslPropertyField(props: Props) {
470470
}
471471

472472
function showCode(name: string, javaType: string) {
473+
console.log(name, javaType)
473474
const {property} = props;
474475
InfrastructureAPI.onGetCustomCode?.(name, property.javaType).then(value => {
475476
if (value === undefined) {
@@ -487,6 +488,7 @@ export function DslPropertyField(props: Props) {
487488
const {dslLanguage} = props;
488489
const selectOptions: SelectOptionProps[] = [];
489490
if (beans) {
491+
console.log(beans)
490492
selectOptions.push(...beans.map((bean) => {
491493
return {value: beanPrefix + bean.name, children: bean.name}
492494
}));
@@ -497,51 +499,46 @@ export function DslPropertyField(props: Props) {
497499
})
498500
);
499501
}
502+
if (selectOptions.filter(o => o.value === value?.toString()).length === 0) {
503+
selectOptions.push({
504+
value: value, children: value, description: 'Custom Bean'
505+
})
506+
}
500507
return (
501-
<SelectField
502-
id={property.name}
503-
name={property.name}
504-
placeholder='Select bean'
505-
selectOptions={selectOptions}
506-
value={value?.toString()}
507-
onChange={(name, value) => propertyChanged(property.name, value)}
508-
/>
509-
// <InputGroup>
510-
// <InputGroupItem isFill>
511-
// <TextInput
512-
// ref={ref}
513-
// className="text-field" isRequired
514-
// type="text"
515-
// id={property.name} name={property.name}
516-
// value={value?.toString()}
517-
// onChange={(_, value) => {
518-
// propertyChanged(property.name, CamelUtil.capitalizeName(value?.replace(/\s/g, '')))
519-
// }}
520-
// readOnlyVariant={isUriReadOnly(property) ? "default" : undefined}/>
521-
// </InputGroupItem>
522-
// <InputGroupItem>
523-
// <Tooltip position="bottom-end" content={"Create Java Class"}>
524-
// <Button isDisabled={value?.length === 0} variant="control"
525-
// onClick={e => showCode(value, property.javaType)}>
526-
// <PlusIcon/>
527-
// </Button>
528-
// </Tooltip>
529-
// </InputGroupItem>
530-
// {showEditor && <InputGroupItem>
531-
// <ExpressionModalEditor name={property.name}
532-
// customCode={customCode}
533-
// showEditor={showEditor}
534-
// dark={dark}
535-
// dslLanguage={dslLanguage}
536-
// title="Java Class"
537-
// onClose={() => setShowEditor(false)}
538-
// onSave={(fieldId, value1) => {
539-
// propertyChanged(fieldId, value);
540-
// InfrastructureAPI.onSaveCustomCode?.(value, value1);
541-
// setShowEditor(false)
542-
// }}/>
543-
// </InputGroupItem>}
544-
// </InputGroup>
508+
<InputGroup>
509+
<InputGroupItem isFill>
510+
<SelectField
511+
id={property.name}
512+
name={property.name}
513+
placeholder='Select bean'
514+
selectOptions={selectOptions}
515+
value={value?.toString()}
516+
onChange={(name, value) => propertyChanged(property.name, value)}
517+
/>
518+
</InputGroupItem>
519+
<InputGroupItem>
520+
<Tooltip position="bottom-end" content={"Create Java Class"}>
521+
<Button isDisabled={value?.length === 0} variant="control"
522+
onClick={e => showCode(value, property.javaType)}>
523+
<PlusIcon/>
524+
</Button>
525+
</Tooltip>
526+
</InputGroupItem>
527+
{showEditor && <InputGroupItem>
528+
<ExpressionModalEditor name={property.name}
529+
customCode={customCode}
530+
showEditor={showEditor}
531+
dark={dark}
532+
dslLanguage={dslLanguage}
533+
title="Java Class"
534+
onClose={() => setShowEditor(false)}
535+
onSave={(fieldId, value1) => {
536+
propertyChanged(fieldId, value);
537+
InfrastructureAPI.onSaveCustomCode?.(value, value1);
538+
setShowEditor(false)
539+
}}/>
540+
</InputGroupItem>}
541+
</InputGroup>
545542
)
546543
}
547544

karavan-designer/src/designer/property/property/SelectField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function SelectField(props: Props) {
8282
setSelectOptions(newSelectOptions);
8383
}, [filterValue]);
8484

85-
const createItemId = (value: any) => `select-typeahead-${value.replace(' ', '-')}`;
85+
const createItemId = (value: any) => `select-typeahead-${value?.replace(' ', '-')}`;
8686

8787
const setActiveAndFocusedItem = (itemIndex: number) => {
8888
setFocusedItemIndex(itemIndex);

karavan-space/src/designer/property/property/DslPropertyField.tsx

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ export function DslPropertyField(props: Props) {
470470
}
471471

472472
function showCode(name: string, javaType: string) {
473+
console.log(name, javaType)
473474
const {property} = props;
474475
InfrastructureAPI.onGetCustomCode?.(name, property.javaType).then(value => {
475476
if (value === undefined) {
@@ -487,6 +488,7 @@ export function DslPropertyField(props: Props) {
487488
const {dslLanguage} = props;
488489
const selectOptions: SelectOptionProps[] = [];
489490
if (beans) {
491+
console.log(beans)
490492
selectOptions.push(...beans.map((bean) => {
491493
return {value: beanPrefix + bean.name, children: bean.name}
492494
}));
@@ -497,51 +499,46 @@ export function DslPropertyField(props: Props) {
497499
})
498500
);
499501
}
502+
if (selectOptions.filter(o => o.value === value?.toString()).length === 0) {
503+
selectOptions.push({
504+
value: value, children: value, description: 'Custom Bean'
505+
})
506+
}
500507
return (
501-
<SelectField
502-
id={property.name}
503-
name={property.name}
504-
placeholder='Select bean'
505-
selectOptions={selectOptions}
506-
value={value?.toString()}
507-
onChange={(name, value) => propertyChanged(property.name, value)}
508-
/>
509-
// <InputGroup>
510-
// <InputGroupItem isFill>
511-
// <TextInput
512-
// ref={ref}
513-
// className="text-field" isRequired
514-
// type="text"
515-
// id={property.name} name={property.name}
516-
// value={value?.toString()}
517-
// onChange={(_, value) => {
518-
// propertyChanged(property.name, CamelUtil.capitalizeName(value?.replace(/\s/g, '')))
519-
// }}
520-
// readOnlyVariant={isUriReadOnly(property) ? "default" : undefined}/>
521-
// </InputGroupItem>
522-
// <InputGroupItem>
523-
// <Tooltip position="bottom-end" content={"Create Java Class"}>
524-
// <Button isDisabled={value?.length === 0} variant="control"
525-
// onClick={e => showCode(value, property.javaType)}>
526-
// <PlusIcon/>
527-
// </Button>
528-
// </Tooltip>
529-
// </InputGroupItem>
530-
// {showEditor && <InputGroupItem>
531-
// <ExpressionModalEditor name={property.name}
532-
// customCode={customCode}
533-
// showEditor={showEditor}
534-
// dark={dark}
535-
// dslLanguage={dslLanguage}
536-
// title="Java Class"
537-
// onClose={() => setShowEditor(false)}
538-
// onSave={(fieldId, value1) => {
539-
// propertyChanged(fieldId, value);
540-
// InfrastructureAPI.onSaveCustomCode?.(value, value1);
541-
// setShowEditor(false)
542-
// }}/>
543-
// </InputGroupItem>}
544-
// </InputGroup>
508+
<InputGroup>
509+
<InputGroupItem isFill>
510+
<SelectField
511+
id={property.name}
512+
name={property.name}
513+
placeholder='Select bean'
514+
selectOptions={selectOptions}
515+
value={value?.toString()}
516+
onChange={(name, value) => propertyChanged(property.name, value)}
517+
/>
518+
</InputGroupItem>
519+
<InputGroupItem>
520+
<Tooltip position="bottom-end" content={"Create Java Class"}>
521+
<Button isDisabled={value?.length === 0} variant="control"
522+
onClick={e => showCode(value, property.javaType)}>
523+
<PlusIcon/>
524+
</Button>
525+
</Tooltip>
526+
</InputGroupItem>
527+
{showEditor && <InputGroupItem>
528+
<ExpressionModalEditor name={property.name}
529+
customCode={customCode}
530+
showEditor={showEditor}
531+
dark={dark}
532+
dslLanguage={dslLanguage}
533+
title="Java Class"
534+
onClose={() => setShowEditor(false)}
535+
onSave={(fieldId, value1) => {
536+
propertyChanged(fieldId, value);
537+
InfrastructureAPI.onSaveCustomCode?.(value, value1);
538+
setShowEditor(false)
539+
}}/>
540+
</InputGroupItem>}
541+
</InputGroup>
545542
)
546543
}
547544

karavan-space/src/designer/property/property/SelectField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function SelectField(props: Props) {
8282
setSelectOptions(newSelectOptions);
8383
}, [filterValue]);
8484

85-
const createItemId = (value: any) => `select-typeahead-${value.replace(' ', '-')}`;
85+
const createItemId = (value: any) => `select-typeahead-${value?.replace(' ', '-')}`;
8686

8787
const setActiveAndFocusedItem = (itemIndex: number) => {
8888
setFocusedItemIndex(itemIndex);

0 commit comments

Comments
 (0)