Skip to content

Commit

Permalink
Merge pull request #222 from CBIIT/CRDCDH-612
Browse files Browse the repository at this point in the history
CRDCDH-612 Submission upload allow txt files
  • Loading branch information
amattu2 authored Nov 22, 2023
2 parents 3b1fbb9 + 8ab8caf commit d758e66
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/DataSubmissions/DataSubmissionUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
const uploadMetatadataInputRef = useRef<HTMLInputElement>(null);
const isSubmissionOwner = submitterID === user?._id;
const canUpload = UploadRoles.includes(user?.role) || isSubmissionOwner;
const acceptedExtensions = [".tsv", ".txt"];

const [createBatch] = useMutation<CreateBatchResp>(CREATE_BATCH, {
context: { clientName: 'backend' },
Expand Down Expand Up @@ -169,8 +170,8 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
return;
}

// Filter out any file that is not tsv
const filteredFiles = Array.from(files)?.filter((file: File) => file.name?.toLowerCase()?.endsWith(".tsv"));
// Filter out any file that is not an accepted file extension
const filteredFiles = Array.from(files)?.filter((file: File) => acceptedExtensions.some((ext) => file.name?.toLowerCase()?.endsWith(ext)));
if (!filteredFiles?.length) {
setSelectedFiles(null);
return;
Expand Down Expand Up @@ -311,7 +312,7 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
<VisuallyHiddenInput
ref={uploadMetatadataInputRef}
type="file"
accept="text/tab-separated-values"
accept={acceptedExtensions.toString()}
onChange={handleChooseFiles}
readOnly={readOnly}
multiple
Expand Down

0 comments on commit d758e66

Please sign in to comment.