Web: Files: added move, copy and download actions in folder header menu

This commit is contained in:
Dmitry Sychugov 2021-09-28 17:46:35 +05:00
parent 88f87d7a82
commit 41b9869def
5 changed files with 68 additions and 22 deletions

View File

@ -16,8 +16,10 @@ const OperationsPanelComponent = (props) => {
visible,
provider,
selection,
isFolderActions,
isRecycleBin,
setDestFolderId,
setIsFolderActions,
currentFolderId,
operationsFolders,
setCopyPanelVisible,
@ -33,7 +35,13 @@ const OperationsPanelComponent = (props) => {
const expandedKeys = props.expandedKeys.map((item) => item.toString());
const onClose = () => {
isCopy ? setCopyPanelVisible(false) : setMoveToPanelVisible(false);
if (isCopy) {
setCopyPanelVisible(false);
setIsFolderActions(false);
} else {
setMoveToPanelVisible(false);
}
setExpandedPanelKeys(null);
};
@ -68,8 +76,8 @@ const OperationsPanelComponent = (props) => {
? selection.filter((x) => !x.providerKey)
: selection;
const fileIds = [];
const folderIds = [];
let fileIds = [];
let folderIds = [];
for (let item of items) {
if (item.fileExst || item.contentLength) {
@ -81,6 +89,13 @@ const OperationsPanelComponent = (props) => {
}
}
if (isFolderActions) {
fileIds = [];
folderIds = [];
folderIds.push(currentFolderId);
}
if (!folderIds.length && !fileIds.length) return;
checkOperationConflict({
@ -152,10 +167,12 @@ export default inject(
const {
moveToPanelVisible,
copyPanelVisible,
isFolderActions,
setCopyPanelVisible,
setMoveToPanelVisible,
setDestFolderId,
setThirdPartyMoveDialogVisible,
setIsFolderActions,
} = dialogsStore;
const provider = selection.find((x) => x.providerKey);
@ -171,10 +188,12 @@ export default inject(
visible: copyPanelVisible || moveToPanelVisible,
provider,
selection,
isFolderActions,
setCopyPanelVisible,
setMoveToPanelVisible,
setDestFolderId,
setIsFolderActions,
setThirdPartyMoveDialogVisible,
checkOperationConflict,
setExpandedPanelKeys,

View File

@ -209,11 +209,20 @@ class SectionHeaderContent extends React.Component {
toastr.success(t("Translations:LinkCopySuccess"));
};
onMoveAction = () => this.props.setMoveToPanelVisible(true);
onCopyAction = () => this.props.setCopyPanelVisible(true);
onMoveAction = () => {
this.props.setIsFolderActions(true);
return this.props.setMoveToPanelVisible(true);
};
onCopyAction = () => {
this.props.setIsFolderActions(true);
return this.props.setCopyPanelVisible(true);
};
downloadAction = () =>
this.props
.downloadAction(this.props.t("Translations:ArchivingData"))
.downloadAction(
this.props.t("Translations:ArchivingData"),
this.props.currentFolderId
)
.catch((err) => toastr.error(err));
renameAction = () => console.log("renameAction click");
@ -256,26 +265,26 @@ class SectionHeaderContent extends React.Component {
key: "link-portal-users",
label: t("LinkForPortalUsers"),
onClick: this.createLinkForPortalUsers,
disabled: false,
disabled: true,
},
{ key: "separator-2", isSeparator: true },
{
key: "move-to",
label: t("MoveTo"),
onClick: this.onMoveAction,
disabled: true,
disabled: false,
},
{
key: "copy",
label: t("Translations:Copy"),
onClick: this.onCopyAction,
disabled: true,
disabled: false,
},
{
key: "download",
label: t("Common:Download"),
onClick: this.downloadAction,
disabled: true,
disabled: false,
},
{
key: "rename",
@ -419,7 +428,7 @@ class SectionHeaderContent extends React.Component {
getData={this.getContextOptionsPlus}
isDisabled={false}
/>
{!personal && (
{personal && (
<ContextMenuButton
className="option-button"
directionX="right"
@ -489,6 +498,7 @@ export default inject(
setMoveToPanelVisible,
setCopyPanelVisible,
setDeleteDialogVisible,
setIsFolderActions,
} = dialogsStore;
const { deleteAction, downloadAction, getHeaderMenu } = filesActionsStore;
@ -518,6 +528,7 @@ export default inject(
setSharingPanelVisible,
setMoveToPanelVisible,
setCopyPanelVisible,
setIsFolderActions,
deleteAction,
setDeleteDialogVisible,
downloadAction,

View File

@ -20,6 +20,7 @@ class DialogsStore {
newFilesPanelVisible = false;
conflictResolveDialogVisible = false;
convertDialogVisible = false;
isFolderActions = false;
removeItem = null;
connectItem = null;
@ -44,6 +45,10 @@ class DialogsStore {
this.sharingPanelVisible = sharingPanelVisible;
};
setIsFolderActions = (isFolderActions) => {
this.isFolderActions = isFolderActions;
};
setChangeOwnerPanelVisible = (ownerPanelVisible) => {
this.ownerPanelVisible = ownerPanelVisible;
};

View File

@ -224,17 +224,17 @@ class FilesActionStore {
});
};
downloadAction = (label) => {
downloadAction = (label, folderId) => {
const {
setSecondaryProgressBarData,
clearSecondaryProgressData,
} = this.uploadDataStore.secondaryProgressDataStore;
const { selection } = this.filesStore;
const fileIds = [];
const folderIds = [];
let fileIds = [];
let folderIds = [];
const items = [];
if (selection.length === 1 && selection[0].fileExst) {
if (selection.length === 1 && selection[0].fileExst && !folderId) {
window.open(selection[0].viewUrl, "_self");
return Promise.resolve();
}
@ -257,6 +257,13 @@ class FilesActionStore {
alert: false,
});
if (folderId) {
folderIds = [];
fileIds = [];
folderIds.push(folderId);
}
return downloadFiles(fileIds, folderIds)
.then((res) => {
this.getDownloadProgress(res[0], label);

View File

@ -893,7 +893,15 @@ class UploadDataStore {
alert: false,
});
getFolder(destFolderId).then((data) => {
let receivedFolder = destFolderId;
let updatedFolder = this.selectedFolderStore.id;
if (this.dialogsStore.isFolderActions) {
receivedFolder = this.selectedFolderStore.parentId;
updatedFolder = destFolderId;
}
getFolder(receivedFolder).then((data) => {
let newTreeFolders = treeFolders;
let path = data.pathParts.slice(0);
let folders = data.folders;
@ -902,14 +910,10 @@ class UploadDataStore {
if (!isCopy || destFolderId === this.selectedFolderStore.id) {
this.filesStore
.fetchFiles(
this.selectedFolderStore.id,
this.filesStore.filter,
true,
true
)
.fetchFiles(updatedFolder, this.filesStore.filter, true, true)
.finally(() => {
setTimeout(() => clearSecondaryProgressData(), TIMEOUT);
this.dialogsStore.setIsFolderActions(false);
});
} else {
setSecondaryProgressBarData({