Skip to content

Commit

Permalink
field rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Fałdrowicz committed Dec 17, 2024
1 parent d8fb287 commit c81dc67
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropsWithChildren } from "react";
import React from "react";
import { FormControl } from "@mui/material";
import { nodeInput } from "../graph/node-modal/NodeDetailsContent/NodeTableStyled";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { MutableRefObject, useEffect, useMemo } from "react";
import React, { useEffect, useMemo } from "react";
import { Button, Box, Typography } from "@mui/material";
import { useTranslation } from "react-i18next";
import { SearchLabeledInput } from "../../sidePanels/SearchLabeledInput";
Expand Down Expand Up @@ -27,10 +27,10 @@ export function AdvancedSearchFilters({
name: t("panels.search.field.id", "Name"),
description: t("panels.search.field.description", "Description"),
type: t("panels.search.field.type", "Type"),
paramName: t("panels.search.field.paramName", "Label"),
paramValue: t("panels.search.field.paramValue", "Value"),
outputValue: t("panels.search.field.outputValue", "Output"),
edgeExpression: t("panels.search.field.edgeExpression", "Edge"),
label: t("panels.search.field.paramName", "Label"),
value: t("panels.search.field.paramValue", "Value"),
output: t("panels.search.field.outputValue", "Output"),
edge: t("panels.search.field.edgeExpression", "Edge"),
}),
[t],
);
Expand Down Expand Up @@ -67,8 +67,8 @@ export function AdvancedSearchFilters({
<SearchLabeledInput name="name" value={filterFields?.name || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["name"]} />
</SearchLabeledInput>
<SearchLabeledInput name="paramValue" value={filterFields?.paramValue || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["paramValue"]} />
<SearchLabeledInput name="value" value={filterFields?.value || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["value"]} />
</SearchLabeledInput>
<SearchLabeledAutocomplete
name="type"
Expand All @@ -78,17 +78,17 @@ export function AdvancedSearchFilters({
>
<SearchLabel label={displayNames["type"]} />
</SearchLabeledAutocomplete>
<SearchLabeledInput name="paramName" value={filterFields?.paramName || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["paramName"]} />
<SearchLabeledInput name="label" value={filterFields?.label || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["label"]} />
</SearchLabeledInput>
<SearchLabeledInput name="description" value={filterFields?.description || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["description"]} />
</SearchLabeledInput>
<SearchLabeledInput name="outputValue" value={filterFields?.outputValue || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["outputValue"]} />
<SearchLabeledInput name="output" value={filterFields?.output || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["output"]} />
</SearchLabeledInput>
<SearchLabeledInput name="edgeExpression" value={filterFields?.edgeExpression || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["edgeExpression"]} />
<SearchLabeledInput name="edge" value={filterFields?.edge || []} setFilterFields={setFilterFields}>
<SearchLabel label={displayNames["edge"]} />
</SearchLabeledInput>
<Box sx={{ display: "flex", flexDirection: "row", justifyContent: "space-between", width: "100%", mt: 2, mb: 1 }}>
<Button sx={{ width: "45%" }} size="small" variant="outlined" onClick={handleClear}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ export type SearchQuery = {
name?: string[];
description?: string[];
type?: string[];
componentGroup?: string[];
paramName?: string[];
paramValue?: string[];
outputValue?: string[];
edgeExpression?: string[];
label?: string[];
value?: string[];
output?: string[];
edge?: string[];
plainQuery?: string;
};

Expand Down
32 changes: 16 additions & 16 deletions designer/client/src/components/toolbars/search/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ const fieldsSelectors: FilterSelector = [
selector: (node) => [node.nodeType, node.ref?.typ, node.ref?.id, node.type, node.service?.id],
},
{
name: "paramValue",
name: "value",
selector: (node) => node.ref?.outputVariableNames && Object.values(node.ref?.outputVariableNames),
},
{
name: "paramName",
name: "label",
selector: (node) => node.ref?.outputVariableNames && Object.keys(node.ref?.outputVariableNames),
},
{
name: "paramValue",
name: "value",
selector: (node) => [node.expression, node.exprVal, node.value],
},
{
name: "outputValue",
name: "output",
selector: (node) => [node.outputName, node.output, node.outputVar, node.varName],
},
{
name: "paramValue",
name: "value",
selector: (node) => [node.parameters, node.ref?.parameters, node.service?.parameters, node.fields].flat().map((p) => p?.expression),
},
{
name: "paramName",
name: "label",
selector: (node) => [node.parameters, node.ref?.parameters, node.service?.parameters, node.fields].flat().map((p) => p?.name),
},
];
Expand Down Expand Up @@ -123,10 +123,10 @@ export function useFilteredNodes(searchQuery: SearchQuery): {
() => ({
name: t("panels.search.field.id", "Name"),
description: t("panels.search.field.description", "Description"),
paramName: t("panels.search.field.paramName", "Label"),
paramValue: t("panels.search.field.paramValue", "Value"),
outputValue: t("panels.search.field.outputValue", "Output"),
edgeExpression: t("panels.search.field.edgeExpression", "Edge"),
label: t("panels.search.field.label", "Label"),
value: t("panels.search.field.value", "Value"),
output: t("panels.search.field.output", "Output"),
edge: t("panels.search.field.edge", "Edge"),
type: t("panels.search.field.type", "Type"),
}),
[t],
Expand All @@ -145,7 +145,7 @@ export function useFilteredNodes(searchQuery: SearchQuery): {
.filter((e) => matchFilters(e.edgeType?.condition, [searchQuery.plainQuery]));

groups = findFields([searchQuery.plainQuery], node)
.concat(edges.length ? "edgeExpression" : null)
.concat(edges.length ? "edge" : null)
.map((name) => displayNames[name])
.filter(Boolean);

Expand All @@ -156,15 +156,15 @@ export function useFilteredNodes(searchQuery: SearchQuery): {
.filter((e) => matchFilters(e.edgeType?.condition, [searchQuery.plainQuery]));

const groupsAux: string[] = findFields([searchQuery.plainQuery], node)
.concat(edgesAux.length ? "edgeExpression" : null)
.concat(edgesAux.length ? "edge" : null)
.map((name) => displayNames[name])
.filter(Boolean);

edges =
"edgeExpression" in searchQuery
"edge" in searchQuery
? allEdges
.filter((e) => e.from === node.id)
.filter((e) => matchFilters(e.edgeType?.condition, searchQuery.edgeExpression))
.filter((e) => matchFilters(e.edgeType?.condition, searchQuery.edge))
: [];

const keyNamesRelevantForFiltering = Object.keys(searchQuery).filter(
Expand All @@ -178,7 +178,7 @@ export function useFilteredNodes(searchQuery: SearchQuery): {
groups = keyNamesRelevantForFiltering
.map((key) => findFieldsUsingSelectorWithName(key, searchQuery[key], node))
.flat()
.concat(edges.length ? "edgeExpression" : null)
.concat(edges.length ? "edge" : null)
.map((name) => displayNames[name])
.filter(Boolean);

Expand Down Expand Up @@ -223,7 +223,7 @@ export function searchQueryToString(query: SearchQuery): string {
const formattedParts = Object.entries(query)
.filter(([key]) => key !== "plainQuery")
.map(([key, value]) => {
if (Array.isArray(value)) {
if (Array.isArray(value) && !(value.length === 1 && value[0] === "")) {
return `${key}:(${value})`;
} else if (typeof value === "string" && value.length > 0) {
return `${key}:(${[value]})`;
Expand Down

0 comments on commit c81dc67

Please sign in to comment.