IO-134 Prevent doc reassignment with limit

This commit is contained in:
Patrick Fic
2021-04-06 09:26:31 -07:00
parent 50581c98e0
commit 9af6311d52
12 changed files with 173 additions and 22 deletions

View File

@@ -24,6 +24,7 @@ export function DocumentsUploadComponent({
billId,
callbackAfterUpload,
totalSize,
ignoreSizeLimit = false,
}) {
const { t } = useTranslation();
@@ -33,7 +34,7 @@ export function DocumentsUploadComponent({
);
}, [bodyshop, totalSize]);
if (pct > 100)
if (pct > 100 && !ignoreSizeLimit)
return (
<Result
status="error"
@@ -46,6 +47,7 @@ export function DocumentsUploadComponent({
<Upload.Dragger
multiple={true}
beforeUpload={(file, fileList) => {
if (ignoreSizeLimit) return true;
const newFiles = fileList.reduce((acc, val) => acc + val.size, 0);
const shouldStopUpload =
(totalSize + newFiles) / ((bodyshop && bodyshop.jobsizelimit) || 1) >=
@@ -84,16 +86,18 @@ export function DocumentsUploadComponent({
<p className="ant-upload-text">
Click or drag files to this area to upload.
</p>
<Space wrap className="ant-upload-text">
<Progress type="dashboard" percent={pct} size="small" />
<span>
{t("documents.labels.usage", {
percent: pct,
used: formatBytes(totalSize),
total: formatBytes(bodyshop && bodyshop.jobsizelimit),
})}
</span>
</Space>
{!ignoreSizeLimit && (
<Space wrap className="ant-upload-text">
<Progress type="dashboard" percent={pct} size="small" />
<span>
{t("documents.labels.usage", {
percent: pct,
used: formatBytes(totalSize),
total: formatBytes(bodyshop && bodyshop.jobsizelimit),
})}
</span>
</Space>
)}
</>
)}
</Upload.Dragger>