diff --git a/src/backend/base/langflow/base/tools/constants.py b/src/backend/base/langflow/base/tools/constants.py index b10c66c45..cfc1bcf32 100644 --- a/src/backend/base/langflow/base/tools/constants.py +++ b/src/backend/base/langflow/base/tools/constants.py @@ -12,6 +12,7 @@ TOOL_TABLE_SCHEMA = [ "sortable": False, "filterable": False, "edit_mode": EditMode.INLINE, + "hidden": False, }, { "name": "description", @@ -21,6 +22,7 @@ TOOL_TABLE_SCHEMA = [ "sortable": False, "filterable": False, "edit_mode": EditMode.POPOVER, + "hidden": False, }, { "name": "tags", @@ -31,6 +33,7 @@ TOOL_TABLE_SCHEMA = [ "sortable": False, "filterable": False, "edit_mode": EditMode.INLINE, + "hidden": True, }, ] diff --git a/src/backend/base/langflow/schema/table.py b/src/backend/base/langflow/schema/table.py index 4ec914163..ed3a797bb 100644 --- a/src/backend/base/langflow/schema/table.py +++ b/src/backend/base/langflow/schema/table.py @@ -30,6 +30,7 @@ class Column(BaseModel): default: str | None = None disable_edit: bool = Field(default=False) edit_mode: EditMode | None = Field(default=EditMode.MODAL) + hidden: bool = Field(default=False) @model_validator(mode="after") def set_display_name(self): diff --git a/src/frontend/src/components/core/parameterRenderComponent/components/tableComponent/index.tsx b/src/frontend/src/components/core/parameterRenderComponent/components/tableComponent/index.tsx index b6df532a9..7111ed15e 100644 --- a/src/frontend/src/components/core/parameterRenderComponent/components/tableComponent/index.tsx +++ b/src/frontend/src/components/core/parameterRenderComponent/components/tableComponent/index.tsx @@ -53,61 +53,67 @@ const TableComponent = forwardRef< }, ref, ) => { - let colDef = props.columnDefs.map((col, index) => { - let newCol = { - ...col, - }; - if (props.rowSelection && props.onSelectionChanged && index === 0) { - newCol = { - ...newCol, - checkboxSelection: true, - headerCheckboxSelection: true, - headerCheckboxSelectionFilteredOnly: true, + let colDef = props.columnDefs + .map((col, index) => { + let newCol = { + ...col, }; - } - if ( - (typeof props.tableOptions?.block_hide === "boolean" && - props.tableOptions?.block_hide) || - (Array.isArray(props.tableOptions?.block_hide) && - props.tableOptions?.block_hide.includes(newCol.field ?? "")) - ) { - newCol = { - ...newCol, - lockVisible: true, - }; - } - if ( - (typeof props.editable === "boolean" && props.editable) || - (Array.isArray(props.editable) && - props.editable.every((field) => typeof field === "string") && - (props.editable as Array).includes(newCol.field ?? "")) - ) { - newCol = { - ...newCol, - editable: true, - }; - } - if ( - Array.isArray(props.editable) && - props.editable.every((field) => typeof field === "object") - ) { - const field = ( - props.editable as Array<{ - field: string; - onUpdate: (value: any) => void; - editableCell: boolean; - }> - ).find((field) => field.field === newCol.field); - if (field) { + // Filter out hidden columns + if (col.hidden) { + return null; + } + if (props.rowSelection && props.onSelectionChanged && index === 0) { newCol = { ...newCol, - editable: field.editableCell, - onCellValueChanged: (e) => field.onUpdate(e), + checkboxSelection: true, + headerCheckboxSelection: true, + headerCheckboxSelectionFilteredOnly: true, }; } - } - return newCol; - }); + if ( + (typeof props.tableOptions?.block_hide === "boolean" && + props.tableOptions?.block_hide) || + (Array.isArray(props.tableOptions?.block_hide) && + props.tableOptions?.block_hide.includes(newCol.field ?? "")) + ) { + newCol = { + ...newCol, + lockVisible: true, + }; + } + if ( + (typeof props.editable === "boolean" && props.editable) || + (Array.isArray(props.editable) && + props.editable.every((field) => typeof field === "string") && + (props.editable as Array).includes(newCol.field ?? "")) + ) { + newCol = { + ...newCol, + editable: true, + }; + } + if ( + Array.isArray(props.editable) && + props.editable.every((field) => typeof field === "object") + ) { + const field = ( + props.editable as Array<{ + field: string; + onUpdate: (value: any) => void; + editableCell: boolean; + }> + ).find((field) => field.field === newCol.field); + if (field) { + newCol = { + ...newCol, + editable: field.editableCell, + onCellValueChanged: (e) => field.onUpdate(e), + }; + } + } + return newCol; + }) + .filter(Boolean); // Filter out null values from hidden columns // @ts-ignore const realRef: React.MutableRefObject = useRef(null); diff --git a/src/frontend/src/types/utils/functions.ts b/src/frontend/src/types/utils/functions.ts index c88b4421f..5acc581fd 100644 --- a/src/frontend/src/types/utils/functions.ts +++ b/src/frontend/src/types/utils/functions.ts @@ -26,6 +26,7 @@ export interface ColumnField { formatter?: FormatterType; description?: string; disable_edit?: boolean; - default?: any; // Add this line + default?: any; edit_mode?: "modal" | "inline" | "popover"; + hidden?: boolean; } diff --git a/src/frontend/src/utils/utils.ts b/src/frontend/src/utils/utils.ts index 005815062..9cf131f5c 100644 --- a/src/frontend/src/utils/utils.ts +++ b/src/frontend/src/utils/utils.ts @@ -524,7 +524,7 @@ export function brokenEdgeMessage({ export function FormatColumns(columns: ColumnField[]): ColDef[] { if (!columns) return []; const basic_types = new Set(["date", "number"]); - const colDefs = columns.map((col, index) => { + const colDefs = columns.map((col) => { let newCol: ColDef = { headerName: col.display_name, field: col.name, @@ -532,6 +532,7 @@ export function FormatColumns(columns: ColumnField[]): ColDef[] { filter: col.filterable, context: col.description ? { info: col.description } : {}, cellClass: col.disable_edit ? "cell-disable-edit" : "", + hide: col.hidden, valueParser: (params: ValueParserParams) => { const { context, newValue, colDef, oldValue } = params; if ( @@ -595,6 +596,7 @@ export function generateBackendColumnsFromValue( sortable: !tableOptions?.block_sort, filterable: !tableOptions?.block_filter, default: null, // Initialize default to null or appropriate value + hidden: false, }; // Attempt to infer the default value from the data, if possible