Fix Bug 69825 - Settings:QuotaPerRoom. Added dialog about exceeding quota during upload
This commit is contained in:
parent
8763c49eea
commit
40626da6f2
@ -29,6 +29,7 @@ import { inject, observer } from "mobx-react";
|
||||
|
||||
import { DeviceType, RoomsType } from "@docspace/shared/enums";
|
||||
import Planet12ReactSvgUrl from "PUBLIC_DIR/images/icons/12/planet.react.svg?url";
|
||||
import { toastr } from "@docspace/shared/components/toast";
|
||||
|
||||
export default function withFileActions(WrappedFileItem) {
|
||||
class WithFileActions extends React.Component {
|
||||
@ -67,8 +68,12 @@ export default function withFileActions(WrappedFileItem) {
|
||||
|
||||
dragging && setDragging(false);
|
||||
|
||||
createFoldersTree(files, uploadToFolder).then((f) => {
|
||||
createFoldersTree(t, files, uploadToFolder)
|
||||
.then((f) => {
|
||||
if (f.length > 0) startUpload(f, null, t);
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error(err);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -45,6 +45,7 @@ import BonusItem from "./BonusItem";
|
||||
import AccountsItem from "./AccountsItem";
|
||||
|
||||
import ClearTrashReactSvgUrl from "PUBLIC_DIR/images/clear.trash.react.svg?url";
|
||||
import { toastr } from "@docspace/shared/components/toast";
|
||||
|
||||
const StyledDragAndDrop = styled(DragAndDrop)`
|
||||
display: contents;
|
||||
@ -87,8 +88,12 @@ const Item = ({
|
||||
(files, uploadToFolder) => {
|
||||
dragging && setDragging(false);
|
||||
|
||||
createFoldersTree(files, uploadToFolder).then((f) => {
|
||||
createFoldersTree(t, files, uploadToFolder)
|
||||
.then((f) => {
|
||||
if (f.length > 0) startUpload(f, null, t);
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error(err);
|
||||
});
|
||||
},
|
||||
[t, dragging, setDragging, startUpload, createFoldersTree],
|
||||
|
@ -245,8 +245,12 @@ const ArticleMainButtonContent = (props) => {
|
||||
async (e) => {
|
||||
const files = await getFilesFromEvent(e);
|
||||
|
||||
createFoldersTree(files).then((f) => {
|
||||
createFoldersTree(t, files)
|
||||
.then((f) => {
|
||||
if (f.length > 0) startUpload(f, null, t);
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error(err);
|
||||
});
|
||||
},
|
||||
[startUpload, t],
|
||||
|
@ -45,6 +45,7 @@ import { useParams } from "react-router-dom";
|
||||
|
||||
import { getCategoryType, getCategoryUrl } from "SRC_DIR/helpers/utils";
|
||||
import { CategoryType } from "SRC_DIR/helpers/constants";
|
||||
import { toastr } from "@docspace/shared/components/toast";
|
||||
|
||||
const useFiles = ({
|
||||
t,
|
||||
@ -118,8 +119,12 @@ const useFiles = ({
|
||||
|
||||
if (disableDrag) return;
|
||||
|
||||
createFoldersTree(files, uploadToFolder).then((f) => {
|
||||
createFoldersTree(t, files, uploadToFolder)
|
||||
.then((f) => {
|
||||
if (f.length > 0) startUpload(f, null, t);
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error(err);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -51,6 +51,7 @@ import {
|
||||
} from "SRC_DIR/helpers/utils";
|
||||
import TariffBar from "SRC_DIR/components/TariffBar";
|
||||
import getFilesFromEvent from "@docspace/shared/components/drag-and-drop/get-files-from-event";
|
||||
import { toastr } from "@docspace/shared/components/toast";
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
width: 100%;
|
||||
@ -244,8 +245,12 @@ const SectionHeaderContent = (props) => {
|
||||
async (e) => {
|
||||
const files = await getFilesFromEvent(e);
|
||||
|
||||
createFoldersTree(files).then((f) => {
|
||||
createFoldersTree(t, files)
|
||||
.then((f) => {
|
||||
if (f.length > 0) startUpload(f, null, t);
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error(err);
|
||||
});
|
||||
},
|
||||
[startUpload, t],
|
||||
|
@ -79,7 +79,11 @@ import { CategoryType } from "SRC_DIR/helpers/constants";
|
||||
import RoomsFilter from "@docspace/shared/api/rooms/filter";
|
||||
import AccountsFilter from "@docspace/shared/api/people/filter";
|
||||
import { RoomSearchArea, UrlActionType } from "@docspace/shared/enums";
|
||||
import { getObjectByLocation } from "@docspace/shared/utils/common";
|
||||
import {
|
||||
getConvertedQuota,
|
||||
getConvertedSize,
|
||||
getObjectByLocation,
|
||||
} from "@docspace/shared/utils/common";
|
||||
import uniqueid from "lodash/uniqueId";
|
||||
import FilesFilter from "@docspace/shared/api/files/filter";
|
||||
import {
|
||||
@ -280,13 +284,41 @@ class FilesActionStore {
|
||||
return treeList;
|
||||
};
|
||||
|
||||
createFoldersTree = async (files, folderId) => {
|
||||
createFoldersTree = async (t, files, folderId) => {
|
||||
//console.log("createFoldersTree", files, folderId);
|
||||
|
||||
const { primaryProgressDataStore } = this.uploadDataStore;
|
||||
|
||||
const { setPrimaryProgressBarData, clearPrimaryProgressData } =
|
||||
primaryProgressDataStore;
|
||||
this.uploadDataStore.primaryProgressDataStore;
|
||||
|
||||
const roomFolder = this.selectedFolderStore.navigationPath.find(
|
||||
(r) => r.isRoom,
|
||||
);
|
||||
|
||||
const withoutHiddenFiles = Object.values(files).filter((f) => {
|
||||
const isHidden = /(^|\/)\.[^\/\.]/g.test(f.name);
|
||||
|
||||
return !isHidden;
|
||||
});
|
||||
|
||||
if (roomFolder && roomFolder.quotaLimit) {
|
||||
const freeSpace = roomFolder.quotaLimit - roomFolder.usedSpace;
|
||||
|
||||
const filesSize = withoutHiddenFiles.reduce((acc, file) => {
|
||||
return acc + file.size;
|
||||
}, 0);
|
||||
|
||||
if (filesSize > freeSpace) {
|
||||
clearPrimaryProgressData();
|
||||
|
||||
const size = getConvertedSize(t, roomFolder.quotaLimit);
|
||||
|
||||
throw new Error(
|
||||
t("Common:RoomSpaceQuotaExceeded", {
|
||||
size,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const operationId = uniqueid("operation_");
|
||||
|
||||
@ -302,7 +334,7 @@ class FilesActionStore {
|
||||
|
||||
setPrimaryProgressBarData({ ...pbData, disableUploadPanelOpen: true });
|
||||
|
||||
const tree = this.convertToTree(files);
|
||||
const tree = this.convertToTree(withoutHiddenFiles);
|
||||
|
||||
const filesList = [];
|
||||
await this.createFolderTree(tree, toFolderId, filesList);
|
||||
|
@ -1606,13 +1606,16 @@ class FilesStore {
|
||||
(data.current.rootFolderType === Rooms ||
|
||||
data.current.rootFolderType === Archive);
|
||||
|
||||
let shared;
|
||||
let shared, quotaLimit, usedSpace;
|
||||
if (idx === 1) {
|
||||
let room = data.current;
|
||||
|
||||
if (!isCurrentFolder) {
|
||||
room = await api.files.getFolderInfo(folderId);
|
||||
|
||||
shared = room.shared;
|
||||
quotaLimit = room.quotaLimit;
|
||||
usedSpace = room.usedSpace;
|
||||
|
||||
this.infoPanelStore.setInfoPanelRoom(room);
|
||||
}
|
||||
@ -1631,6 +1634,8 @@ class FilesStore {
|
||||
roomType,
|
||||
isRootRoom,
|
||||
shared,
|
||||
quotaLimit,
|
||||
usedSpace,
|
||||
};
|
||||
}),
|
||||
).then((res) => {
|
||||
|
@ -692,8 +692,12 @@ class HotkeyStore {
|
||||
|
||||
const files = await getFilesFromEvent(event);
|
||||
|
||||
createFoldersTree(files).then((f) => {
|
||||
createFoldersTree(t, files)
|
||||
.then((f) => {
|
||||
if (f.length > 0) startUpload(f, null, t);
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error(err);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -714,14 +714,6 @@ class UploadDataStore {
|
||||
};
|
||||
|
||||
startUpload = (uploadFiles, folderId, t) => {
|
||||
const withoutHiddenFiles = Object.values(uploadFiles).filter((f) => {
|
||||
const isHidden = /(^|\/)\.[^\/\.]/g.test(f.name);
|
||||
|
||||
return !isHidden;
|
||||
});
|
||||
|
||||
console.log("startUpload", { withoutHiddenFiles, uploadFiles });
|
||||
|
||||
const { canConvert } = this.filesSettingsStore;
|
||||
|
||||
const toFolderId = folderId ? folderId : this.selectedFolderStore.id;
|
||||
@ -743,10 +735,10 @@ class UploadDataStore {
|
||||
let filesSize = 0;
|
||||
let convertSize = 0;
|
||||
|
||||
const uploadFilesArray = Object.keys(withoutHiddenFiles);
|
||||
const uploadFilesArray = Object.keys(uploadFiles);
|
||||
const hasFolder =
|
||||
uploadFilesArray.findIndex((_, ind) => {
|
||||
const file = withoutHiddenFiles[ind];
|
||||
const file = uploadFiles[ind];
|
||||
|
||||
const filePath = file.path
|
||||
? file.path
|
||||
@ -761,13 +753,13 @@ class UploadDataStore {
|
||||
if (this.uploaded) {
|
||||
this.isParallel = false;
|
||||
} else if (this.isParallel) {
|
||||
this.tempFiles.push({ withoutHiddenFiles, folderId, t });
|
||||
this.tempFiles.push({ uploadFiles, folderId, t });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (let index of uploadFilesArray) {
|
||||
const file = withoutHiddenFiles[index];
|
||||
const file = uploadFiles[index];
|
||||
|
||||
const parts = file.name.split(".");
|
||||
const ext = parts.length > 1 ? "." + parts.pop() : "";
|
||||
|
@ -515,5 +515,6 @@
|
||||
"Website": "Website",
|
||||
"Yes": "Yes",
|
||||
"Yesterday": "Yesterday",
|
||||
"You": "You"
|
||||
"You": "You",
|
||||
"RoomSpaceQuotaExceeded": "Room space quota exceeded ({{size}})."
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user