diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/FormRenderer.tsx b/autogpt_platform/frontend/src/components/renderers/InputRenderer/FormRenderer.tsx index c3a20d8cd2..fc388cc343 100644 --- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/FormRenderer.tsx +++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/FormRenderer.tsx @@ -30,6 +30,8 @@ export const FormRenderer = ({ return generateUiSchemaForCustomFields(preprocessedSchema, uiSchema); }, [preprocessedSchema, uiSchema]); + console.log("preprocessedSchema", preprocessedSchema); + return (
{!fromAnyOf && ( -
+
{ - const { schema, uiSchema, onChange, fieldPathId, formData } = props; + const { schema, uiSchema, onChange, fieldPathId, formData, registry } = props; const uiOptions = getUiOptions(uiSchema); const config: GoogleDrivePickerConfig = schema.google_drive_picker_config; + const uiType = registry.formContext?.uiType; + + if (uiType === BlockUIType.INPUT) { + return ( +
+ Select files when you run the graph +
+ ); + } + return (
{ - return ( - "google_drive_picker_config" in schema || - ("format" in schema && schema.format === "google-drive-picker") - ); - }, + matcher: isGoogleDrivePickerSchema, component: GoogleDrivePickerField, }, { diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/schema-utils.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/schema-utils.ts index fecf2d77d1..c7dd9680d7 100644 --- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/schema-utils.ts +++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/schema-utils.ts @@ -55,3 +55,38 @@ export function isMultiSelectSchema(schema: RJSFSchema | undefined): boolean { ) ); } + +const isGoogleDriveFileObject = (obj: RJSFSchema): boolean => { + if (obj.type !== "object" || !obj.properties) { + return false; + } + const props = obj.properties; + const hasId = "id" in props; + const hasMimeType = "mimeType" in props || "mime_type" in props; + const hasIconUrl = "iconUrl" in props || "icon_url" in props; + const hasIsFolder = "isFolder" in props || "is_folder" in props; + return hasId && hasMimeType && (hasIconUrl || hasIsFolder); +}; + +export const isGoogleDrivePickerSchema = ( + schema: RJSFSchema | undefined, +): boolean => { + if (!schema) { + return false; + } + + // highest priority + if ( + "google_drive_picker_config" in schema || + ("format" in schema && schema.format === "google-drive-picker") + ) { + return true; + } + + // In the Input type block, we do not add the format for the GoogleFile field, so we need to include this extra check. + if (isGoogleDriveFileObject(schema)) { + return true; + } + + return false; +};