Skip to content

Commit

Permalink
Bug/WP-321: Removing oversized attachments from tickets (#1012)
Browse files Browse the repository at this point in the history
* Added functionality to remove oversized files attached to tickets

* Still trying to only delete one oversized file at a time

* Still trying to get the list of rejected files to refresh automatically

* Finally got to filter rejectedFiles correctly

---------

Co-authored-by: Jeff McMillen <[email protected]>
  • Loading branch information
jmcmillenmusic and Jeff McMillen authored Dec 20, 2024
1 parent daeccd2 commit 928dc75
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion client/src/components/_common/Form/FileInputDropZone.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* FP-993: Allow use by DataFilesUploadModal */
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { useDropzone } from 'react-dropzone';
import { Button, InlineMessage } from '_common';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -45,6 +45,13 @@ function FileInputDropZone({
}
};

const removeRejectedFile = (i) => {
const newRejectedFiles = rejectedFiles.filter(
(file) => file !== rejectedFiles[i]
);
setRejectedFiles(newRejectedFiles);
};

const showFileList = (files && files.length > 0) || rejectedFiles.length > 0;

return (
Expand Down Expand Up @@ -74,6 +81,14 @@ function FileInputDropZone({
<InlineMessage type="error">
Exceeds File Size Limit
</InlineMessage>
<Button
type="link"
onClick={() => {
removeRejectedFile(i);
}}
>
Remove
</Button>
</div>
))}
{files &&
Expand Down

0 comments on commit 928dc75

Please sign in to comment.