Merge branch 'dev' into hackathon-copilot-backend

This commit is contained in:
Swifty
2026-01-07 11:34:04 +01:00
committed by GitHub
8 changed files with 1638 additions and 2145 deletions

View File

@@ -54,7 +54,7 @@
"@radix-ui/react-tooltip": "1.2.8",
"@rjsf/core": "6.1.2",
"@rjsf/utils": "6.1.2",
"@rjsf/validator-ajv8": "5.24.13",
"@rjsf/validator-ajv8": "6.1.2",
"@sentry/nextjs": "10.27.0",
"@supabase/ssr": "0.7.0",
"@supabase/supabase-js": "2.78.0",

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,7 @@ import { cn } from "@/lib/utils";
import { Cross2Icon } from "@radix-ui/react-icons";
import React, { useCallback } from "react";
import { GoogleDrivePicker } from "./GoogleDrivePicker";
import { isValidFile } from "./helpers";
export interface Props {
config: GoogleDrivePickerConfig;
@@ -27,13 +28,15 @@ export function GoogleDrivePickerInput({
const hasAutoCredentials = !!config.auto_credentials;
// Strip _credentials_id from value for display purposes
const currentFiles = isMultiSelect
? Array.isArray(value)
? value
: []
: value
? [value]
: [];
// Only show files section when there are valid file objects
const currentFiles = React.useMemo(() => {
if (isMultiSelect) {
if (!Array.isArray(value)) return [];
return value.filter(isValidFile);
}
if (!value || !isValidFile(value)) return [];
return [value];
}, [value, isMultiSelect]);
const handlePicked = useCallback(
(files: any[], credentialId?: string) => {
@@ -85,23 +88,27 @@ export function GoogleDrivePickerInput({
return (
<div className={cn("flex flex-col gap-2", className)}>
{/* Picker Button */}
<GoogleDrivePicker
multiselect={config.multiselect || false}
views={config.allowed_views || ["DOCS"]}
scopes={config.scopes || ["https://www.googleapis.com/auth/drive.file"]}
disabled={false}
requirePlatformCredentials={hasAutoCredentials}
onPicked={handlePicked}
onCanceled={() => {
// User canceled - no action needed
}}
onError={handleError}
/>
<div className="mb-4">
{/* Picker Button */}
<GoogleDrivePicker
multiselect={config.multiselect || false}
views={config.allowed_views || ["DOCS"]}
scopes={
config.scopes || ["https://www.googleapis.com/auth/drive.file"]
}
disabled={false}
requirePlatformCredentials={hasAutoCredentials}
onPicked={handlePicked}
onCanceled={() => {
// User canceled - no action needed
}}
onError={handleError}
/>
</div>
{/* Display Selected Files */}
{currentFiles.length > 0 && (
<div className="space-y-1">
<div className="mb-8 space-y-1">
{currentFiles.map((file: any, idx: number) => (
<div
key={file.id || idx}

View File

@@ -119,3 +119,14 @@ export function getCredentialsSchema(scopes: string[]) {
secret: true,
} satisfies BlockIOCredentialsSubSchema;
}
export function isValidFile(
file: unknown,
): file is { id?: string; name?: string } {
return (
typeof file === "object" &&
file !== null &&
(typeof (file as { id?: unknown }).id === "string" ||
typeof (file as { name?: unknown }).name === "string")
);
}

View File

@@ -4,11 +4,10 @@ import {
TemplatesType,
} from "@rjsf/utils";
import { AnyOfField } from "./anyof/AnyOfField";
import { AddButton, CopyButton, RemoveButton } from "./standard/buttons";
import {
ArrayFieldItemTemplate,
ArraySchemaField,
ArrayFieldTemplate,
ArraySchemaField,
} from "./array";
import {
ObjectFieldTemplate,
@@ -16,14 +15,16 @@ import {
WrapIfAdditionalTemplate,
} from "./object";
import { DescriptionField, FieldTemplate, TitleField } from "./standard";
import { AddButton, CopyButton, RemoveButton } from "./standard/buttons";
import {
TextWidget,
SelectWidget,
CheckboxWidget,
FileWidget,
DateWidget,
TimeWidget,
DateTimeWidget,
DateWidget,
FileWidget,
GoogleDrivePickerWidget,
SelectWidget,
TextWidget,
TimeWidget,
} from "./standard/widgets";
const NoButton = () => null;
@@ -65,5 +66,6 @@ export function generateBaseWidgets(): RegistryWidgetsType {
DateWidget,
TimeWidget,
DateTimeWidget,
GoogleDrivePickerWidget,
};
}

View File

@@ -0,0 +1,55 @@
import { useNodeStore } from "@/app/(platform)/build/stores/nodeStore";
import { GoogleDrivePickerInput } from "@/components/contextual/GoogleDrivePicker/GoogleDrivePickerInput";
import { getFieldErrorKey } from "@/components/renderers/InputRenderer/utils/helpers";
import type { GoogleDrivePickerConfig } from "@/lib/autogpt-server-api/types";
import { cn } from "@/lib/utils";
import { WidgetProps } from "@rjsf/utils";
function hasGoogleDrivePickerConfig(
schema: unknown,
): schema is { google_drive_picker_config?: GoogleDrivePickerConfig } {
return (
typeof schema === "object" &&
schema !== null &&
"google_drive_picker_config" in schema
);
}
export function GoogleDrivePickerWidget(props: WidgetProps) {
const { onChange, disabled, readonly, value, schema, id, formContext } =
props;
const { nodeId } = formContext || {};
const nodeErrors = useNodeStore((state) => {
const node = state.nodes.find((n) => n.id === nodeId);
return node?.data?.errors;
});
const fieldErrorKey = getFieldErrorKey(id ?? "");
const fieldError =
nodeErrors?.[fieldErrorKey] ||
nodeErrors?.[fieldErrorKey.replace(/_/g, ".")] ||
nodeErrors?.[fieldErrorKey.replace(/\./g, "_")] ||
undefined;
const config: GoogleDrivePickerConfig = hasGoogleDrivePickerConfig(schema)
? schema.google_drive_picker_config || {}
: {};
function handleChange(newValue: unknown) {
onChange(newValue);
}
return (
<GoogleDrivePickerInput
config={config}
value={value}
onChange={handleChange}
error={fieldError}
className={cn(
disabled || readonly ? "pointer-events-none opacity-50" : undefined,
)}
showRemoveButton={true}
/>
);
}

View File

@@ -0,0 +1 @@
export { GoogleDrivePickerWidget } from "./GoogleDrivePicketWidget";

View File

@@ -1,7 +1,8 @@
export { default as TextWidget } from "./TextInput";
export { SelectWidget } from "./SelectInput";
export { CheckboxWidget } from "./CheckboxInput";
export { FileWidget } from "./FileInput";
export { DateWidget } from "./DateInput";
export { TimeWidget } from "./TimeInput";
export { DateTimeWidget } from "./DateTimeInput";
export { FileWidget } from "./FileInput";
export { GoogleDrivePickerWidget } from "./GoogleDrivePicker";
export { SelectWidget } from "./SelectInput";
export { default as TextWidget } from "./TextInput";
export { TimeWidget } from "./TimeInput";