Skip to content

Commit

Permalink
Merge pull request #370 from ONLYOFFICE/bugfix/fix-operations-notific…
Browse files Browse the repository at this point in the history
…ations

Bugfix/fix operations notifications
  • Loading branch information
AlexeySafronov authored Oct 5, 2021
2 parents 4f9fddf + cee2e96 commit d0229aa
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 477 deletions.
5 changes: 0 additions & 5 deletions packages/asc-web-common/api/files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,6 @@ export function downloadFiles(fileIds, folderIds) {
return request({ method: "put", url: "/files/fileops/bulkdownload", data });
}

export function downloadFormatFiles(fileConvertIds, folderIds) {
const data = { folderIds, fileConvertIds };
return request({ method: "put", url: "/files/fileops/bulkdownload", data });
}

export function getProgress() {
return request({ method: "get", url: "/files/fileops" });
}
Expand Down
19 changes: 3 additions & 16 deletions products/ASC.Files/Client/src/HOCs/withContextOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,8 @@ export default function withContextOptions(WrappedComponent) {
t,
deleteItemAction,
} = this.props;
const {
id,
title,
fileExst,
contentLength,
folderId,
providerKey,
rootFolderId,
} = item;
const { id, title, providerKey, rootFolderId, isFolder } = item;

const isRootThirdPartyFolder = providerKey && id === rootFolderId;

if (isRootThirdPartyFolder) {
Expand All @@ -251,13 +244,7 @@ export default function withContextOptions(WrappedComponent) {
successRemoveFolder: t("FolderRemoved"),
};

deleteItemAction(
id,
folderId,
translations,
fileExst || contentLength,
providerKey
);
deleteItemAction(id, translations, !isFolder, providerKey);
};

onClickShare = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DeleteDialogComponent extends React.Component {

if (!selection.length) return;

deleteAction(translations, selection).catch((err) => toastr.error(err));
deleteAction(translations, selection);
};

onUnsubscribe = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import RowContent from "@appserver/components/row-content";
import RowContainer from "@appserver/components/row-container";
import { ReactSVG } from "react-svg";
import { withTranslation } from "react-i18next";
import { downloadFormatFiles } from "@appserver/common/api/files";
import { TIMEOUT } from "../../../helpers/constants";
import DownloadContent from "./DownloadContent";
import { inject, observer } from "mobx-react";

Expand Down Expand Up @@ -73,15 +71,8 @@ class DownloadDialogComponent extends React.Component {
return [files, folders];
};

//TODO: move to actions?
onDownload = () => {
const {
//onDownloadProgress,
t,
getDownloadProgress,
setSecondaryProgressBarData,
clearSecondaryProgressData,
} = this.props;
const { t, downloadFiles } = this.props;

const [fileConvertIds, folderIds] = this.getDownloadItems();

Expand All @@ -95,29 +86,7 @@ class DownloadDialogComponent extends React.Component {
window.open(viewUrl, "_self");
this.onClose();
} else if (fileConvertIds.length || folderIds.length) {
setSecondaryProgressBarData({
icon: "file",
visible: true,
percent: 0,
label: t("Translations:ArchivingData"),
alert: false,
});
downloadFormatFiles(fileConvertIds, folderIds)
.then((res) => {
this.onClose();
getDownloadProgress(
res[0],
t("Translations:ArchivingData")
).catch((err) => toastr.error(err));
})
.catch((err) => {
setSecondaryProgressBarData({
visible: true,
alert: true,
});
//toastr.error(err);
setTimeout(() => clearSecondaryProgressData(), TIMEOUT);
});
downloadFiles(fileConvertIds, folderIds, t("Translations:ArchivingData"));
}
};

Expand Down Expand Up @@ -522,40 +491,27 @@ const DownloadDialog = withTranslation([
])(DownloadDialogComponent);

