From 9d5c5e5e8c4981873b3ea96c8c0f1af1e3414b0e Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Fri, 30 Aug 2019 10:07:43 +0300 Subject: [PATCH 1/3] web: People: Fixed route to edit self profile on user --- products/ASC.People/Client/src/App.js | 1 + .../ASC.People/Client/src/helpers/privateRoute.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/products/ASC.People/Client/src/App.js b/products/ASC.People/Client/src/App.js index 5fe5d51ca0..5e42a29932 100644 --- a/products/ASC.People/Client/src/App.js +++ b/products/ASC.People/Client/src/App.js @@ -32,6 +32,7 @@ const App = ({ settings }) => { path={`${homepage}/edit/:userId`} component={ProfileAction} restricted + allowForMe /> { - const { isAuthenticated, isLoaded, isAdmin, restricted } = rest; + const { isAuthenticated, isLoaded, isAdmin, restricted, allowForMe, currentUser, computedMatch } = rest; + const { userId } = computedMatch.params; + + console.log("PrivateRoute render", rest); return ( { /> ) : isAuthenticated ? ( restricted - ? (isAdmin + ? (isAdmin || (allowForMe && userId && isMe(currentUser, userId)) ? : ) @@ -42,7 +45,8 @@ function mapStateToProps(state) { return { isAuthenticated: state.auth.isAuthenticated, isLoaded: state.auth.isLoaded, - isAdmin: isAdmin(state.auth.user) + isAdmin: isAdmin(state.auth.user), + currentUser: state.auth.user }; } From 6218363b52148a09cba3f4bf140c06c967278e29 Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Fri, 30 Aug 2019 11:36:19 +0300 Subject: [PATCH 2/3] web: People: Added change group tree by filter --- .../src/components/Article/Body/index.js | 66 +++++++++++-------- .../Client/src/store/people/actions.js | 22 +++---- web/ASC.Web.Components/src/index.js | 3 +- web/ASC.Web.Components/src/utils/index.js | 4 ++ 4 files changed, 56 insertions(+), 39 deletions(-) create mode 100644 web/ASC.Web.Components/src/utils/index.js diff --git a/products/ASC.People/Client/src/components/Article/Body/index.js b/products/ASC.People/Client/src/components/Article/Body/index.js index bf07a84e5d..2ffa24c465 100644 --- a/products/ASC.People/Client/src/components/Article/Body/index.js +++ b/products/ASC.People/Client/src/components/Article/Body/index.js @@ -1,4 +1,5 @@ -import React, { useCallback } from 'react'; +import React from 'react'; +import { utils } from 'asc-web-components'; import { connect } from 'react-redux'; import { TreeMenu, @@ -50,16 +51,25 @@ const getItems = data => { }); }; -const PeopleTreeMenu = props => { - const { data, selectGroup, defaultSelectedKeys } = props; +class ArticleBodyContent extends React.Component { - console.log("PeopleTreeMenu", props); + shouldComponentUpdate(nextProps) { + if(!utils.array.isArrayEqual(nextProps.selectedKeys, this.props.selectedKeys)) { + return true; + } - const onSelect = useCallback(data => { - selectGroup(data && data.length === 1 && data[0] !== "root" ? data[0] : null); - }, [selectGroup]) + if(!utils.array.isArrayEqual(nextProps.data, this.props.data)) { + return true; + } - const switcherIcon = obj => { + return false; + } + + onSelect = data => { + this.props.selectGroup(data && data.length === 1 && data[0] !== "root" ? data[0] : null); + }; + + switcherIcon = obj => { if (obj.isLeaf) { return null; } @@ -74,24 +84,28 @@ const PeopleTreeMenu = props => { } }; - return ( - - {getItems(data)} - - ); -}; + render() { + const { data, selectedKeys } = this.props; -const ArticleBodyContent = props => ; + console.log("PeopleTreeMenu", this.props); + + return ( + + {getItems(data)} + + ); + }; +}; const getTreeGroups = (groups) => { const treeData = [ @@ -113,7 +127,7 @@ const getTreeGroups = (groups) => { function mapStateToProps(state) { return { data: getTreeGroups(state.people.groups), - defaultSelectedKeys: state.people.selectedGroup ? [state.people.selectedGroup] : ["root"] + selectedKeys: state.people.selectedGroup ? [state.people.selectedGroup] : ["root"] }; } diff --git a/products/ASC.People/Client/src/store/people/actions.js b/products/ASC.People/Client/src/store/people/actions.js index d0ed18a329..1e6f1c3137 100644 --- a/products/ASC.People/Client/src/store/people/actions.js +++ b/products/ASC.People/Client/src/store/people/actions.js @@ -54,12 +54,7 @@ export function selectGroup(groupId) { let newFilter = filter.clone(); newFilter.group = groupId; - fetchPeopleAsync(dispatch, newFilter); - - return dispatch({ - type: SELECT_GROUP, - groupId - }); + return fetchPeopleByFilter(dispatch, newFilter); }; } @@ -86,12 +81,7 @@ export function setFilter(filter) { export function fetchPeople(filter) { return dispatch => { - let filterData = (filter && filter.clone()) || Filter.getDefault(); - return api.getUserList(filterData).then(res => { - filterData.total = res.data.total; - dispatch(setFilter(filterData)); - return dispatch(setUsers(res.data.response)); - }); + return fetchPeopleByFilter(dispatch, filter); }; } @@ -100,6 +90,10 @@ export function fetchPeopleByFilter(dispatch, filter) { return api.getUserList(filterData).then(res => { filterData.total = res.data.total; dispatch(setFilter(filterData)); + dispatch({ + type: SELECT_GROUP, + groupId: filterData.group + }); return dispatch(setUsers(res.data.response)); }); } @@ -112,6 +106,10 @@ export async function fetchPeopleAsync(dispatch, filter = null) { filterData.total = usersResp.data.total; dispatch(setFilter(filterData)); + dispatch({ + type: SELECT_GROUP, + groupId: filterData.group + }); dispatch(setUsers(usersResp.data.response)); } diff --git a/web/ASC.Web.Components/src/index.js b/web/ASC.Web.Components/src/index.js index 258489e360..1b8fce9f10 100644 --- a/web/ASC.Web.Components/src/index.js +++ b/web/ASC.Web.Components/src/index.js @@ -53,4 +53,5 @@ export { default as NewCalendar } from './components/calendar-new' export { default as AdvancedSelector } from './components/advanced-selector' export { default as ContextMenu } from './components/context-menu' export { default as RowContainer } from './components/row-container' -export { default as FieldContainer } from './components/field-container' \ No newline at end of file +export { default as FieldContainer } from './components/field-container' +export { default as utils } from './utils' \ No newline at end of file diff --git a/web/ASC.Web.Components/src/utils/index.js b/web/ASC.Web.Components/src/utils/index.js new file mode 100644 index 0000000000..4c9c513ad8 --- /dev/null +++ b/web/ASC.Web.Components/src/utils/index.js @@ -0,0 +1,4 @@ +import * as array from './array'; +import * as event from './event'; + +export default { array, event }; \ No newline at end of file From 9a5b0bcc4b0aa4f160fc9cd1fadc1e53a8b98bd5 Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Fri, 30 Aug 2019 11:36:41 +0300 Subject: [PATCH 3/3] web: components: bump version --- web/ASC.Web.Components/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ASC.Web.Components/package.json b/web/ASC.Web.Components/package.json index 70adcdb4f0..f58bfd982e 100644 --- a/web/ASC.Web.Components/package.json +++ b/web/ASC.Web.Components/package.json @@ -1,6 +1,6 @@ { "name": "asc-web-components", - "version": "1.0.21", + "version": "1.0.22", "description": "Ascensio System SIA component library", "license": "AGPL-3.0", "main": "dist/asc-web-components.cjs.js",