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