export default inject(
({
filesStore,
uploadDataStore,
formatsStore,
dialogsStore,
filesActionsStore,
}) => {
const { secondaryProgressDataStore } = uploadDataStore;
({ filesStore, formatsStore, dialogsStore, filesActionsStore }) => {
const { sortedFiles } = filesStore;
const { getIcon, getFolderIcon } = formatsStore.iconFormatsStore;
const { filesConverts } = formatsStore.docserviceStore;
const {
setSecondaryProgressBarData,
clearSecondaryProgressData,
} = secondaryProgressDataStore;

const {
downloadDialogVisible: visible,
setDownloadDialogVisible,
} = dialogsStore;

const { getDownloadProgress } = filesActionsStore;
const { downloadFiles } = filesActionsStore;

return {
sortedFiles,
visible,
filesConverts,

setSecondaryProgressBarData,
clearSecondaryProgressData,
getIcon,
getFolderIcon,
setDownloadDialogVisible,
getDownloadProgress,
downloadFiles,
};
}
)(withRouter(observer(DownloadDialog)));
Original file line number Diff line number Diff line change
@@ -1,119 +1,29 @@
import React, { useCallback } from "react";
import React from "react";
import { withRouter } from "react-router";
import ModalDialogContainer from "../ModalDialogContainer";
import Text from "@appserver/components/text";
import Button from "@appserver/components/button";
import ModalDialog from "@appserver/components/modal-dialog";
import { withTranslation } from "react-i18next";
import { getProgress, emptyTrash } from "@appserver/common/api/files";
import toastr from "@appserver/components/toast/toastr";
import { TIMEOUT } from "../../../helpers/constants";
import { inject, observer } from "mobx-react";

const EmptyTrashDialogComponent = (props) => {
const {
visible,
t,
tReady,
filter,
currentFolderId,
setSecondaryProgressBarData,
isLoading,
clearSecondaryProgressData,
fetchFiles,
setEmptyTrashDialogVisible,
emptyTrash,
} = props;

const onClose = () => setEmptyTrashDialogVisible(false);

const loopEmptyTrash = useCallback(
(id) => {
const successMessage = t("SuccessEmptyTrash");
getProgress()
.then((res) => {
const currentProcess = res.find((x) => x.id === id);
if (currentProcess && currentProcess.progress !== 100) {
const newProgressData = {
icon: "trash",
visible: true,
percent: currentProcess.progress,
label: t("Translations:DeleteOperation"),
alert: false,
};
setSecondaryProgressBarData(newProgressData);
setTimeout(() => loopEmptyTrash(id), 1000);
} else {
fetchFiles(currentFolderId, filter)
.then(() => {
setSecondaryProgressBarData({
icon: "trash",
visible: true,
percent: 100,
label: t("Translations:DeleteOperation"),
alert: false,
});
setTimeout(() => clearSecondaryProgressData(), TIMEOUT);
toastr.success(successMessage);
})
.catch((err) => {
setSecondaryProgressBarData({
visible: true,
alert: true,
});
//toastr.error(err);
setTimeout(() => clearSecondaryProgressData(), TIMEOUT);
});
}
})
.catch((err) => {
setSecondaryProgressBarData({
visible: true,
alert: true,
});
//toastr.error(err);
setTimeout(() => clearSecondaryProgressData(), TIMEOUT);
});
},
[
t,
currentFolderId,
filter,
setSecondaryProgressBarData,
clearSecondaryProgressData,
fetchFiles,
]
);

const onEmptyTrash = useCallback(() => {
const newProgressData = {
icon: "trash",
visible: true,
percent: 0,
label: t("Translations:DeleteOperation"),
alert: false,
};
setSecondaryProgressBarData(newProgressData);
const onEmptyTrash = () => {
onClose();
emptyTrash()
.then((res) => {
const id = res[0] && res[0].id ? res[0].id : null;
loopEmptyTrash(id);
})
.catch((err) => {
setSecondaryProgressBarData({
visible: true,
alert: true,
});
//toastr.error(err);
setTimeout(() => clearSecondaryProgressData(), TIMEOUT);
});
}, [
onClose,
loopEmptyTrash,
setSecondaryProgressBarData,
t,
clearSecondaryProgressData,
]);
const translations = { deleteOperation: t("Translations:DeleteOperation") };
emptyTrash(translations);
};

return (
<ModalDialogContainer
Expand Down Expand Up @@ -153,30 +63,22 @@ const EmptyTrashDialog = withTranslation([
"Translations",
])(EmptyTrashDialogComponent);

export default inject(
({ filesStore, uploadDataStore, selectedFolderStore, dialogsStore }) => {
const { secondaryProgressDataStore } = uploadDataStore;
const { fetchFiles, filter, isLoading } = filesStore;
const {
setSecondaryProgressBarData,
clearSecondaryProgressData,
} = secondaryProgressDataStore;
export default inject(({ filesStore, filesActionsStore, dialogsStore }) => {
const { fetchFiles, filter, isLoading } = filesStore;
const { emptyTrash } = filesActionsStore;

const {
emptyTrashDialogVisible: visible,
setEmptyTrashDialogVisible,
} = dialogsStore;
const {
emptyTrashDialogVisible: visible,
setEmptyTrashDialogVisible,
} = dialogsStore;

return {
currentFolderId: selectedFolderStore.id,
isLoading,
filter,
visible,
return {
isLoading,
filter,
visible,

fetchFiles,
setSecondaryProgressBarData,
clearSecondaryProgressData,
setEmptyTrashDialogVisible,
};
}
)(withRouter(observer(EmptyTrashDialog)));
fetchFiles,
setEmptyTrashDialogVisible,
emptyTrash,
};
})(withRouter(observer(EmptyTrashDialog)));
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const OperationsPanelComponent = (props) => {
setMoveToPanelVisible,
checkOperationConflict,
setThirdPartyMoveDialogVisible,
setBufferSelection,
} = props;

const zIndex = 310;
Expand All @@ -34,7 +33,6 @@ const OperationsPanelComponent = (props) => {
const expandedKeys = props.expandedKeys.map((item) => item.toString());

const onClose = () => {
!provider && setBufferSelection(null);
isCopy ? setCopyPanelVisible(false) : setMoveToPanelVisible(false);
setExpandedPanelKeys(null);
};
Expand Down Expand Up @@ -142,12 +140,7 @@ export default inject(
dialogsStore,
filesActionsStore,
}) => {
const {
filter,
selection,
bufferSelection,
setBufferSelection,
} = filesStore;
const { filter, selection, bufferSelection } = filesStore;
const {
isRecycleBinFolder,
operationsFolders,
Expand Down Expand Up @@ -187,7 +180,6 @@ export default inject(
setThirdPartyMoveDialogVisible,
checkOperationConflict,
setExpandedPanelKeys,
setBufferSelection,
};
}
)(withRouter(observer(OperationsPanel)));
Loading

0 comments on commit d0229aa

Please sign in to comment.