From 9746006457ee6a3a2bbfa75f038540c348fa360b Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Mon, 29 Nov 2021 14:59:27 +0300 Subject: [PATCH] Fixed Bug 54082 - Client.Files.Removed change of confirmation text. --- .../components/dialogs/DeleteDialog/index.js | 60 ++++++++++++++----- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/products/ASC.Files/Client/src/components/dialogs/DeleteDialog/index.js b/products/ASC.Files/Client/src/components/dialogs/DeleteDialog/index.js index 243a9235f5e..66c63dc0fa9 100644 --- a/products/ASC.Files/Client/src/components/dialogs/DeleteDialog/index.js +++ b/products/ASC.Files/Client/src/components/dialogs/DeleteDialog/index.js @@ -114,6 +114,49 @@ class DeleteDialogComponent extends React.Component { this.props.setDeleteDialogVisible(false); }; + moveToTrashTitle = (checkedSelections) => { + const { unsubscribe, t } = this.props; + const { filesList, foldersList } = this.state; + + const itemsCount = filesList.length + foldersList.length; + const checkedSelectionCount = checkedSelections.length; + + if (unsubscribe) { + return t("UnsubscribeTitle"); + } else { + if ( + (checkedSelectionCount < itemsCount && itemsCount > 1) || + checkedSelectionCount > 1 + ) { + return t("MoveToTrashItemsTitle"); + } else { + return filesList.length === 1 + ? t("MoveToTrashOneFileTitle") + : t("MoveToTrashOneFolderTitle"); + } + } + }; + + moveToTrashNoteText = (checkedSelections) => { + const { filesList, foldersList } = this.state; + const { t, personal } = this.props; + + const itemsCount = filesList.length + foldersList.length; + const checkedSelectionCount = checkedSelections.length; + + if ( + (checkedSelectionCount < itemsCount && itemsCount > 1) || + checkedSelectionCount > 1 + ) { + return t("MoveToTrashItemsNote"); + } else { + return filesList.length === 1 + ? t("MoveToTrashOneFileNote") + : personal + ? "" + : t("MoveToTrashOneFolderNote"); + } + }; render() { const { visible, @@ -123,7 +166,6 @@ class DeleteDialogComponent extends React.Component { unsubscribe, isPrivacyFolder, isRecycleBinFolder, - personal, } = this.props; const { filesList, foldersList, selection } = this.state; @@ -132,23 +174,11 @@ class DeleteDialogComponent extends React.Component { const title = isPrivacyFolder || isRecycleBinFolder || checkedSelections[0]?.providerKey ? t("Common:Confirmation") - : unsubscribe - ? t("UnsubscribeTitle") - : checkedSelections.length === 1 || isPrivacyFolder - ? checkedSelections[0].fileExst - ? t("MoveToTrashOneFileTitle") - : t("MoveToTrashOneFolderTitle") - : t("MoveToTrashItemsTitle"); + : this.moveToTrashTitle(checkedSelections); const noteText = unsubscribe ? t("UnsubscribeNote") - : checkedSelections.length === 1 || isPrivacyFolder - ? checkedSelections[0].fileExst - ? t("MoveToTrashOneFileNote") - : personal - ? "" - : t("MoveToTrashOneFolderNote") - : t("MoveToTrashItemsNote"); + : this.moveToTrashNoteText(checkedSelections); const accessButtonLabel = isPrivacyFolder || isRecycleBinFolder || checkedSelections[0]?.providerKey