From 6853fe2b53f60e72bcdb6a3c0b2508b028e6d590 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Fri, 27 Oct 2023 15:16:23 +0200 Subject: [PATCH] :bug: Add missing properties for file component * webcam: false is set in our default form builder configuration, and it affects the SDK/renderer in that no webcam integration needs to be built/enabled * options object is set as string in our current builder, but it is then at run-time parsed as JSON. We can shortcut this and directly set it as an object. The withCredentials option is required for XHR uploads to send cookies. This will likely become obsolete when we replace the formio renderer with our own and have a fetch-based upload client. --- src/formio/components/file.ts | 3 ++- test-d/formio/components/file.test-d.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/formio/components/file.ts b/src/formio/components/file.ts index 3a47968..7c6cf43 100644 --- a/src/formio/components/file.ts +++ b/src/formio/components/file.ts @@ -82,8 +82,9 @@ export interface BaseFileComponentSchema HasValidation { type: 'file'; multiple?: boolean; - // (possibly) more-constrained existing formio properties + webcam: false; + options: {withCredentials: true}; storage: 'url'; url: string; file: FileUploadConfiguration; diff --git a/test-d/formio/components/file.test-d.ts b/test-d/formio/components/file.test-d.ts index 5ea70e9..33e44c5 100644 --- a/test-d/formio/components/file.test-d.ts +++ b/test-d/formio/components/file.test-d.ts @@ -26,6 +26,8 @@ expectAssignable({ type: 'file', key: 'someFile', label: 'Attachment', + webcam: false, + options: {withCredentials: true}, storage: 'url', url: '', file: { @@ -43,6 +45,8 @@ const explicitSingleUpload: FileComponentSchema = { type: 'file', key: 'someFile', label: 'Attachment', + webcam: false, + options: {withCredentials: true}, storage: 'url', url: '', file: { @@ -63,6 +67,8 @@ const explicitMultipleUpload: FileComponentSchema = { type: 'file', key: 'someFile', label: 'Attachment', + webcam: false, + options: {withCredentials: true}, storage: 'url', url: '', file: { @@ -83,6 +89,8 @@ const implicitSingleUpload: FileComponentSchema = { type: 'file', key: 'someFile', label: 'Attachment', + webcam: false, + options: {withCredentials: true}, storage: 'url', url: '', file: { @@ -106,6 +114,8 @@ expectAssignable({ key: 'someInput', label: 'Some input', // builder sets empty URL, backend dynamically makes this non-empty + webcam: false, + options: {withCredentials: true}, storage: 'url', url: '', file: { @@ -143,6 +153,8 @@ expectAssignable({ expectAssignable({ id: 'yejak', type: 'file', + webcam: false, + options: {withCredentials: true}, storage: 'url', url: '', // basic tab in builder form @@ -219,6 +231,8 @@ expectNotAssignable({ type: 'content', key: 'someFile', label: 'Attachment', + webcam: false, + options: {withCredentials: true}, storage: 'url', url: '', file: { @@ -235,6 +249,8 @@ expectNotAssignable({ type: 'file', key: 'someFile', label: 'Attachment', + webcam: false, + options: {withCredentials: true}, storage: 's3', // we only support url url: '', file: {