Skip to content

Commit

Permalink
enh: add warning when uploading file > 5mb (#3355)
Browse files Browse the repository at this point in the history
* enh: add warning when uploading file > 5mb

* include large file threshold in warning message

---------

Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Jan 22, 2024
1 parent 727a452 commit 13d793c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions front/pages/w/[wId]/builder/data-sources/[name]/tables/upsert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Button,
DocumentPlusIcon,
DropdownMenu,
ExclamationCircleIcon,
Input,
Page,
TrashIcon,
Expand Down Expand Up @@ -100,6 +101,7 @@ export default function TableUpsert({
const [loading, setLoading] = useState(false);
const [uploading, setUploading] = useState(false);
const [upserting, setUpserting] = useState(false);
const [isBigFile, setIsBigFile] = useState(false);

const { table } = useTable({
workspaceId: owner.sId,
Expand Down Expand Up @@ -178,6 +180,12 @@ export default function TableUpsert({
return;
}

if (res.value.content.length > 5_000_000) {
setIsBigFile(true);
} else {
setIsBigFile(false);
}

const body: CreateTableFromCsvRequestBody = {
name: tableName,
description: description,
Expand Down Expand Up @@ -308,6 +316,19 @@ export default function TableUpsert({
},
}}
/>
{isBigFile && (
<div className="pt-4">
<div className="flex flex-col gap-y-2">
<div className="flex grow flex-row items-center gap-1 text-sm font-medium text-element-800 text-warning-500">
<ExclamationCircleIcon />
Warning: Large file (5MB+)
</div>
<div className="text-sm font-normal text-element-700">
This file is large and may take a while to upload.
</div>
</div>
</div>
)}
<input
type="file"
ref={fileInputRef}
Expand Down

0 comments on commit 13d793c

Please sign in to comment.