-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Create model file for
FileUpload
(#3723)
- Loading branch information
1 parent
4ba1baa
commit b649aeb
Showing
14 changed files
with
62 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 2 additions & 48 deletions
50
editor.planx.uk/src/@planx/components/FileUpload/Public.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
editor.planx.uk/src/@planx/components/FileUpload/model.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { MoreInformation } from "@planx/components/shared"; | ||
import { Store } from "pages/FlowEditor/lib/store"; | ||
import type { HandleSubmit } from "pages/Preview/Node"; | ||
import { FileWithPath } from "react-dropzone"; | ||
import { array } from "yup"; | ||
|
||
export interface Props extends MoreInformation { | ||
id?: string; | ||
title?: string; | ||
fn: string; | ||
description?: string; | ||
handleSubmit: HandleSubmit; | ||
previouslySubmittedData?: Store.UserData; | ||
} | ||
|
||
export interface FileUploadSlot { | ||
file: FileWithPath; | ||
status: "success" | "error" | "uploading"; | ||
progress: number; | ||
id: string; | ||
url?: string; | ||
cachedSlot?: Omit<FileUploadSlot, "cachedSlot">; | ||
} | ||
|
||
export const slotsSchema = array() | ||
.required() | ||
.test({ | ||
name: "nonUploading", | ||
message: "Upload at least one file", | ||
test: (slots?: Array<FileUploadSlot>) => { | ||
return Boolean( | ||
slots && | ||
slots.length > 0 && | ||
!slots.some((slot) => slot.status === "uploading"), | ||
); | ||
}, | ||
}) | ||
.test({ | ||
name: "errorStatus", | ||
message: "Remove files which failed to upload", | ||
test: (slots?: Array<FileUploadSlot>) => { | ||
return Boolean( | ||
slots && | ||
slots.length > 0 && | ||
!slots.some((slot) => slot.status === "error"), | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
editor.planx.uk/src/@planx/components/FileUploadAndLabel/mocks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
editor.planx.uk/src/@planx/components/FileUploadAndLabel/model.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
editor.planx.uk/src/@planx/components/FileUploadAndLabel/schema.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
editor.planx.uk/src/@planx/components/shared/PrivateFileUpload/PrivateFileUpload.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters