From 4d4e464275725d5ff823b02dd64495effa740832 Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Mon, 8 Feb 2021 10:43:10 +0300 Subject: [PATCH] Web: Files: moved isLoading to mobx store, added checkbox to files row --- .../components/Article/Body/TreeSettings.js | 8 +-- .../components/Article/MainButton/index.js | 2 +- .../components/dialogs/DeleteDialog/index.js | 16 +++--- .../dialogs/EmptyTrashDialog/index.js | 7 +-- .../Home/Section/Body/FilesRowContent.js | 7 +-- .../Home/Section/Body/FilesTileContent.js | 7 +-- .../pages/Home/Section/Body/index.js | 43 +++++++++------- .../pages/Home/Section/Header/index.js | 7 +-- .../Client/src/components/pages/Home/index.js | 13 +++-- .../Settings/Section/Body/ConnectedClouds.js | 2 +- .../pages/Settings/Section/Body/index.js | 24 +++++++-- .../src/components/pages/Settings/index.js | 10 ++-- .../VersionHistory/Section/Body/index.js | 8 +-- .../components/pages/VersionHistory/index.js | 20 ++++++-- .../panels/ChangeOwnerPanel/index.js | 14 +++--- .../panels/OperationsPanel/index.js | 10 ++-- .../components/panels/SharingPanel/index.js | 12 +++-- .../panels/VersionHistoryPanel/index.js | 20 ++++++-- .../ASC.Files/Client/src/store/FilesStore.js | 50 ++++++++++++++++--- 19 files changed, 197 insertions(+), 83 deletions(-) diff --git a/products/ASC.Files/Client/src/components/Article/Body/TreeSettings.js b/products/ASC.Files/Client/src/components/Article/Body/TreeSettings.js index 4c712903b5..e17bc27774 100644 --- a/products/ASC.Files/Client/src/components/Article/Body/TreeSettings.js +++ b/products/ASC.Files/Client/src/components/Article/Body/TreeSettings.js @@ -15,7 +15,7 @@ import { //setIsLoading, } from "../../../store/files/actions"; import { - getIsLoading, + //getIsLoading, getSettingsSelectedTreeNode, getExpandedSetting, getEnableThirdParty, @@ -211,7 +211,7 @@ function mapStateToProps(state) { expandedSetting: getExpandedSetting(state), enableThirdParty: getEnableThirdParty(state), isAdmin: isAdmin(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), //selectedFolder: getSelectedTreeNode(state), }; } @@ -232,10 +232,12 @@ export default connect(mapStateToProps, { //setIsLoading, })( inject(({ store, mainFilesStore }) => { - const { setIsLoading, filesStore } = mainFilesStore; + const { setIsLoading, filesStore, isLoading } = mainFilesStore; const { setSelectedFolder } = filesStore.selectedFolderStore; return { + isLoading, + setIsLoading, setSelectedFolder, }; diff --git a/products/ASC.Files/Client/src/components/Article/MainButton/index.js b/products/ASC.Files/Client/src/components/Article/MainButton/index.js index 6137b9408c..dcc5f48719 100644 --- a/products/ASC.Files/Client/src/components/Article/MainButton/index.js +++ b/products/ASC.Files/Client/src/components/Article/MainButton/index.js @@ -9,7 +9,7 @@ import { /* setAction, */ startUpload } from "../../../store/files/actions"; import { canCreate, getFilter, - getSelectedFolder, + //getSelectedFolder, //getFirstLoad, getIsPrivacyFolder, } from "../../../store/files/selectors"; 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 dc944384fd..f71eca62cd 100644 --- a/products/ASC.Files/Client/src/components/dialogs/DeleteDialog/index.js +++ b/products/ASC.Files/Client/src/components/dialogs/DeleteDialog/index.js @@ -24,9 +24,9 @@ import { //getSelectedFolderId, getFilter, getTreeFolders, - getIsLoading, + //getIsLoading, getIsRecycleBinFolder, - getSelection, + //getSelection, isRootFolder, getIsPrivacyFolder, } from "../../../store/files/selectors"; @@ -308,10 +308,10 @@ const mapStateToProps = (state) => { //currentFolderId: getSelectedFolderId(state), filter: getFilter(state), treeFolders: getTreeFolders(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), isRecycleBinFolder: getIsRecycleBinFolder(state), isPrivacy: getIsPrivacyFolder(state), - selection: getSelection(state), + //selection: getSelection(state), isRootFolder: isRootFolder(state), }; }; @@ -332,11 +332,13 @@ export default connect(mapStateToProps, { //fetchFiles, })( inject(({ store, mainFilesStore }) => { - const { filesStore } = mainFilesStore; - const { fetchFiles } = filesStore; + const { filesStore, isLoading } = mainFilesStore; + const { fetchFiles, selection, selectedFolderStore } = filesStore; return { - currentFolderId: filesStore.selectedFolderStore.id, + currentFolderId: selectedFolderStore.id, + selection, + isLoading, fetchFiles, }; diff --git a/products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js b/products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js index 679c8ad497..a286d5c4c1 100644 --- a/products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js +++ b/products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js @@ -14,7 +14,7 @@ import { TIMEOUT } from "../../../helpers/constants"; import { //getSelectedFolderId, getFilter, - getIsLoading, + //getIsLoading, } from "../../../store/files/selectors"; import { createI18N } from "../../../helpers/i18n"; import { inject, observer } from "mobx-react"; @@ -178,7 +178,7 @@ const mapStateToProps = (state) => { return { //currentFolderId: getSelectedFolderId(state), filter: getFilter(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), }; }; @@ -194,11 +194,12 @@ export default connect(mapStateToProps, { //fetchFiles, })( inject(({ store, mainFilesStore }) => { - const { filesStore } = mainFilesStore; + const { filesStore, isLoading } = mainFilesStore; const { fetchFiles } = filesStore; return { currentFolderId: filesStore.selectedFolderStore.id, + isLoading, fetchFiles, }; diff --git a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js index a88be20f19..1f14d940bb 100644 --- a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js +++ b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js @@ -33,7 +33,7 @@ import { //getFileAction, getFilter, //getFolders, - getIsLoading, + //getIsLoading, getIsPrivacyFolder, getIsRecycleBinFolder, getNewRowItems, @@ -766,7 +766,7 @@ function mapStateToProps(state, props) { //selectedFolder: getSelectedFolder(state), //folders: getFolders(state), newRowItems: getNewRowItems(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), isPrivacy: getIsPrivacyFolder(state), isDesktop: isDesktopClient(state), @@ -808,7 +808,7 @@ export default connect(mapStateToProps, { replaceFileStream, })( inject(({ store, mainFilesStore }) => { - const { filesStore, setIsLoading } = mainFilesStore; + const { filesStore, setIsLoading, isLoading } = mainFilesStore; const { folders, fetchFiles } = filesStore; const { type, extension, id } = filesStore.fileActionStore; @@ -821,6 +821,7 @@ export default connect(mapStateToProps, { selectedFolderPathParts: filesStore.selectedFolderStore.pathParts, newItems: filesStore.selectedFolderStore.new, parentFolder: filesStore.selectedFolderStore.parentId, + isLoading, setIsLoading, fetchFiles, diff --git a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesTileContent.js b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesTileContent.js index 9ca7fd9264..f7343dd58e 100644 --- a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesTileContent.js +++ b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesTileContent.js @@ -20,7 +20,7 @@ import { //getFileAction, getFilter, //getFolders, - getIsLoading, + //getIsLoading, getNewRowItems, //getSelectedFolder, //getSelectedFolderNew, @@ -454,7 +454,7 @@ function mapStateToProps(state, props) { //folders: getFolders(state), newRowItems: getNewRowItems(state), dragging: getDragging(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), canWebEdit: canWebEdit(props.item.fileExst)(state), }; } @@ -477,7 +477,7 @@ export default connect(mapStateToProps, { //fetchFiles, })( inject(({ store, mainFilesStore }) => { - const { filesStore, setIsLoading } = mainFilesStore; + const { filesStore, setIsLoading, isLoading } = mainFilesStore; const { folders, fetchFiles } = filesStore; const { type, extension, id } = filesStore.fileActionStore; @@ -491,6 +491,7 @@ export default connect(mapStateToProps, { selectedFolderPathParts: filesStore.selectedFolderStore.pathParts, newItems: filesStore.selectedFolderStore.new, parentFolder: filesStore.selectedFolderStore.parentId, + isLoading, setIsLoading, fetchFiles, diff --git a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js index 102e43cb87..5556ee1ae7 100644 --- a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js +++ b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js @@ -3,7 +3,7 @@ import { withRouter } from "react-router"; import { connect } from "react-redux"; import { ReactSVG } from "react-svg"; import { withTranslation, Trans } from "react-i18next"; -import equal from "fast-deep-equal/react"; +//import equal from "fast-deep-equal/react"; import copy from "copy-to-clipboard"; import styled from "styled-components"; import queryString from "query-string"; @@ -36,10 +36,10 @@ import { markItemAsFavorite, removeItemFromFavorite, fetchFavoritesFolder, - deselectFile, + //deselectFile, updateFile, //fetchFiles, - selectFile, + //selectFile, //setAction, //setDragging, setDragItem, @@ -48,7 +48,7 @@ import { setUpdateTree, setSecondaryProgressBarData, //setSelected, - setSelection, + //setSelection, setTreeFolders, getFileInfo, addFileToRecentlyViewed, @@ -75,7 +75,7 @@ import { //getSelectedFolderParentId, //getSelected, //getSelectedFolderTitle, - getSelection, + //getSelection, getTreeFolders, getViewAs, loopTreeFolders, @@ -973,7 +973,7 @@ class SectionBodyContent extends React.Component { }); }; - needForUpdate = (currentProps, nextProps) => { + /*needForUpdate = (currentProps, nextProps) => { if (currentProps.widthProp !== nextProps.widthProp) { return true; } @@ -997,7 +997,7 @@ class SectionBodyContent extends React.Component { } return false; - }; + };*/ onContentRowSelect = (checked, file) => { if (!file) return; @@ -1974,7 +1974,7 @@ class SectionBodyContent extends React.Component { viewAs={viewAs} {...checkedProps} {...contextOptionsProps} - needForUpdate={this.needForUpdate} + //needForUpdate={this.needForUpdate} > @@ -2148,7 +2148,7 @@ const mapStateToProps = (state) => { privacyInstructions: getPrivacyInstructionsLink(state), //selected: getSelected(state), //selectedFolderId: getSelectedFolderId(state), - selection: getSelection(state), + //selection: getSelection(state), settings: getSettings(state), //title: getSelectedFolderTitle(state), treeFolders: getTreeFolders(state), @@ -2194,15 +2194,15 @@ const mapStateToProps = (state) => { // })(withRouter(withTranslation()(SectionBodyContent))); export default connect(mapStateToProps, { - deselectFile, + //deselectFile, updateFile, //fetchFiles, - selectFile, + //selectFile, setTreeFolders, setDragItem, setMediaViewerData, setSecondaryProgressBarData, - setSelection, + //setSelection, //setSelected, setUpdateTree, //setIsLoading, @@ -2227,10 +2227,13 @@ export default connect(mapStateToProps, { setSelected, fileActionStore, firstLoad, - getFilesList, - fetchFiles + filesList, + fetchFiles, + setSelection, + selection, + selectFile, + deselectFile, } = filesStore; - const { type, extension, id, setAction } = fileActionStore; @@ -2243,16 +2246,20 @@ export default connect(mapStateToProps, { folders, selected, firstLoad, - filesList: getFilesList(), + filesList, title: filesStore.selectedFolderStore.title, parentId: filesStore.selectedFolderStore.parentId, selectedFolderId: filesStore.selectedFolderStore.id, + selection, setDragging, setAction, setSelected, setIsLoading, - fetchFiles + setSelection, + fetchFiles, + selectFile, + deselectFile, }; })(withRouter(withTranslation()(observer(SectionBodyContent)))) ); diff --git a/products/ASC.Files/Client/src/components/pages/Home/Section/Header/index.js b/products/ASC.Files/Client/src/components/pages/Home/Section/Header/index.js index 6ee28c7fa8..5e6632e747 100644 --- a/products/ASC.Files/Client/src/components/pages/Home/Section/Header/index.js +++ b/products/ASC.Files/Client/src/components/pages/Home/Section/Header/index.js @@ -43,7 +43,7 @@ import { //getSelectedFolderTitle, getFilter, //getSelectedFolderId, - getSelection, + //getSelection, //getSelectedFolderParentId, //getIsRootFolder, getHeaderVisible, @@ -701,7 +701,7 @@ const mapStateToProps = (state) => { isPrivacy: getIsPrivacyFolder(state), isDesktop: isDesktopClient(state), //parentId: getSelectedFolderParentId(state), - selection: getSelection(state), + //selection: getSelection(state), //title: getSelectedFolderTitle(state), filter: getFilter(state), deleteDialogVisible: getUserAccess(state), @@ -739,7 +739,7 @@ export default connect(mapStateToProps, { })( inject(({ store, mainFilesStore }) => { const { filesStore, setIsLoading } = mainFilesStore; - const { setSelected, fileActionStore, fetchFiles } = filesStore; + const { setSelected, fileActionStore, fetchFiles, selection } = filesStore; const { setAction } = fileActionStore; return { @@ -747,6 +747,7 @@ export default connect(mapStateToProps, { title: filesStore.selectedFolderStore.title, parentId: filesStore.selectedFolderStore.parentId, currentFolderId: filesStore.selectedFolderStore.id, + selection, setSelected, setAction, diff --git a/products/ASC.Files/Client/src/components/pages/Home/index.js b/products/ASC.Files/Client/src/components/pages/Home/index.js index 836f8c82f0..36bb0871f6 100644 --- a/products/ASC.Files/Client/src/components/pages/Home/index.js +++ b/products/ASC.Files/Client/src/components/pages/Home/index.js @@ -35,7 +35,7 @@ import { getSecondaryProgressData, getTreeFolders, getViewAs, - getIsLoading, + //getIsLoading, //getDragging, //getFirstLoad, isSecondaryProgressFinished, @@ -337,7 +337,7 @@ function mapStateToProps(state) { secondaryProgressData: getSecondaryProgressData(state), treeFolders: getTreeFolders(state), viewAs: getViewAs(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), //homepage: getSettingsHomepage(state), //dragging: getDragging(state), //firstLoad: getFirstLoad(state), @@ -367,7 +367,13 @@ export default connect( mapDispatchToProps )( inject(({ store, mainFilesStore }) => { - const { dragging, setDragging, setIsLoading, filesStore } = mainFilesStore; + const { + dragging, + setDragging, + setIsLoading, + filesStore, + isLoading, + } = mainFilesStore; const { firstLoad, setFirstLoad, fileActionStore, fetchFiles } = filesStore; const { id } = fileActionStore; @@ -377,6 +383,7 @@ export default connect( dragging, fileActionId: id, currentFolderId: filesStore.selectedFolderStore.id, + isLoading, setFirstLoad, setDragging, diff --git a/products/ASC.Files/Client/src/components/pages/Settings/Section/Body/ConnectedClouds.js b/products/ASC.Files/Client/src/components/pages/Settings/Section/Body/ConnectedClouds.js index bb1f05c810..40b89b52b8 100644 --- a/products/ASC.Files/Client/src/components/pages/Settings/Section/Body/ConnectedClouds.js +++ b/products/ASC.Files/Client/src/components/pages/Settings/Section/Body/ConnectedClouds.js @@ -21,7 +21,7 @@ import { openConnectWindow, setConnectItem, setShowThirdPartyPanel, - fetchFiles, + //fetchFiles, setSelectedNode, } from "../../../../../store/files/actions"; import { diff --git a/products/ASC.Files/Client/src/components/pages/Settings/Section/Body/index.js b/products/ASC.Files/Client/src/components/pages/Settings/Section/Body/index.js index 62699411d9..83e665c1ea 100644 --- a/products/ASC.Files/Client/src/components/pages/Settings/Section/Body/index.js +++ b/products/ASC.Files/Client/src/components/pages/Settings/Section/Body/index.js @@ -12,7 +12,7 @@ import { setForceSave, } from "../../../../../store/files/actions"; import { - getIsLoading, + //getIsLoading, getSettingsSelectedTreeNode, getSettingsTreeStoreOriginalFiles, getSettingsTreeConfirmDelete, @@ -23,6 +23,7 @@ import { getSettingsTree, } from "../../../../../store/files/selectors"; import ConnectClouds from "./ConnectedClouds"; +import { inject, observer } from "mobx-react"; const { isAdmin } = store.auth.selectors; @@ -189,11 +190,20 @@ function mapStateToProps(state) { forceSave: getSettingsTreeForceSave(state), storeForceSave: getSettingsTreeStoreForceSave(state), enableThirdParty: getSettingsTreeEnableThirdParty(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), settingsTree: getSettingsTree(state), }; } +// export default connect(mapStateToProps, { +// setUpdateIfExist, +// setStoreOriginal, +// setEnableThirdParty, +// setConfirmDelete, +// setStoreForceSave, +// setForceSave, +// })(SectionBodyContent); + export default connect(mapStateToProps, { setUpdateIfExist, setStoreOriginal, @@ -201,4 +211,12 @@ export default connect(mapStateToProps, { setConfirmDelete, setStoreForceSave, setForceSave, -})(SectionBodyContent); +})( + inject(({ store, mainFilesStore }) => { + const { isLoading } = mainFilesStore; + + return { + isLoading, + }; + })(observer(SectionBodyContent)) +); diff --git a/products/ASC.Files/Client/src/components/pages/Settings/index.js b/products/ASC.Files/Client/src/components/pages/Settings/index.js index a40cb42a7b..85e1d9e7f3 100644 --- a/products/ASC.Files/Client/src/components/pages/Settings/index.js +++ b/products/ASC.Files/Client/src/components/pages/Settings/index.js @@ -15,7 +15,9 @@ import { //setFirstLoad, setSelectedNode, } from "../../../store/files/actions"; -import { getSettingsTree, getIsLoading } from "../../../store/files/selectors"; +import { + getSettingsTree /* getIsLoading */, +} from "../../../store/files/selectors"; import { setDocumentTitle } from "../../../helpers/utils"; import { inject, observer } from "mobx-react"; @@ -129,7 +131,7 @@ const Settings = (props) => { function mapStateToProps(state) { return { - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), settingsTree: getSettingsTree(state), }; } @@ -152,10 +154,12 @@ export default connect( mapDispatchToProps )( inject(({ store, mainFilesStore }) => { - const { filesStore } = mainFilesStore; + const { filesStore, isLoading } = mainFilesStore; const { setFirstLoad } = filesStore; return { + isLoading, + setFirstLoad, }; })(withRouter(observer(Settings))) diff --git a/products/ASC.Files/Client/src/components/pages/VersionHistory/Section/Body/index.js b/products/ASC.Files/Client/src/components/pages/VersionHistory/Section/Body/index.js index 96935d4e19..4e3effd224 100644 --- a/products/ASC.Files/Client/src/components/pages/VersionHistory/Section/Body/index.js +++ b/products/ASC.Files/Client/src/components/pages/VersionHistory/Section/Body/index.js @@ -13,7 +13,7 @@ import { } from "../../../../../store/files/actions"; import { getFileVersions, - getIsLoading, + //getIsLoading, } from "../../../../../store/files/selectors"; import { inject, observer } from "mobx-react"; @@ -70,7 +70,7 @@ class SectionBodyContent extends React.Component { const mapStateToProps = (state) => { return { versions: getFileVersions(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), }; }; @@ -92,10 +92,12 @@ export default connect( mapDispatchToProps )( inject(({ store, mainFilesStore }) => { - const { filesStore, setIsLoading } = mainFilesStore; + const { filesStore, setIsLoading, isLoading } = mainFilesStore; const { setFirstLoad } = filesStore; return { + isLoading, + setFirstLoad, setIsLoading, }; diff --git a/products/ASC.Files/Client/src/components/pages/VersionHistory/index.js b/products/ASC.Files/Client/src/components/pages/VersionHistory/index.js index 132990d18c..649b01da83 100644 --- a/products/ASC.Files/Client/src/components/pages/VersionHistory/index.js +++ b/products/ASC.Files/Client/src/components/pages/VersionHistory/index.js @@ -18,9 +18,10 @@ import { } from "../../../store/files/actions"; import { getFilter, - getIsLoading, + //getIsLoading, getFileVersions, } from "../../../store/files/selectors"; +import { inject, observer } from "mobx-react"; const i18n = createI18N({ page: "VersionHistory", @@ -116,7 +117,7 @@ VersionHistory.propTypes = { function mapStateToProps(state) { return { - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), isTabletView: getIsTabletView(state), filter: getFilter(state), versions: getFileVersions(state), @@ -131,7 +132,20 @@ const mapDispatchToProps = (dispatch) => { }; }; +// export default connect( +// mapStateToProps, +// mapDispatchToProps +// )(withRouter(VersionHistory)); + export default connect( mapStateToProps, mapDispatchToProps -)(withRouter(VersionHistory)); +)( + inject(({ store, mainFilesStore }) => { + const { isLoading } = mainFilesStore; + + return { + isLoading, + }; + })(withRouter(observer(VersionHistory))) +); diff --git a/products/ASC.Files/Client/src/components/panels/ChangeOwnerPanel/index.js b/products/ASC.Files/Client/src/components/panels/ChangeOwnerPanel/index.js index 71de89763c..9bdff9073f 100644 --- a/products/ASC.Files/Client/src/components/panels/ChangeOwnerPanel/index.js +++ b/products/ASC.Files/Client/src/components/panels/ChangeOwnerPanel/index.js @@ -19,8 +19,8 @@ import { setChangeOwnerPanelVisible, } from "../../../store/files/actions"; import { - getSelection, - getIsLoading, + //getSelection, + //getIsLoading, //getFiles, //getFolders, getShowOwnerChangePanel, @@ -203,9 +203,9 @@ const ChangeOwnerPanel = (props) => ( const mapStateToProps = (state) => { return { - selection: getSelection(state), + //selection: getSelection(state), groupsCaption: getSettingsCustomNamesGroupsCaption(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), //files: getFiles(state), //folders: getFolders(state), visible: getShowOwnerChangePanel(state), @@ -227,12 +227,14 @@ export default connect(mapStateToProps, { }); inject(({ store, mainFilesStore }) => { - const { filesStore, setIsLoading } = mainFilesStore; - const { files, folders } = filesStore; + const { filesStore, setIsLoading, isLoading } = mainFilesStore; + const { files, folders, selection } = filesStore; return { files, folders, + selection, + isLoading, setIsLoading, }; diff --git a/products/ASC.Files/Client/src/components/panels/OperationsPanel/index.js b/products/ASC.Files/Client/src/components/panels/OperationsPanel/index.js index 987e8ddf3f..27e307d717 100644 --- a/products/ASC.Files/Client/src/components/panels/OperationsPanel/index.js +++ b/products/ASC.Files/Client/src/components/panels/OperationsPanel/index.js @@ -13,7 +13,7 @@ import { } from "../../../store/files/actions"; import { getFilter, - getSelection, + //getSelection, //getPathParts, //getSelectedFolderId, getIsRecycleBinFolder, @@ -209,7 +209,7 @@ const OperationsPanel = (props) => ( const mapStateToProps = (state) => { return { filter: getFilter(state), - selection: getSelection(state), + //selection: getSelection(state), //expandedKeys: getPathParts(state), //currentFolderId: getSelectedFolderId(state), isRecycleBin: getIsRecycleBinFolder(state), @@ -228,10 +228,12 @@ export default connect(mapStateToProps, { })( inject(({ store, mainFilesStore }) => { const { filesStore } = mainFilesStore; + const { selection, selectedFolderStore } = filesStore; return { - expandedKeys: filesStore.selectedFolderStore.pathParts, - currentFolderId: filesStore.selectedFolderStore.id, + expandedKeys: selectedFolderStore.pathParts, + currentFolderId: selectedFolderStore.id, + selection, }; })(withRouter(observer(OperationsPanel))) ); diff --git a/products/ASC.Files/Client/src/components/panels/SharingPanel/index.js b/products/ASC.Files/Client/src/components/panels/SharingPanel/index.js index bfc8c7110a..0a9785861b 100644 --- a/products/ASC.Files/Client/src/components/panels/SharingPanel/index.js +++ b/products/ASC.Files/Client/src/components/panels/SharingPanel/index.js @@ -27,10 +27,10 @@ import { import { getAccessOption, getExternalAccessOption, - getSelection, + //getSelection, getSharePanelVisible, getCanShareOwnerChange, - getIsLoading, + //getIsLoading, //getFiles, //getFolders, getIsPrivacyFolder, @@ -639,7 +639,7 @@ const mapStateToProps = (state, ownProps) => { groupsCaption: getSettingsCustomNamesGroupsCaption(state), sharingPanelVisible: getSharePanelVisible(state), canShareOwnerChange: getCanShareOwnerChange(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), //files: getFiles(state), //folders: getFolders(state), //settings: getSettings(state), @@ -668,13 +668,15 @@ export default connect(mapStateToProps, { }); inject(({ store, mainFilesStore }) => { - const { filesStore, setIsLoading } = mainFilesStore; - const { files, folders } = filesStore; + const { filesStore, setIsLoading, isLoading } = mainFilesStore; + const { files, folders, selection } = filesStore; return { homepage: store.settingsStore.homepage, files, folders, + //selection, + isLoading, setIsLoading, }; diff --git a/products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js b/products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js index 118344073d..97a00b2b77 100644 --- a/products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js +++ b/products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js @@ -11,7 +11,7 @@ import { createI18N } from "../../../helpers/i18n"; import { setIsVerHistoryPanel } from "../../../store/files/actions"; import { getVerHistoryFileId, - getIsLoading, + //getIsLoading, getFileVersions, } from "../../../store/files/selectors"; @@ -23,6 +23,7 @@ import { } from "../StyledPanels"; import { SectionBodyContent } from "../../pages/VersionHistory/Section/"; +import { inject, observer } from "mobx-react"; const i18n = createI18N({ page: "VersionHistory", @@ -124,7 +125,7 @@ function mapStateToProps(state) { fileId: getVerHistoryFileId(state), isTabletView: getIsTabletView(state), homepage: getSettingsHomepage(state), - isLoading: getIsLoading(state), + //isLoading: getIsLoading(state), versions: getFileVersions(state), }; } @@ -136,7 +137,20 @@ function mapDispatchToProps(dispatch) { }; } +// export default connect( +// mapStateToProps, +// mapDispatchToProps +// )(VersionHistoryPanel); + export default connect( mapStateToProps, mapDispatchToProps -)(VersionHistoryPanel); +)( + inject(({ store, mainFilesStore }) => { + const { isLoading } = mainFilesStore; + + return { + isLoading, + }; + })(observer(VersionHistoryPanel)) +); diff --git a/products/ASC.Files/Client/src/store/FilesStore.js b/products/ASC.Files/Client/src/store/FilesStore.js index 1a48946a8c..d9c9ac11fd 100644 --- a/products/ASC.Files/Client/src/store/FilesStore.js +++ b/products/ASC.Files/Client/src/store/FilesStore.js @@ -1,4 +1,4 @@ -import { makeObservable, action, observable } from "mobx"; +import { makeObservable, action, observable, computed } from "mobx"; import { api, constants, store } from "asc-web-common"; import FileActionStore from "./FileActionStore"; import SelectedFolderStore from "./SelectedFolderStore"; @@ -15,6 +15,7 @@ class FilesStore { firstLoad = true; files = []; folders = []; + selection = []; selected = "close"; filter = FilesFilter.getDefault(); //TODO: FILTER @@ -28,14 +29,18 @@ class FilesStore { folders: observable, selected: observable, filter: observable, //TODO: FILTER + selection: observable, setFirstLoad: action, setFiles: action, setFolders: action, setSelected: action, setFilesFilter: action, //TODO: FILTER + setSelection: action, fetchFiles: action, - getFilesList: action, + filesList: computed, + selectFile: action, + deselectFile: action, }); this.fileActionStore = new FileActionStore(); @@ -63,6 +68,10 @@ class FilesStore { this.filter = filter; }; + setSelection = (selection) => { + this.selection = selection; + }; + fetchFiles = (folderId, filter, clearFilter = true) => { const filterData = filter ? filter.clone() : FilesFilter.getDefault(); filterData.folder = folderId; @@ -128,7 +137,7 @@ class FilesStore { }); }; - getFilesList = () => { + get filesList() { const items = this.folders && this.files ? [...this.folders, ...this.files] @@ -169,11 +178,13 @@ class FilesStore { //const canOpenPlayer = isMediaOrImage(item.fileExst)(state); //const contextOptions = getFilesContextOptions(item,isRecycleBin,isRecent,isFavorites,isVisitor,canOpenPlayer,canChangeOwner,haveAccess,canShare,isPrivacy,isRootFolder); - //const checked = isFileSelected(selection, id, parentId); + const checked = this.isFileSelected(this.selection, id, parentId); - //const selectedItem = selection.find((x) => x.id === id && x.fileExst === fileExst); + const selectedItem = this.selection.find( + (x) => x.id === id && x.fileExst === fileExst + ); - //const isFolder = selectedItem ? false : fileExst ? false : true; + const isFolder = selectedItem ? false : fileExst ? false : true; //const draggable = selectedItem && !isRecycleBin && selectedItem.id !== actionId; @@ -187,7 +198,7 @@ class FilesStore { return { access, - //checked, + checked, comment, contentLength, //contextOptions, @@ -201,7 +212,7 @@ class FilesStore { foldersCount, //icon, id, - //isFolder, + isFolder, locked, new: item.new, parentId, @@ -224,6 +235,29 @@ class FilesStore { //canShare, }; }); + } + + isFileSelected = (selection, fileId, parentId) => { + const item = selection.find( + (x) => x.id === fileId && x.parentId === parentId + ); + + return item !== undefined; + }; + + selectFile = (file) => { + console.log("selectFile", file); + const { id, parentId } = file; + const isFileSelected = this.isFileSelected(this.selection, id, parentId); + console.log("isFileSelected", isFileSelected); + if (!isFileSelected) this.selection.push(file); + }; + + deselectFile = (file) => { + const { id, parentId } = file; + const isFileSelected = this.isFileSelected(this.selection, id, parentId); + if (isFileSelected) + this.selection = this.selection.filter((x) => x.id !== id); }; }