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 d5f8a69 Fix for Camel-karavan-489 (#517)
d5f8a69 is described below
commit d5f8a6983019e117bcc1af03fd5efed57eb777ff
Author: Mrinal Sharma <[email protected]>
AuthorDate: Fri Nov 4 20:17:42 2022 -0400
Fix for Camel-karavan-489 (#517)
---
karavan-designer/src/designer/route/DslSelector.tsx | 13 ++-----------
karavan-designer/src/designer/utils/CamelUi.tsx | 20 +++++++++++++++-----
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/karavan-designer/src/designer/route/DslSelector.tsx
b/karavan-designer/src/designer/route/DslSelector.tsx
index 5e5d387..c36d76a 100644
--- a/karavan-designer/src/designer/route/DslSelector.tsx
+++ b/karavan-designer/src/designer/route/DslSelector.tsx
@@ -72,15 +72,6 @@ export class DslSelector extends React.Component<Props,
State> {
this.props.onDslSelect.call(this, dsl, this.props.parentId,
this.props.position);
}
- checkFilter = (dsl: DslMetaModel): boolean => {
- if (this.state.filter !== undefined) {
- return
dsl.title.toLowerCase().includes(this.state.filter.toLowerCase())
- ||
dsl.description.toLowerCase().includes(this.state.filter.toLowerCase());
- } else {
- return true;
- }
- }
-
searchInput = () => {
return (
<Form isHorizontal className="search" autoComplete="off">
@@ -148,7 +139,7 @@ export class DslSelector extends React.Component<Props,
State> {
<FlexItem>
<Tabs style={{overflow: 'hidden'}}
activeKey={this.state.tabIndex}
onSelect={this.selectTab}>
- {CamelUi.getSelectorModelTypes(parentDsl,
this.props.showSteps).map((label: [string, number], index: number) => {
+ {CamelUi.getSelectorModelTypes(parentDsl,
this.props.showSteps,this.state.filter).map((label: [string, number], index:
number) => {
const labelText = label[0];
const count = label[1];
const title = ['kamelet',
'component'].includes(labelText.toLowerCase()) ? labelText + "s (" + count +
")" : labelText;
@@ -166,7 +157,7 @@ export class DslSelector extends React.Component<Props,
State> {
<PageSection variant={this.props.dark ? "darker" : "light"}>
<Gallery key={"gallery-" + labelText} hasGutter
className="dsl-gallery">
{CamelUi.getSelectorModelsForParentFiltered(parentDsl,
labelText, this.props.showSteps)
- .filter((dsl: DslMetaModel) =>
this.checkFilter(dsl))
+ .filter((dsl: DslMetaModel) =>
CamelUi.checkFilter(dsl, this.state.filter))
.map((dsl: DslMetaModel, index: number) =>
this.getCard(dsl, index))}
</Gallery>
</PageSection>
diff --git a/karavan-designer/src/designer/utils/CamelUi.tsx
b/karavan-designer/src/designer/utils/CamelUi.tsx
index 40252a9..3083c36 100644
--- a/karavan-designer/src/designer/utils/CamelUi.tsx
+++ b/karavan-designer/src/designer/utils/CamelUi.tsx
@@ -86,14 +86,24 @@ export class RouteToCreate {
export class CamelUi {
- static getSelectorModelTypes = (parentDsl: string | undefined, showSteps:
boolean = true): [string, number][] => {
+ static getSelectorModelTypes = (parentDsl: string | undefined, showSteps:
boolean = true, filter:string|undefined = undefined): [string, number][] => {
const navs = CamelUi.getSelectorModelsForParent(parentDsl,
showSteps).map(dsl => dsl.navigation.split(","))
.reduce((accumulator, value) => accumulator.concat(value), [])
.filter((nav, i, arr) => arr.findIndex(l => l === nav) === i)
.filter((nav, i, arr) => ![ 'dataformat'].includes(nav));
const connectorNavs = ['routing', "transformation", "error",
"configuration", "endpoint", "kamelet", "component"];
const eipLabels = connectorNavs.filter(n => navs.includes(n));
- return eipLabels.map(label => [label,
this.getSelectorModelsForParentFiltered(parentDsl, label, true).length]);
+ return eipLabels.map(label => [label,
this.getSelectorModelsForParentFiltered(parentDsl, label, true)
+ .filter((dsl: DslMetaModel) => filter === undefined ? true :
CamelUi.checkFilter(dsl, filter)).length]);
+ }
+
+ static checkFilter = (dsl: DslMetaModel, filter:string|undefined =
undefined): boolean => {
+ if (filter !== undefined && filter !== "") {
+ return dsl.title.toLowerCase().includes(filter.toLowerCase())
+ ||
dsl.description.toLowerCase().includes(filter.toLowerCase());
+ } else {
+ return true;
+ }
}
static dslHasSteps = (className: string): boolean => {
@@ -108,8 +118,8 @@ export class CamelUi {
static getSelectorModelsForParentFiltered = (parentDsl: string |
undefined, navigation: string, showSteps: boolean = true): DslMetaModel[] => {
return CamelUi.getSelectorModelsForParent(parentDsl, showSteps)
.filter(dsl => dsl.navigation.includes(navigation));
- }
-
+
+ }
static getSelectorModelsForParent = (parentDsl: string | undefined,
showSteps: boolean = true): DslMetaModel[] => {
const result: DslMetaModel[] = [];
if (!parentDsl){
@@ -511,4 +521,4 @@ export class CamelUi {
}
return result;
}
-}
+}
\ No newline at end of file