fix: Add TableNodeComponent and set default formatter type (#3382)
* feat: Add TableNodeComponent for rendering table data in ParameterRenderComponent * refactor: Set default formatter type for columns in FormatColumns function * [autofix.ci] apply automated fixes * refactor: Improve object rendering in ObjectRender component --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
640f1becf3
commit
26bc6bc645
5 changed files with 33 additions and 13 deletions
|
|
@ -7,12 +7,20 @@ export default function ObjectRender({
|
||||||
object: any;
|
object: any;
|
||||||
setValue?: (value: any) => void;
|
setValue?: (value: any) => void;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
let preview =
|
let newObject = object;
|
||||||
object === null || object === undefined ? "" : JSON.stringify(object);
|
if (typeof object === "string") {
|
||||||
if (object === null || object === undefined) {
|
try {
|
||||||
|
newObject = JSON.parse(object);
|
||||||
|
} catch (e) {
|
||||||
|
newObject = object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
let preview =
|
||||||
|
newObject === null || newObject === undefined
|
||||||
|
? ""
|
||||||
|
: JSON.stringify(newObject);
|
||||||
return (
|
return (
|
||||||
<DictAreaModal onChange={setValue} value={object ?? {}}>
|
<DictAreaModal onChange={setValue} value={newObject ?? {}}>
|
||||||
<div className="flex h-full w-full items-center align-middle transition-all">
|
<div className="flex h-full w-full items-center align-middle transition-all">
|
||||||
<div className="truncate">{preview}</div>
|
<div className="truncate">{preview}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { handleOnNewValueType } from "@/CustomNodes/hooks/use-handle-new-value";
|
||||||
import { TEXT_FIELD_TYPES } from "@/constants/constants";
|
import { TEXT_FIELD_TYPES } from "@/constants/constants";
|
||||||
import { APIClassType, InputFieldType } from "@/types/api";
|
import { APIClassType, InputFieldType } from "@/types/api";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
|
import TableNodeComponent from "../TableNodeComponent";
|
||||||
import CodeAreaComponent from "../codeAreaComponent";
|
import CodeAreaComponent from "../codeAreaComponent";
|
||||||
import DictComponent from "../dictComponent";
|
import DictComponent from "../dictComponent";
|
||||||
import FloatComponent from "../floatComponent";
|
import FloatComponent from "../floatComponent";
|
||||||
|
|
@ -146,6 +147,14 @@ export function ParameterRenderComponent({
|
||||||
/>
|
/>
|
||||||
) : templateData.type === "Any" ? (
|
) : templateData.type === "Any" ? (
|
||||||
<>-</>
|
<>-</>
|
||||||
|
) : templateData.type === "table" ? (
|
||||||
|
<TableNodeComponent
|
||||||
|
description={templateData.info || "Add or edit data"}
|
||||||
|
columns={templateData?.table_schema?.columns}
|
||||||
|
onChange={onChange}
|
||||||
|
tableTitle={templateData?.display_name ?? "Table"}
|
||||||
|
value={templateValue}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
String(templateValue)
|
String(templateValue)
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -646,6 +646,7 @@ export const LANGFLOW_SUPPORTED_TYPES = new Set([
|
||||||
"int",
|
"int",
|
||||||
"dict",
|
"dict",
|
||||||
"NestedDict",
|
"NestedDict",
|
||||||
|
"table",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const priorityFields = new Set(["code", "template"]);
|
export const priorityFields = new Set(["code", "template"]);
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ export type InputFieldType = {
|
||||||
refresh_button?: boolean;
|
refresh_button?: boolean;
|
||||||
refresh_button_text?: string;
|
refresh_button_text?: string;
|
||||||
combobox?: boolean;
|
combobox?: boolean;
|
||||||
|
info?: string;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -502,15 +502,16 @@ export function FormatColumns(columns: ColumnField[]): ColDef<any>[] {
|
||||||
sortable: col.sortable,
|
sortable: col.sortable,
|
||||||
filter: col.filterable,
|
filter: col.filterable,
|
||||||
};
|
};
|
||||||
if (col.formatter) {
|
if (!col.formatter) {
|
||||||
if (basic_types.has(col.formatter)) {
|
col.formatter = FormatterType.text;
|
||||||
newCol.cellDataType = col.formatter;
|
}
|
||||||
} else {
|
if (basic_types.has(col.formatter)) {
|
||||||
newCol.cellRendererParams = {
|
newCol.cellDataType = col.formatter;
|
||||||
formatter: col.formatter,
|
} else {
|
||||||
};
|
newCol.cellRendererParams = {
|
||||||
newCol.cellRenderer = TableAutoCellRender;
|
formatter: col.formatter,
|
||||||
}
|
};
|
||||||
|
newCol.cellRenderer = TableAutoCellRender;
|
||||||
}
|
}
|
||||||
return newCol;
|
return newCol;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue