Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRDCDH-612 Submission upload allow txt files #222

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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