[Issue #11350] Single attachment application upload - virus scanning - #11648
[Issue #11350] Single attachment application upload - virus scanning#11648freddieyebra wants to merge 39 commits into
Conversation
This reverts commit 7c1b312.
ErinPattisonNava
left a comment
There was a problem hiding this comment.
Did a quick pre-review, looks like the right patterns. One request is to post the test coverage when you create a pr since this is such a key component for forms.
| applicationStatus, | ||
| createdAt, | ||
| updatedAt, | ||
| useVirusScanning = false, |
There was a problem hiding this comment.
I'd add a comment here that this should be deleted in #11352
| requesterForEndpoint(fetchCompetitionEndpoint), | ||
| ); | ||
|
|
||
| export const fetchApplicationWithMethod = ( |
There was a problem hiding this comment.
We should probably have a line in the same ticket mentioned above to remove this code too.
There was a problem hiding this comment.
This will still have alpha endpoints that use but the attachment api endpoints themselves will be removed in the following ticket.
| import { Attachment } from "src/types/attachmentTypes"; | ||
| import { UploadFileMetadata } from "src/types/fileUploadTypes"; | ||
|
|
||
| export const ApplicationAttachmentStatus = { |
There was a problem hiding this comment.
Can these not be pulled out in to the translation file?
|
|
||
| for (const { testName, orgLabel } of applicantScenarios) { | ||
| test( | ||
| test.skip( |
| {error && ( | ||
| <FieldErrors fieldName={id} rawErrors={rawErrors as string[]} /> | ||
| )} | ||
| <SimplerFileInput |
There was a problem hiding this comment.
| ); | ||
| const { applicationId } = useParams<{ applicationId: string }>(); | ||
| const { attachments } = useApplicationAttachments(); | ||
| const [attachment, setAttachment] = useState<Attachment | null>( |
There was a problem hiding this comment.
The attachment is initialized from value and the attachment context only once.
If attachments load later, Saving returns refreshed data, or the parent changes/reset the value while the widget remains mounted, the hidden value and displayed file can be stale.
We could synchronize the local state when value or attachments changes.
| const describedby = error | ||
| ? `error-for-${visibleInputId}` | ||
| : title | ||
| ? `label-for-${visibleInputId}` |
There was a problem hiding this comment.
I think the required-field error relationship my currently be broken.
FieldErrors receives fieldName={id}, which renders an ID like error-for-att1, but the visible input is passed error-for-att1-visible.
| {error && ( | ||
| <FieldErrors fieldName={id} rawErrors={rawErrors as string[]} /> | ||
| )} | ||
| <SimplerFileInput |
There was a problem hiding this comment.
The story requires the form to be marked dirty when an upload starts. SimplerFileInput supports onStart, and ApplyForm exposes formContext.widgetSupport.markFormDirty, but this widget does not connect them.
Deleting an attachment also clears the local form value without explicitly marking the form dirty.
Could we wire markFormDirty to upload start and deletion?

Summary
Work for #11350
This is blocked by removing the duplicate create attachment PR
Changes proposed
This pr integrates the virus scanning component into the single attachment form fields.
fetchrequestsContext for reviewers
The new component integrated in this pr will only be supported in the Attachment form for initial integration and eventually for all single attachment uploads. This integration also ensure that application attachments and attachment audit events are only persisted once the form is saved.
Validation steps
make db-seed-local && make run-logsnpm run localornpm run devCreating attachment
Deleting attachments
Submission
make cmd args="task create-application-submission"/print/application/<application_uuid>/form/<form_uuid>and verify the print view correctly renders the attachmentsTest coverage
