Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend/builder): make Google Drive file inputs chainable (#12274)

Nicholas Tindle3722d05b9be2
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/custom/GoogleDrivePickerField/GoogleDrivePickerField.tsx b/autogpt_platform/frontend/src/components/renderers/InputRenderer/custom/GoogleDrivePickerField/GoogleDrivePickerField.tsx
index dff6274189..94fad2378f 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/custom/GoogleDrivePickerField/GoogleDrivePickerField.tsx
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/custom/GoogleDrivePickerField/GoogleDrivePickerField.tsx
@@ -1,32 +1,60 @@
import { BlockUIType } from "@/app/(platform)/build/components/types";
import { GoogleDrivePickerInput } from "@/components/contextual/GoogleDrivePicker/GoogleDrivePickerInput";
import { GoogleDrivePickerConfig } from "@/lib/autogpt-server-api";
-import { FieldProps, getUiOptions } from "@rjsf/utils";
+import { FieldProps, getTemplate, getUiOptions, titleId } from "@rjsf/utils";
+import { cleanUpHandleId, getHandleId, updateUiOption } from "../../helpers";
+import { useEdgeStore } from "@/app/(platform)/build/stores/edgeStore";
export const GoogleDrivePickerField = (props: FieldProps) => {
const { schema, uiSchema, onChange, fieldPathId, formData, registry } = props;
const uiOptions = getUiOptions(uiSchema);
const config: GoogleDrivePickerConfig = schema.google_drive_picker_config;
+ const { nodeId } = registry.formContext;
const uiType = registry.formContext?.uiType;
+ const TitleFieldTemplate = getTemplate("TitleFieldTemplate", registry);
+
+ const handleId = getHandleId({ uiOptions, id: fieldPathId.$id, schema });
+ const updatedUiSchema = updateUiOption(uiSchema, {
+ handleId,
+ showHandles: !!nodeId,
+ });
+
+ const { isInputConnected } = useEdgeStore();
+ const isConnected = isInputConnected(nodeId, cleanUpHandleId(handleId));
+
if (uiType === BlockUIType.INPUT) {
return (
- <div className="rounded-3xl border border-gray-200 p-2 pl-4 text-xs text-gray-500 hover:cursor-not-allowed">
- Select files when you run the graph
+ <div className="flex flex-col gap-2">
+ {!isConnected && (
+ <div className="rounded-3xl border border-gray-200 p-2 pl-4 text-xs text-gray-500 hover:cursor-not-allowed">
+ Select files when you run the graph
+ </div>
+ )}
</div>
);
}
return (
- <div>
- <GoogleDrivePickerInput
- config={config}
- value={formData}
- onChange={(value) => onChange(value, fieldPathId.path)}
- className={uiOptions.className}
- showRemoveButton={true}
+ <div className="flex flex-col gap-2">
+ <TitleFieldTemplate
+ id={titleId(fieldPathId.$id)}
+ title={schema.title || ""}
+ required={false}
+ schema={schema}
+ uiSchema={updatedUiSchema}
+ registry={registry}
/>
+ {!isConnected && (
+ <GoogleDrivePickerInput
+ config={config}
+ value={formData}
+ onChange={(value) => onChange(value, fieldPathId.path)}
+ className={uiOptions.className}
+ showRemoveButton={true}
+ />
+ )}
</div>
);
};
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/generate-ui-schema.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/generate-ui-schema.ts
index 4012c39068..f7f6bc86c1 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/generate-ui-schema.ts
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/generate-ui-schema.ts
@@ -44,9 +44,19 @@ export function generateUiSchemaForCustomFields(
const customFieldId = findCustomFieldId(propSchema);
if (customFieldId) {
+ const hasAnyOfOrOneOf =
+ propSchema.anyOf || propSchema.oneOf ? true : false;
uiSchema[key] = {
...(uiSchema[key] as object),
"ui:field": customFieldId,
+ ...(hasAnyOfOrOneOf && {
+ "ui:options": {
+ ...((uiSchema[key] as Record<string, unknown>)?.[
+ "ui:options"
+ ] as object),
+ fieldReplacesAnyOrOneOf: true,
+ },
+ }),
};
// Skip further processing for custom fields
continue;