diff --git a/common/ASC.Core.Common/Notify/Senders/NotifyServiceSender.cs b/common/ASC.Core.Common/Notify/Senders/NotifyServiceSender.cs index 9df6c95187..68f97deb37 100644 --- a/common/ASC.Core.Common/Notify/Senders/NotifyServiceSender.cs +++ b/common/ASC.Core.Common/Notify/Senders/NotifyServiceSender.cs @@ -32,9 +32,9 @@ namespace ASC.Core.Notify.Senders public class NotifyServiceSender : INotifySender { public NotifyServiceClient NotifyServiceClient { get; } - public NotifyServiceSender(NotifyServiceClient notifyServiceClient) + public NotifyServiceSender() { - NotifyServiceClient = notifyServiceClient; + NotifyServiceClient = new NotifyServiceClient(); } public void Init(IDictionary properties) diff --git a/products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js b/products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js index 6c16981e11..2abcd1952f 100644 --- a/products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js +++ b/products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js @@ -5,63 +5,95 @@ import { ContentRow } from "asc-web-components"; import UserContent from "./userContent"; //import config from "../../../../../../package.json"; import { selectUser, deselectUser, setSelection } from "../../../../../store/people/actions"; -import { isSelected, convertPeople } from '../../../../../store/people/selectors'; +import { isSelected, getUserStatus, getUserRole } from '../../../../../store/people/selectors'; import { isAdmin } from '../../../../../store/auth/selectors'; class SectionBodyContent extends React.PureComponent { + + getUserContextOptions = (user, isAdmin, history, settings) => { + return [ + { + key: "key1", + label: "Send e-mail", + onClick: () => console.log("Context action: Send e-mail") + }, + { + key: "key2", + label: "Send message", + onClick: () => console.log("Context action: Send message") + }, + { key: "key3", isSeparator: true }, + { + key: "key4", + label: "Edit", + onClick: () => history.push(`${settings.homepage}/edit/${user.userName}`) + }, + { + key: "key5", + label: "Change password", + onClick: () => console.log("Context action: Change password") + }, + { + key: "key6", + label: "Change e-mail", + onClick: () => console.log("Context action: Change e-mail") + }, + { + key: "key7", + label: "Disable", + onClick: () => console.log("Context action: Disable") + } + ]; + }; + + onContentRowSelect = (checked, data, user) => { + console.log("ContentRow onSelect", checked, data); + if (checked) { + this.props.selectUser(user); + } + else { + this.props.deselectUser(user); + } + } + render() { console.log("Home SectionBodyContent render()"); - const { users, isAdmin, selection, selectUser, deselectUser, history, settings} = this.props; + const { users, isAdmin, selection, history, settings} = this.props; return ( <> - {convertPeople(users, isAdmin, history, settings).map(item => { - const user = item.user; + {users.map(user => { + const contextOptions = this.getUserContextOptions(user, isAdmin, history, settings); return isAdmin ? ( { - console.log("ContentRow onSelect", checked, data); - if (checked) { - selectUser(user); - } - else { - deselectUser(user); - } - }} + onSelect={this.onContentRowSelect.bind(this, user)} > ) : ( ); diff --git a/products/ASC.People/Client/src/components/pages/Home/Section/Body/userContent.js b/products/ASC.People/Client/src/components/pages/Home/Section/Body/userContent.js index eb57b9e41b..9c0fd942f9 100644 --- a/products/ASC.People/Client/src/components/pages/Home/Section/Body/userContent.js +++ b/products/ASC.People/Client/src/components/pages/Home/Section/Body/userContent.js @@ -1,119 +1,166 @@ -import React from 'react'; +import React, { useCallback } from "react"; import { withRouter } from "react-router"; import { Container, Row, Col } from "reactstrap"; -import { Link, Icons} from 'asc-web-components'; -import { connect } from 'react-redux'; +import { Link, Icons } from "asc-web-components"; +import { connect } from "react-redux"; +import { getUserStatus } from "../../../../../store/people/selectors"; -const UserContent = ({ - userName, - displayName, - department, - phone, - email, - headDepartment, - status, - history, - settings -}) => ( - - - - { - console.log("User name action"); - history.push(`${settings.homepage}/view/${userName}`); - }} - > - {displayName} - - {status === "pending" && } - {status === "disabled" && } - - { + return { + title: user.department, + action: () => console.log("Department action") + }; +}; + +const getUserPhone = user => { + return { + title: user.mobilePhone, + action: () => console.log("Phone action") + }; +}; + +const getUserEmail = user => { + return { + title: user.email, + action: () => console.log("Email action") + }; +}; + +const getIsHead = user => { + return false; +}; + +const UserContent = ({user, history,settings }) => { + const { userName, displayName, headDepartment, department, mobilePhone, email } = user; + const status = getUserStatus(user); + + const onUserNameClick = useCallback(() => { + console.log("User name action"); + history.push(`${settings.homepage}/view/${userName}`); + }, [history, settings.homepage, userName]); + + const onHeadDepartmentClick = useCallback( + () => console.log("Head of department action"), + [] + ); + + const onDepartmentClick = useCallback( + () => console.log("Department action"), + [] + ); + + const onPhoneClick = useCallback( + () => console.log("Phone action"), + [] + ); + + const onEmailClick = useCallback( + () => console.log("Email action"), + [] + ); + + return ( + + + + - console.log("Head of department action")} - > - {headDepartment ? "Head of department" : ""} - - - - {headDepartment && ( - - {department.title ? "|" : ""} - - )} - - {department.title} - - - - {department.title && ( - - {phone.title ? "|" : ""} - - )} - - {phone.title} - - - - {phone.title && ( - - {email.title ? "|" : ""} - - )} - - {email.title} - - - - - ); + {displayName} + + {status === "pending" && ( + + )} + {status === "disabled" && ( + + )} + + + + {headDepartment ? "Head of department" : ""} + + + + {headDepartment && ( + + {department ? "|" : ""} + + )} + + {department} + + + + {department && ( + + {mobilePhone ? "|" : ""} + + )} + + {mobilePhone} + + + + {mobilePhone && ( + + {email ? "|" : ""} + + )} + + {email} + + + + + ); +}; - function mapStateToProps(state) { - return { - settings: state.settings - }; - } +function mapStateToProps(state) { + return { + settings: state.settings + }; +} -export default connect(mapStateToProps)(withRouter(UserContent)); \ No newline at end of file +export default connect(mapStateToProps)(withRouter(UserContent)); diff --git a/products/ASC.People/Client/src/components/pages/Home/Section/Header/index.js b/products/ASC.People/Client/src/components/pages/Home/Section/Header/index.js index c0d55f50c6..55dca82eae 100644 --- a/products/ASC.People/Client/src/components/pages/Home/Section/Header/index.js +++ b/products/ASC.People/Client/src/components/pages/Home/Section/Header/index.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { GroupButtonsMenu, DropDownItem, Text } from 'asc-web-components'; const getPeopleItems = (onSelect) => [ @@ -45,21 +45,24 @@ const getPeopleItems = (onSelect) => [ } ]; -const SectionHeaderContent = ({ +const SectionHeaderContent = React.memo(({ isHeaderVisible, isHeaderIndeterminate, isHeaderChecked, onCheck, onSelect, onClose - }) => + }) => { + console.log("SectionHeaderContent render"); + const menuItems = getPeopleItems(onSelect); + return ( isHeaderVisible ? (
) : ( People + ) ); + }); export default SectionHeaderContent; \ No newline at end of file diff --git a/products/ASC.People/Client/src/components/pages/Home/index.js b/products/ASC.People/Client/src/components/pages/Home/index.js index 1b151a044f..465a3f9bb1 100644 --- a/products/ASC.People/Client/src/components/pages/Home/index.js +++ b/products/ASC.People/Client/src/components/pages/Home/index.js @@ -99,8 +99,27 @@ class Home extends React.Component { }); }; - render() { + onSectionHeaderContentCheck = (checked) => { + this.props.setSelected(checked ? "all" : "none"); + } + + onSectionHeaderContentSelect = (selected) => { + this.props.setSelected(selected); + } + + onClose = () => { const { selection, setSelected } = this.props; + + if (!selection.length) { + setSelected("none"); + this.setState({ isHeaderVisible: false }); + } else { + setSelected("close"); + } + } + + render() { + const { isHeaderVisible, isHeaderIndeterminate, @@ -137,25 +156,9 @@ class Home extends React.Component { isHeaderVisible={isHeaderVisible} isHeaderIndeterminate={isHeaderIndeterminate} isHeaderChecked={isHeaderChecked} - onCheck={checked => { - /*console.log(`SectionHeaderContent onCheck - selection.length=${selection.length}`);*/ - setSelected(checked ? "all" : "none"); - }} - onSelect={selected => { - /*console.log(`SectionHeaderContent onSelect - selected=${selected}`);*/ - setSelected(selected); - }} - onClose={() => { - /*console.log('SectionHeaderContent onClose');*/ - if (!selection.length) { - setSelected("none"); - this.setState({ isHeaderVisible: false }); - } else { - setSelected("close"); - } - }} + onCheck={this.onSectionHeaderContentCheck} + onSelect={this.onSectionHeaderContentSelect} + onClose={this.onClose} /> diff --git a/products/ASC.People/Client/src/store/people/selectors.js b/products/ASC.People/Client/src/store/people/selectors.js index b160d291d3..dee7a5348d 100644 --- a/products/ASC.People/Client/src/store/people/selectors.js +++ b/products/ASC.People/Client/src/store/people/selectors.js @@ -39,101 +39,19 @@ export function getTreeGroups(groups) { return treeData; }; -const getUserDepartment = user => { - return { - title: user.department, - action: () => console.log("Department action") - }; -}; - -const getUserPhone = user => { - return { - title: user.mobilePhone, - action: () => console.log("Phone action") - }; -}; - -const getUserEmail = user => { - return { - title: user.email, - action: () => console.log("Email action") - }; -}; - -const getUserRole = user => { - if (user.isOwner) return "owner"; - else if (user.isAdmin) return "admin"; - else if (user.isVisitor) return "guest"; - else return "user"; -}; - -const getUserStatus = user => { +export const getUserStatus = user => { if (user.status === 1 && user.activationStatus === 1) return "normal"; else if (user.status === 1 && user.activationStatus === 2) return "pending"; else if (user.status === 2) return "disabled"; else return "normal"; -}; + }; -const getUserContextOptions = (user, isAdmin, history, settings) => { - return [ - { - key: "key1", - label: "Send e-mail", - onClick: () => console.log("Context action: Send e-mail") - }, - { - key: "key2", - label: "Send message", - onClick: () => console.log("Context action: Send message") - }, - { key: "key3", isSeparator: true }, - { - key: "key4", - label: "Edit", - onClick: () => history.push(`${settings.homepage}/edit/${user.userName}`) - }, - { - key: "key5", - label: "Change password", - onClick: () => console.log("Context action: Change password") - }, - { - key: "key6", - label: "Change e-mail", - onClick: () => console.log("Context action: Change e-mail") - }, - { - key: "key7", - label: "Disable", - onClick: () => console.log("Context action: Disable") - } - ]; -}; - -const getIsHead = user => { - return false; -}; - -export function convertPeople(users, isAdmin, history, settings) { - return users.map(user => { - const status = getUserStatus(user); - return { - user: user, - status: status, - role: getUserRole(user), - contextOptions: getUserContextOptions( - user, - isAdmin, - history, - settings - ), - department: getUserDepartment(user), - phone: getUserPhone(user), - email: getUserEmail(user), - isHead: getIsHead(user) - }; - }); -}; + export const getUserRole = user => { + if (user.isOwner) return "owner"; + else if (user.isAdmin) return "admin"; + else if (user.isVisitor) return "guest"; + else return "user"; + }; const getChecked = (status, selected) => { let checked; diff --git a/web/ASC.Web.Components/src/components/checkbox/index.js b/web/ASC.Web.Components/src/components/checkbox/index.js index b5bd6b2d33..9ec62ebec9 100644 --- a/web/ASC.Web.Components/src/components/checkbox/index.js +++ b/web/ASC.Web.Components/src/components/checkbox/index.js @@ -7,18 +7,6 @@ import { Text } from "../text"; const disableColor = "#A3A9AE"; const hoverColor = disableColor; -const IndeterminateHoverCss = css` - rect:first-child { - stroke: ${hoverColor}; - } -`; - -const HoverCss = css` - rect:first-child { - stroke: ${hoverColor}; - } -`; - const Label = styled.label` display: flex; align-items: center; @@ -43,7 +31,9 @@ const Label = styled.label` &:hover { svg { - ${props => props.isIndeterminate ? IndeterminateHoverCss : HoverCss} + rect:first-child { + stroke: ${hoverColor}; + } } } `}