Skip to content

Commit

Permalink
🐛 Add missing properties for file component
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
sergei-maertens committed Oct 27, 2023
1 parent 619d979 commit 6853fe2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/formio/components/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ export interface BaseFileComponentSchema
HasValidation<Validator> {
type: 'file';
multiple?: boolean;

// (possibly) more-constrained existing formio properties
webcam: false;
options: {withCredentials: true};
storage: 'url';
url: string;
file: FileUploadConfiguration;
Expand Down
16 changes: 16 additions & 0 deletions test-d/formio/components/file.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ expectAssignable<FileComponentSchema>({
type: 'file',
key: 'someFile',
label: 'Attachment',
webcam: false,
options: {withCredentials: true},
storage: 'url',
url: '',
file: {
Expand All @@ -43,6 +45,8 @@ const explicitSingleUpload: FileComponentSchema = {
type: 'file',
key: 'someFile',
label: 'Attachment',
webcam: false,
options: {withCredentials: true},
storage: 'url',
url: '',
file: {
Expand All @@ -63,6 +67,8 @@ const explicitMultipleUpload: FileComponentSchema = {
type: 'file',
key: 'someFile',
label: 'Attachment',
webcam: false,
options: {withCredentials: true},
storage: 'url',
url: '',
file: {
Expand All @@ -83,6 +89,8 @@ const implicitSingleUpload: FileComponentSchema = {
type: 'file',
key: 'someFile',
label: 'Attachment',
webcam: false,
options: {withCredentials: true},
storage: 'url',
url: '',
file: {
Expand All @@ -106,6 +114,8 @@ expectAssignable<FileComponentSchema>({
key: 'someInput',
label: 'Some input',
// builder sets empty URL, backend dynamically makes this non-empty
webcam: false,
options: {withCredentials: true},
storage: 'url',
url: '',
file: {
Expand Down Expand Up @@ -143,6 +153,8 @@ expectAssignable<FileComponentSchema>({
expectAssignable<FileComponentSchema>({
id: 'yejak',
type: 'file',
webcam: false,
options: {withCredentials: true},
storage: 'url',
url: '',
// basic tab in builder form
Expand Down Expand Up @@ -219,6 +231,8 @@ expectNotAssignable<FileComponentSchema>({
type: 'content',
key: 'someFile',
label: 'Attachment',
webcam: false,
options: {withCredentials: true},
storage: 'url',
url: '',
file: {
Expand All @@ -235,6 +249,8 @@ expectNotAssignable<FileComponentSchema>({
type: 'file',
key: 'someFile',
label: 'Attachment',
webcam: false,
options: {withCredentials: true},
storage: 's3', // we only support url
url: '',
file: {
Expand Down

0 comments on commit 6853fe2

Please sign in to comment.