Fix capital errors (#1061)
This commit is contained in:
commit
cbe27f867f
4 changed files with 34 additions and 33 deletions
|
|
@ -18,7 +18,7 @@ import {
|
||||||
scapedJSONStringfy,
|
scapedJSONStringfy,
|
||||||
} from "../../utils/reactflowUtils";
|
} from "../../utils/reactflowUtils";
|
||||||
import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils";
|
import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils";
|
||||||
import { classNames, toTitleCase } from "../../utils/utils";
|
import { classNames, getFieldTitle } from "../../utils/utils";
|
||||||
import ParameterComponent from "./components/parameterComponent";
|
import ParameterComponent from "./components/parameterComponent";
|
||||||
|
|
||||||
export default function GenericNode({
|
export default function GenericNode({
|
||||||
|
|
@ -239,15 +239,10 @@ export default function GenericNode({
|
||||||
] ??
|
] ??
|
||||||
nodeColors.unknown
|
nodeColors.unknown
|
||||||
}
|
}
|
||||||
title={
|
title={getFieldTitle(
|
||||||
data.node?.template[templateField].display_name
|
data.node?.template!,
|
||||||
? data.node.template[templateField].display_name
|
templateField
|
||||||
: data.node?.template[templateField].name
|
)}
|
||||||
? toTitleCase(
|
|
||||||
data.node.template[templateField].name
|
|
||||||
)
|
|
||||||
: toTitleCase(templateField)
|
|
||||||
}
|
|
||||||
info={data.node?.template[templateField].info}
|
info={data.node?.template[templateField].info}
|
||||||
name={templateField}
|
name={templateField}
|
||||||
tooltipTitle={
|
tooltipTitle={
|
||||||
|
|
@ -448,15 +443,10 @@ export default function GenericNode({
|
||||||
] ??
|
] ??
|
||||||
nodeColors.unknown
|
nodeColors.unknown
|
||||||
}
|
}
|
||||||
title={
|
title={getFieldTitle(
|
||||||
data.node?.template[templateField].display_name
|
data.node?.template!,
|
||||||
? data.node.template[templateField].display_name
|
templateField
|
||||||
: data.node?.template[templateField].name
|
)}
|
||||||
? toTitleCase(
|
|
||||||
data.node.template[templateField].name
|
|
||||||
)
|
|
||||||
: toTitleCase(templateField)
|
|
||||||
}
|
|
||||||
info={data.node?.template[templateField].info}
|
info={data.node?.template[templateField].info}
|
||||||
name={templateField}
|
name={templateField}
|
||||||
tooltipTitle={
|
tooltipTitle={
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ export type TemplateVariableType = {
|
||||||
dynamic?: boolean;
|
dynamic?: boolean;
|
||||||
proxy?: { id: string; field: string };
|
proxy?: { id: string; field: string };
|
||||||
input_types?: Array<string>;
|
input_types?: Array<string>;
|
||||||
|
display_name?: string;
|
||||||
|
name?: string;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
export type sendAllProps = {
|
export type sendAllProps = {
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,7 @@ import {
|
||||||
unselectAllNodesType,
|
unselectAllNodesType,
|
||||||
updateEdgesHandleIdsType,
|
updateEdgesHandleIdsType,
|
||||||
} from "../types/utils/reactflowUtils";
|
} from "../types/utils/reactflowUtils";
|
||||||
import { toNormalCase, toTitleCase } from "./utils";
|
import { getFieldTitle } from "./utils";
|
||||||
const uid = new ShortUniqueId({ length: 5 });
|
|
||||||
|
|
||||||
export function cleanEdges({
|
export function cleanEdges({
|
||||||
flow: { edges, nodes },
|
flow: { edges, nodes },
|
||||||
|
|
@ -240,11 +239,7 @@ export function validateNode(node: NodeType, edges: Edge[]): Array<string> {
|
||||||
node.id
|
node.id
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
errors.push(
|
errors.push(`${type} is missing ${getFieldTitle(template, t)}.`);
|
||||||
`${type} is missing ${
|
|
||||||
template.display_name || toNormalCase(template[t].name)
|
|
||||||
}.`
|
|
||||||
);
|
|
||||||
} else if (
|
} else if (
|
||||||
template[t].type === "dict" &&
|
template[t].type === "dict" &&
|
||||||
template[t].required &&
|
template[t].required &&
|
||||||
|
|
@ -255,15 +250,14 @@ export function validateNode(node: NodeType, edges: Edge[]): Array<string> {
|
||||||
) {
|
) {
|
||||||
if (hasDuplicateKeys(template[t].value))
|
if (hasDuplicateKeys(template[t].value))
|
||||||
errors.push(
|
errors.push(
|
||||||
`${type} (${
|
`${type} (${getFieldTitle(
|
||||||
template.display_name || template[t].name
|
template,
|
||||||
}) contains duplicate keys with the same values.`
|
t
|
||||||
|
)}) contains duplicate keys with the same values.`
|
||||||
);
|
);
|
||||||
if (hasEmptyKey(template[t].value))
|
if (hasEmptyKey(template[t].value))
|
||||||
errors.push(
|
errors.push(
|
||||||
`${type} (${
|
`${type} (${getFieldTitle(template, t)}) field must not be empty.`
|
||||||
template.display_name || template[t].name
|
|
||||||
}) field must not be empty.`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return errors;
|
return errors;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
import clsx, { ClassValue } from "clsx";
|
import clsx, { ClassValue } from "clsx";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "../flow_constants";
|
import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "../flow_constants";
|
||||||
import { APIDataType, TemplateVariableType } from "../types/api";
|
import {
|
||||||
|
APIDataType,
|
||||||
|
APITemplateType,
|
||||||
|
TemplateVariableType,
|
||||||
|
} from "../types/api";
|
||||||
import {
|
import {
|
||||||
IVarHighlightType,
|
IVarHighlightType,
|
||||||
groupedObjType,
|
groupedObjType,
|
||||||
|
|
@ -550,3 +554,14 @@ export function tabsArray(codes: string[], method: number) {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getFieldTitle(
|
||||||
|
template: APITemplateType,
|
||||||
|
templateField: string
|
||||||
|
): string {
|
||||||
|
return template[templateField].display_name
|
||||||
|
? template[templateField].display_name!
|
||||||
|
: template[templateField].name
|
||||||
|
? toTitleCase(template[templateField].name!)
|
||||||
|
: toTitleCase(templateField);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue