Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mgubaidullin committed Sep 16, 2024
1 parent d59cb2e commit fc55e62
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import {CamelElement} from "karavan-core/lib/model/IntegrationDefinition";
import {CamelDefinitionApi} from "karavan-core/lib/api/CamelDefinitionApi";
import {DslPropertyField} from "./DslPropertyField";
import {CamelUi} from "../../utils/CamelUi";
import {usePropertiesStore} from "../PropertyStore";
import {shallow} from "zustand/shallow";
import {PropertyUtil} from "./PropertyUtil";

interface Props {
property: PropertyMeta,
Expand All @@ -45,6 +48,8 @@ interface Props {

export function ExpressionField(props: Props) {


const [propertyFilter, changedOnly, requiredOnly] = usePropertiesStore((s) => [s.propertyFilter, s.changedOnly, s.requiredOnly], shallow)
const [selectIsOpen, setSelectIsOpen] = useState<boolean>(false);
const [propsAreOpen, setPropsAreOpen] = useState<boolean>(false);

Expand Down Expand Up @@ -91,10 +96,32 @@ export function ExpressionField(props: Props) {

function getProps (): PropertyMeta[] {
const dslName = getValueClassName();
return CamelDefinitionApiExt.getElementProperties(dslName)
const filter = propertyFilter.toLocaleLowerCase();
let propertyMetas = CamelDefinitionApiExt.getElementProperties(dslName)
.filter(p => p.name !== 'id')
.filter(p => p.name !== 'expression')
.filter(p => !p.isObject || (p.isObject && !CamelUi.dslHasSteps(p.type)) || (dslName === 'CatchDefinition' && p.name === 'onWhen'));
.filter(p => !p.isObject || (p.isObject && !CamelUi.dslHasSteps(p.type)) || (dslName === 'CatchDefinition' && p.name === 'onWhen'))
.filter(p => p.name === 'parameters' || p.name.toLocaleLowerCase().includes(filter) || p.label.toLocaleLowerCase().includes(filter) || p.displayName.toLocaleLowerCase().includes(filter));
if (requiredOnly) {
propertyMetas = propertyMetas.filter(p => p.name === 'parameters' || p.required);
}
if (changedOnly) {
propertyMetas = propertyMetas.filter(p => p.name === 'parameters' || PropertyUtil.hasDslPropertyValueChanged(p, getPropertyValue(p)));
}
return propertyMetas
}

function getPropertyValue(property: PropertyMeta) {
const value = getExpressionValue();
return value ? (value as any)[property.name] : undefined;
}

function getPropertySelectorChanged(): boolean {
return requiredOnly || changedOnly || propertyFilter?.trim().length > 0;
}

function getShowExpanded(): boolean {
return propsAreOpen || getPropertySelectorChanged();
}

function getExpressionProps (): PropertyMeta | undefined {
Expand Down Expand Up @@ -165,7 +192,7 @@ export function ExpressionField(props: Props) {
<ExpandableSection
toggleText={'Expression properties'}
onToggle={(_event, isExpanded) => setPropsAreOpen(isExpanded)}
isExpanded={propsAreOpen}>
isExpanded={getShowExpanded()}>
{value && getProps().map((property: PropertyMeta) =>
<DslPropertyField key={property.name + props.value?.uuid}
property={property}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export function DslElementHeader(props: Props) {
return (
<>
{getHeader()}
<Tooltip triggerRef={props.headerRef} position={"left"} content={<div style={{textAlign: 'left'}}>{tooltip}</div>}/>
<Tooltip triggerRef={props.headerRef} entryDelay={700} position={"left"} content={<div style={{textAlign: 'left'}}>{tooltip}</div>}/>
</>

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import {CamelElement} from "karavan-core/lib/model/IntegrationDefinition";
import {CamelDefinitionApi} from "karavan-core/lib/api/CamelDefinitionApi";
import {DslPropertyField} from "./DslPropertyField";
import {CamelUi} from "../../utils/CamelUi";
import {usePropertiesStore} from "../PropertyStore";
import {shallow} from "zustand/shallow";
import {PropertyUtil} from "./PropertyUtil";

interface Props {
property: PropertyMeta,
Expand All @@ -45,6 +48,8 @@ interface Props {

export function ExpressionField(props: Props) {


const [propertyFilter, changedOnly, requiredOnly] = usePropertiesStore((s) => [s.propertyFilter, s.changedOnly, s.requiredOnly], shallow)
const [selectIsOpen, setSelectIsOpen] = useState<boolean>(false);
const [propsAreOpen, setPropsAreOpen] = useState<boolean>(false);

Expand Down Expand Up @@ -91,10 +96,32 @@ export function ExpressionField(props: Props) {

function getProps (): PropertyMeta[] {
const dslName = getValueClassName();
return CamelDefinitionApiExt.getElementProperties(dslName)
const filter = propertyFilter.toLocaleLowerCase();
let propertyMetas = CamelDefinitionApiExt.getElementProperties(dslName)
.filter(p => p.name !== 'id')
.filter(p => p.name !== 'expression')
.filter(p => !p.isObject || (p.isObject && !CamelUi.dslHasSteps(p.type)) || (dslName === 'CatchDefinition' && p.name === 'onWhen'));
.filter(p => !p.isObject || (p.isObject && !CamelUi.dslHasSteps(p.type)) || (dslName === 'CatchDefinition' && p.name === 'onWhen'))
.filter(p => p.name === 'parameters' || p.name.toLocaleLowerCase().includes(filter) || p.label.toLocaleLowerCase().includes(filter) || p.displayName.toLocaleLowerCase().includes(filter));
if (requiredOnly) {
propertyMetas = propertyMetas.filter(p => p.name === 'parameters' || p.required);
}
if (changedOnly) {
propertyMetas = propertyMetas.filter(p => p.name === 'parameters' || PropertyUtil.hasDslPropertyValueChanged(p, getPropertyValue(p)));
}
return propertyMetas
}

function getPropertyValue(property: PropertyMeta) {
const value = getExpressionValue();
return value ? (value as any)[property.name] : undefined;
}

function getPropertySelectorChanged(): boolean {
return requiredOnly || changedOnly || propertyFilter?.trim().length > 0;
}

function getShowExpanded(): boolean {
return propsAreOpen || getPropertySelectorChanged();
}

function getExpressionProps (): PropertyMeta | undefined {
Expand Down Expand Up @@ -165,7 +192,7 @@ export function ExpressionField(props: Props) {
<ExpandableSection
toggleText={'Expression properties'}
onToggle={(_event, isExpanded) => setPropsAreOpen(isExpanded)}
isExpanded={propsAreOpen}>
isExpanded={getShowExpanded()}>
{value && getProps().map((property: PropertyMeta) =>
<DslPropertyField key={property.name + props.value?.uuid}
property={property}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export function DslElementHeader(props: Props) {
return (
<>
{getHeader()}
<Tooltip triggerRef={props.headerRef} position={"left"} content={<div style={{textAlign: 'left'}}>{tooltip}</div>}/>
<Tooltip triggerRef={props.headerRef} entryDelay={700} position={"left"} content={<div style={{textAlign: 'left'}}>{tooltip}</div>}/>
</>

)
Expand Down
33 changes: 30 additions & 3 deletions karavan-space/src/designer/property/property/ExpressionField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import {CamelElement} from "karavan-core/lib/model/IntegrationDefinition";
import {CamelDefinitionApi} from "karavan-core/lib/api/CamelDefinitionApi";
import {DslPropertyField} from "./DslPropertyField";
import {CamelUi} from "../../utils/CamelUi";
import {usePropertiesStore} from "../PropertyStore";
import {shallow} from "zustand/shallow";
import {PropertyUtil} from "./PropertyUtil";

interface Props {
property: PropertyMeta,
Expand All @@ -45,6 +48,8 @@ interface Props {

export function ExpressionField(props: Props) {


const [propertyFilter, changedOnly, requiredOnly] = usePropertiesStore((s) => [s.propertyFilter, s.changedOnly, s.requiredOnly], shallow)
const [selectIsOpen, setSelectIsOpen] = useState<boolean>(false);
const [propsAreOpen, setPropsAreOpen] = useState<boolean>(false);

Expand Down Expand Up @@ -91,10 +96,32 @@ export function ExpressionField(props: Props) {

function getProps (): PropertyMeta[] {
const dslName = getValueClassName();
return CamelDefinitionApiExt.getElementProperties(dslName)
const filter = propertyFilter.toLocaleLowerCase();
let propertyMetas = CamelDefinitionApiExt.getElementProperties(dslName)
.filter(p => p.name !== 'id')
.filter(p => p.name !== 'expression')
.filter(p => !p.isObject || (p.isObject && !CamelUi.dslHasSteps(p.type)) || (dslName === 'CatchDefinition' && p.name === 'onWhen'));
.filter(p => !p.isObject || (p.isObject && !CamelUi.dslHasSteps(p.type)) || (dslName === 'CatchDefinition' && p.name === 'onWhen'))
.filter(p => p.name === 'parameters' || p.name.toLocaleLowerCase().includes(filter) || p.label.toLocaleLowerCase().includes(filter) || p.displayName.toLocaleLowerCase().includes(filter));
if (requiredOnly) {
propertyMetas = propertyMetas.filter(p => p.name === 'parameters' || p.required);
}
if (changedOnly) {
propertyMetas = propertyMetas.filter(p => p.name === 'parameters' || PropertyUtil.hasDslPropertyValueChanged(p, getPropertyValue(p)));
}
return propertyMetas
}

function getPropertyValue(property: PropertyMeta) {
const value = getExpressionValue();
return value ? (value as any)[property.name] : undefined;
}

function getPropertySelectorChanged(): boolean {
return requiredOnly || changedOnly || propertyFilter?.trim().length > 0;
}

function getShowExpanded(): boolean {
return propsAreOpen || getPropertySelectorChanged();
}

function getExpressionProps (): PropertyMeta | undefined {
Expand Down Expand Up @@ -165,7 +192,7 @@ export function ExpressionField(props: Props) {
<ExpandableSection
toggleText={'Expression properties'}
onToggle={(_event, isExpanded) => setPropsAreOpen(isExpanded)}
isExpanded={propsAreOpen}>
isExpanded={getShowExpanded()}>
{value && getProps().map((property: PropertyMeta) =>
<DslPropertyField key={property.name + props.value?.uuid}
property={property}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export function DslElementHeader(props: Props) {
return (
<>
{getHeader()}
<Tooltip triggerRef={props.headerRef} position={"left"} content={<div style={{textAlign: 'left'}}>{tooltip}</div>}/>
<Tooltip triggerRef={props.headerRef} entryDelay={700} position={"left"} content={<div style={{textAlign: 'left'}}>{tooltip}</div>}/>
</>

)
Expand Down

0 comments on commit fc55e62

Please sign in to comment.