diff --git a/src/applications/simple-forms/40-0247/components/FileField.jsx b/src/applications/simple-forms/40-0247/components/FileField.jsx index 9747c221f463..e4595ea6daba 100644 --- a/src/applications/simple-forms/40-0247/components/FileField.jsx +++ b/src/applications/simple-forms/40-0247/components/FileField.jsx @@ -1,14 +1,12 @@ /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */ -/* Customized copy of Platform's FileField component - * - Adds new optional prop `ariaLabelAdditionalText` to append additional - * text to the upload button's aria-label attribute. -*/ import PropTypes from 'prop-types'; import React, { useEffect, useState, useRef } from 'react'; import { connect } from 'react-redux'; import classNames from 'classnames'; import { VaModal } from '@department-of-veterans-affairs/component-library/dist/react-bindings'; +import environment from 'platform/utilities/environment'; + import { toggleValues } from 'platform/site-wide/feature-toggles/selectors'; import get from 'platform/utilities/data/get'; import set from 'platform/utilities/data/set'; @@ -21,6 +19,7 @@ import { } from 'platform/utilities/ui'; import { FILE_UPLOAD_NETWORK_ERROR_MESSAGE } from 'platform/forms-system/src/js/constants'; +import { ERROR_ELEMENTS } from 'platform/utilities/constants'; import { $ } from 'platform/forms-system/src/js/utilities/ui'; import { ShowPdfPassword, @@ -32,6 +31,7 @@ import { FILE_TYPE_MISMATCH_ERROR, } from 'platform/forms-system/src/js/utilities/file'; import { usePreviousValue } from 'platform/forms-system/src/js/helpers'; +import { MISSING_PASSWORD_ERROR } from 'platform/forms-system/src/js/validation'; /** * Modal content callback @@ -48,7 +48,7 @@ import { usePreviousValue } from 'platform/forms-system/src/js/helpers'; * @property {string} buttonText='Upload' - upload button text * @property {string} addAnotherLabel='Upload another' - upload another text, * replaces upload button text when greater than one upload is showing - * @property {string} ariaLabelAdditionalText='' - additional screen-reader text to be appended to upload button's aria-label attribute. + * @property {string} ariaLabelAdditionalText additional screen-reader text to be appended to upload button's aria-label attribute. * @property {string} tryAgain='Try again' - button in enableShortWorkflow * @property {string} newFile='Upload a new file' - button in enableShortWorkflow * @property {string} cancel='Cancel' - button visible while uploading & in enableShortWorkflow @@ -274,6 +274,18 @@ const FileField = props => { return; } + // MBMS-66936 prod flag + if (!environment.isProduction() && checkResults.checkIsEncryptedPdf) { + allFiles[idx] = { + file: currentFile, + name: 'Upload additional evidence', + errorMessage: + 'We weren’t able to upload your file. Make sure the file is not encrypted and is an accepted format.', + }; + props.onChange(allFiles); + return; + } + if (!checkResults.checkTypeAndExtensionMatches) { allFiles[idx] = { file: currentFile, @@ -420,6 +432,302 @@ const FileField = props => { const uploadText = content[files.length > 0 ? 'uploadAnother' : 'upload']; + // MBMS-66936 prod flag + if (!environment.isProduction()) { + return ( +
+ closeRemoveModal({ remove: true })} + onSecondaryButtonClick={closeRemoveModal} + visible={showRemoveModal} + uswds + > +

+ {removeIndex !== null + ? content.modalContent(files[removeIndex]?.name) + : null} +

+
+ {files.length > 0 && ( + + )} + {// Don't render an upload button on review & submit page while in + // review mode + showButtons && ( + <> + {(maxItems === null || files.length < maxItems) && + // Prevent additional upload if any upload has error state + checkUploadVisibility() && ( + // eslint-disable-next-line jsx-a11y/label-has-associated-control + + )} + `.${item}`).join(',')} + className="vads-u-display--none" + id={idSchema.$id} + name={idSchema.$id} + onChange={onAddFile} + onClick={() => { + fileInputRef.current.value = ''; + }} + /> + + )} +
+ ); + } return (