From c584f75c4ef406e1b97581cbfd35f1a71f5a3abb Mon Sep 17 00:00:00 2001 From: Artem Tarasov Date: Tue, 25 Aug 2020 15:23:43 +0300 Subject: [PATCH] fixed node selection when switching between TreeSettings and TreeFolders --- .../components/Article/Body/TreeSettings.js | 25 +++++++++---------- .../src/components/Article/Body/index.js | 21 ++++++++++------ .../pages/Settings/Section/Body/index.js | 4 +++ .../src/components/pages/Settings/index.js | 13 +++++++++- .../Settings/locales/en/translation.json | 5 +++- .../Settings/locales/ru/translation.json | 5 +++- .../Client/src/store/files/actions.js | 8 +++--- .../Client/src/store/files/reducers.js | 16 +++++++----- 8 files changed, 63 insertions(+), 34 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 e30fc9d152..123261b7fb 100644 --- a/products/ASC.Files/Client/src/components/Article/Body/TreeSettings.js +++ b/products/ASC.Files/Client/src/components/Article/Body/TreeSettings.js @@ -7,7 +7,7 @@ import { history, utils } from "asc-web-common"; import { withTranslation, I18nextProvider } from "react-i18next"; import { createI18N } from "../../../helpers/i18n"; -import { setSelectedSetting, setExpandSettingsTree } from '../../../store/files/actions'; +import { setSelectedNode, setExpandSettingsTree } from '../../../store/files/actions'; const i18n = createI18N({ page: "Settings", @@ -34,9 +34,9 @@ class PureTreeSettings extends React.Component { } componentDidMount() { - const { match, setSelectedSetting, setExpandSettingsTree } = this.props; + const { match, setSelectedNode, setExpandSettingsTree } = this.props; const { setting } = match.params; - setSelectedSetting([setting]); + setSelectedNode([setting]); if (setting) setExpandSettingsTree(['settings']); } @@ -53,22 +53,21 @@ class PureTreeSettings extends React.Component { } onSelect = (section) => { - const { setSelectedSetting, setExpandSettingsTree } = this.props; + const { setSelectedNode, setExpandSettingsTree } = this.props; const path = section[0]; if(path === 'settings') { - setSelectedSetting(['common']); + setSelectedNode(['common']); setExpandSettingsTree(section); return history.push('/products/files/settings/common'); } - setSelectedSetting(section); + setSelectedNode(section); return history.push(`/products/files/settings/${path}`); } onExpand = (data) => { - const { setExpandSettingsTree, setSelectedSetting } = this.props; - setSelectedSetting(['common']); + const { setExpandSettingsTree } = this.props; setExpandSettingsTree(data); } @@ -110,7 +109,7 @@ class PureTreeSettings extends React.Component { render() { const { - selectedSetting, + selectedTreeNode, expandedSetting } = this.props; const nodes = this.renderTreeNode(); @@ -118,7 +117,7 @@ class PureTreeSettings extends React.Component { return ( { function mapStateToProps(state) { const { - selectedSetting, + selectedTreeNode, expandedSetting } = state.files; return { - selectedSetting, + selectedTreeNode, expandedSetting } } export default connect( mapStateToProps, { - setSelectedSetting, + setSelectedNode, setExpandSettingsTree })(withRouter(TreeSettings)); \ No newline at end of file diff --git a/products/ASC.Files/Client/src/components/Article/Body/index.js b/products/ASC.Files/Client/src/components/Article/Body/index.js index 2cb7102629..4bc664f80c 100644 --- a/products/ASC.Files/Client/src/components/Article/Body/index.js +++ b/products/ASC.Files/Client/src/components/Article/Body/index.js @@ -10,7 +10,8 @@ import { setDragItem, setDragging, setNewTreeFilesBadge, - setIsLoading + setIsLoading, + setSelectedNode } from "../../../store/files/actions"; import store from "../../../store/store"; import isEqual from "lodash/isEqual"; @@ -55,8 +56,9 @@ class ArticleBodyContent extends React.Component { } onSelect = data => { - const { selectedKeys, filter, setIsLoading } = this.props; - if (selectedKeys[0] !== data[0]) { + const { filter, setIsLoading, selectedTreeNode, setSelectedNode } = this.props; + if (selectedTreeNode[0] !== data[0]) { + setSelectedNode(data) setIsLoading(true); const newFilter = filter.clone(); newFilter.page = 0; @@ -83,7 +85,6 @@ class ArticleBodyContent extends React.Component { render() { const { data, - selectedKeys, filter, setFilter, setTreeFolders, @@ -100,6 +101,7 @@ class ArticleBodyContent extends React.Component { isShare, setDragging, onTreeDrop, + selectedTreeNode } = this.props; const { showNewFilesPanel, expandedKeys, newFolderId } = this.state; @@ -121,7 +123,7 @@ class ArticleBodyContent extends React.Component { /> )} 0 ? selectedTreeNode : [ selectedFolder.id.toString() ]; + return { data: treeFolders, selectedKeys: selectedFolder ? [currentFolderId] : [""], @@ -186,10 +190,11 @@ function mapStateToProps(state) { selection, dragging, updateTreeNew, - isLoading + isLoading, + selectedTreeNode: selected }; } -export default connect(mapStateToProps, { setFilter, setTreeFolders, setDragItem, setDragging, setNewTreeFilesBadge, setIsLoading })( +export default connect(mapStateToProps, { setFilter, setTreeFolders, setDragItem, setDragging, setNewTreeFilesBadge, setIsLoading, setSelectedNode })( ArticleBodyContent ); \ No newline at end of file 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 f3ec26fedb..1d89b8ed8a 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 @@ -36,6 +36,10 @@ class SectionBodyContent extends React.Component { document.title = t(`${setting}`); } + componentWillUnmount() { + document.title = 'ASC.Files'; + } + renderAdminSettings = () => { const { intermediateVersion, 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 13a458ffd4..073e7b1df1 100644 --- a/products/ASC.Files/Client/src/components/pages/Settings/index.js +++ b/products/ASC.Files/Client/src/components/pages/Settings/index.js @@ -2,6 +2,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { withRouter } from "react-router"; import { PageLayout, utils } from "asc-web-common"; +import { RequestLoader } from "asc-web-components"; import { ArticleHeaderContent, ArticleBodyContent, @@ -52,9 +53,18 @@ class PureSettings extends React.Component { } = this.state; const { match, t, isLoading, setIsLoading } = this.props; const { setting } = match.params; - console.log(setting) return ( + <> + @@ -95,6 +105,7 @@ class PureSettings extends React.Component { /> + ); } } diff --git a/products/ASC.Files/Client/src/components/pages/Settings/locales/en/translation.json b/products/ASC.Files/Client/src/components/pages/Settings/locales/en/translation.json index 039034acd4..bb8d512eaa 100644 --- a/products/ASC.Files/Client/src/components/pages/Settings/locales/en/translation.json +++ b/products/ASC.Files/Client/src/components/pages/Settings/locales/en/translation.json @@ -19,5 +19,8 @@ "storingFileVersion": "Storing file versions", "updateOrCreate": "Update the file version for the existing file with the same name. Otherwise, a copy of the file will be created.", - "keepIntermediateVersion": "Keep intermediate versions when editing" + "keepIntermediateVersion": "Keep intermediate versions when editing", + + "LoadingProcessing": "Loading...", + "LoadingDescription": "Please wait..." } \ No newline at end of file diff --git a/products/ASC.Files/Client/src/components/pages/Settings/locales/ru/translation.json b/products/ASC.Files/Client/src/components/pages/Settings/locales/ru/translation.json index 86db226b29..55f6a3c4a8 100644 --- a/products/ASC.Files/Client/src/components/pages/Settings/locales/ru/translation.json +++ b/products/ASC.Files/Client/src/components/pages/Settings/locales/ru/translation.json @@ -19,5 +19,8 @@ "storingFileVersion": "Хранение версий файлов", "updateOrCreate": "Обновлять версию файла для существующего файла с таким же именем. В противном случае будет создаваться копия файла.", - "keepIntermediateVersion": "Хранить промежуточные версии при редактировании" + "keepIntermediateVersion": "Хранить промежуточные версии при редактировании", + + "LoadingProcessing": "Загрузка...", + "LoadingDescription": "Пожалуйста, подождите..." } \ No newline at end of file diff --git a/products/ASC.Files/Client/src/store/files/actions.js b/products/ASC.Files/Client/src/store/files/actions.js index a99f7774d3..8952467b42 100644 --- a/products/ASC.Files/Client/src/store/files/actions.js +++ b/products/ASC.Files/Client/src/store/files/actions.js @@ -39,7 +39,7 @@ export const SET_VIEW_AS = "SET_VIEW_AS"; export const SET_CONVERT_DIALOG_VISIBLE = "SET_CONVERT_DIALOG_VISIBLE"; export const SET_NEW_TREE_FILES = "SET_NEW_TREE_FILES"; export const SET_NEW_ROW_ITEMS = "SET_NEW_ROW_ITEMS"; -export const SET_SELECTED_SETTING = "SET_SELECTED_SETTING"; +export const SET_SELECTED_NODE = "SET_SELECTED_NODE"; export const SET_EXPAND_SETTINGS_TREE = "SET_EXPAND_SETTINGS_TREE"; export const SET_IS_LOADING = "SET_IS_LOADING"; @@ -190,10 +190,10 @@ export function setNewRowItems(newRowItems) { }; } -export function setSelectedSetting(setting) { +export function setSelectedNode(node) { return { - type: SET_SELECTED_SETTING, - setting + type: SET_SELECTED_NODE, + node } } diff --git a/products/ASC.Files/Client/src/store/files/reducers.js b/products/ASC.Files/Client/src/store/files/reducers.js index 125100ae99..83288fe1cf 100644 --- a/products/ASC.Files/Client/src/store/files/reducers.js +++ b/products/ASC.Files/Client/src/store/files/reducers.js @@ -20,7 +20,7 @@ import { SET_CONVERT_DIALOG_VISIBLE, SET_NEW_TREE_FILES, SET_NEW_ROW_ITEMS, - SET_SELECTED_SETTING, + SET_SELECTED_NODE, SET_EXPAND_SETTINGS_TREE, SET_IS_LOADING } from "./actions"; @@ -47,7 +47,7 @@ const initialState = { convertDialogVisible: false, updateTreeNew: false, newRowItems: [], - selectedSetting: [], + selectedTreeNode: [], expandedSetting: [], isLoading: false }; @@ -147,10 +147,14 @@ const filesReducer = (state = initialState, action) => { return Object.assign({}, state, { newRowItems: action.newRowItems }); - case SET_SELECTED_SETTING: - return Object.assign({}, state, { - selectedSetting: action.setting - }) + case SET_SELECTED_NODE: + if ( action.node[0] ) { + return Object.assign({}, state, { + selectedTreeNode: action.node + }) + } else { + return state; + } case SET_EXPAND_SETTINGS_TREE: return Object.assign({}, state, { expandedSetting: action.setting