From c29d35c36d40b527e8f008cb5e077dca56888165 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 22 Feb 2022 12:30:30 +0300 Subject: [PATCH] Web: Files: Added possibility to delete backup elem without selected file. --- .../data-management/StyledBackup.js | 16 ++--- .../BackupListBody.js | 70 ++++++++++--------- .../BackupListModalDialog.js | 21 +++--- 3 files changed, 55 insertions(+), 52 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/StyledBackup.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/StyledBackup.js index fbd6ba8d70..0b213e848b 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/StyledBackup.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/StyledBackup.js @@ -282,14 +282,14 @@ const StyledBackupList = styled.div` margin: 10px 0 16px 0; } - .backup-list_trash-icon:hover { - path { - fill: #657077; - } - } .backup-list_trash-icon { cursor: pointer; - margin-top: 1px; + margin-top: -3px; + grid-area: trash; + + path { + fill: #a3a9ae; + } } .backup-list_icon { @@ -309,10 +309,6 @@ const StyledBackupList = styled.div` grid-area: ext; } - .backup-list_trash { - grid-area: trash; - } - .backup-list_radio-button { grid-area: radiobutton; } diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/sub-components-restore-backup/BackupListBody.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/sub-components-restore-backup/BackupListBody.js index 1f8bf57860..24b62a41cd 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/sub-components-restore-backup/BackupListBody.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/sub-components-restore-backup/BackupListBody.js @@ -2,7 +2,7 @@ import React, { useCallback } from "react"; import { FixedSizeList as List } from "react-window"; import AutoSizer from "react-virtualized-auto-sizer"; import CustomScrollbarsVirtualList from "@appserver/components/scrollbar/custom-scrollbars-virtual-list"; -import TrashIcon from "../../../../../../../../../public/images/button.trash.react.svg"; +import TrashIcon from "../../../../../../../../../public/images/delete.react.svg"; import { StyledBackupList } from "../StyledBackup"; import { ReactSVG } from "react-svg"; import Text from "@appserver/components/text"; @@ -21,45 +21,51 @@ const BackupListBody = ({ [selectedFileIndex] ); - const Item = ({ index, style }) => { - const file = filesList[index]; - const fileId = file.id; - const fileName = file.fileName; - const isChecked = isFileChecked(index); + const onTrashClick = (id) => { + onDeleteBackup(id); + }; - return ( -
- -
- + const Item = useCallback( + ({ index, style }) => { + const file = filesList[index]; + const fileId = file.id; + const fileName = file.fileName; + const isChecked = isFileChecked(index); - {fileName} + return ( +
+ +
+ - + {fileName} + + -
onTrashClick(fileId)} />
-
-
-
- ); - }; + +
+ ); + }, + [filesList, isFileChecked] + ); + return ( {({ height, width }) => ( diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/sub-components-restore-backup/BackupListModalDialog.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/sub-components-restore-backup/BackupListModalDialog.js index 1abf98217c..5ed4ef2a21 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/sub-components-restore-backup/BackupListModalDialog.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/sub-components-restore-backup/BackupListModalDialog.js @@ -25,10 +25,8 @@ class BackupListModalDialog extends React.Component { this.state = { isLoading: true, filesList: [], - hasNextPage: true, - isNextPageLoading: false, - selectedFileIndex: "", - selectedFileId: "", + selectedFileIndex: null, + selectedFileId: null, }; } componentDidMount() { @@ -65,18 +63,18 @@ class BackupListModalDialog extends React.Component { }); }); }; - onDeleteBackup = (e) => { - const { selectedFileId } = this.state; - - if (!selectedFileId) return; + onDeleteBackup = (backupId) => { + if (!backupId) return; this.setState({ isLoading: true }, function () { - deleteBackup(selectedFileId) + deleteBackup(backupId) .then(() => getBackupHistory()) .then((filesList) => this.setState({ filesList, isLoading: false, + selectedFileIndex: null, + selectedFileId: null, }) ) .catch((error) => { @@ -100,6 +98,7 @@ class BackupListModalDialog extends React.Component { value: backupId, }, ]; + startRestore(backupId, storageType, storageParams, isNotify) .then(() => history.push( @@ -114,6 +113,8 @@ class BackupListModalDialog extends React.Component { .finally(() => this.setState({ isLoading: false, + selectedFileIndex: null, + selectedFileId: null, }) ); }); @@ -121,7 +122,7 @@ class BackupListModalDialog extends React.Component { render() { const { onModalClose, isVisibleDialog, t, isCopyingToLocal } = this.props; const { filesList, isLoading, selectedFileIndex } = this.state; - console.log("selectedFileIndex", selectedFileIndex); + return (