feat(GenericNode): add priorityFields constant to improve sorting logic in GenericNode component
The `GenericNode` component in `index.tsx` has been updated to include an import statement for the `priorityFields` constant from `constants.ts`. This constant is a `Set` containing the field names "code" and "template". In the `sort` function of the `GenericNode` component, the logic has been modified to check if a field name is present in the `priorityFields` set. If so, it gives higher priority to that field during sorting. This change improves the sorting logic in the component. The `constants.ts` file has also been updated to include the `priorityFields` constant.
This commit is contained in:
parent
b43a22fbee
commit
faea687871
2 changed files with 5 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import Tooltip from "../../components/TooltipComponent";
|
||||||
import IconComponent from "../../components/genericIconComponent";
|
import IconComponent from "../../components/genericIconComponent";
|
||||||
import InputComponent from "../../components/inputComponent";
|
import InputComponent from "../../components/inputComponent";
|
||||||
import { Textarea } from "../../components/ui/textarea";
|
import { Textarea } from "../../components/ui/textarea";
|
||||||
|
import { priorityFields } from "../../constants/constants";
|
||||||
import { useSSE } from "../../contexts/SSEContext";
|
import { useSSE } from "../../contexts/SSEContext";
|
||||||
import { FlowsContext } from "../../contexts/flowsContext";
|
import { FlowsContext } from "../../contexts/flowsContext";
|
||||||
import { typesContext } from "../../contexts/typesContext";
|
import { typesContext } from "../../contexts/typesContext";
|
||||||
|
|
@ -438,9 +439,9 @@ export default function GenericNode({
|
||||||
{Object.keys(data.node!.template)
|
{Object.keys(data.node!.template)
|
||||||
.filter((templateField) => templateField.charAt(0) !== "_")
|
.filter((templateField) => templateField.charAt(0) !== "_")
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
if (a.toLowerCase() === "code") {
|
if (priorityFields.has(a.toLowerCase())) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (b.toLowerCase() === "code") {
|
} else if (priorityFields.has(b.toLowerCase())) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return a.localeCompare(b);
|
return a.localeCompare(b);
|
||||||
|
|
|
||||||
|
|
@ -675,3 +675,5 @@ export const LANGFLOW_SUPPORTED_TYPES = new Set([
|
||||||
"dict",
|
"dict",
|
||||||
"NestedDict",
|
"NestedDict",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
export const priorityFields = new Set(["code", "template"]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue