Merge branch 'master' of https://github.com/ONLYOFFICE/CommunityServer-AspNetCore
This commit is contained in:
commit
c4e7a1266b
@ -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<string, string> properties)
|
||||
|
@ -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 ? (
|
||||
<ContentRow
|
||||
key={user.id}
|
||||
status={item.status}
|
||||
status={getUserStatus(user)}
|
||||
data={user}
|
||||
avatarRole={item.role}
|
||||
avatarRole={getUserRole(user)}
|
||||
avatarSource={user.avatar}
|
||||
avatarName={user.userName}
|
||||
contextOptions={item.contextOptions}
|
||||
contextOptions={contextOptions}
|
||||
checked={isSelected(selection, user.id)}
|
||||
onSelect={(checked, data) => {
|
||||
console.log("ContentRow onSelect", checked, data);
|
||||
if (checked) {
|
||||
selectUser(user);
|
||||
}
|
||||
else {
|
||||
deselectUser(user);
|
||||
}
|
||||
}}
|
||||
onSelect={this.onContentRowSelect.bind(this, user)}
|
||||
>
|
||||
<UserContent
|
||||
userName={item.user.userName}
|
||||
displayName={item.user.displayName}
|
||||
department={item.department}
|
||||
phone={item.phone}
|
||||
email={item.email}
|
||||
headDepartment={item.isHead}
|
||||
status={item.status}
|
||||
user={user}
|
||||
history={history}
|
||||
settings={settings}
|
||||
/>
|
||||
</ContentRow>
|
||||
) : (
|
||||
<ContentRow
|
||||
key={item.user.id}
|
||||
status={item.status}
|
||||
avatarRole={item.role}
|
||||
avatarSource={item.user.avatar}
|
||||
avatarName={item.user.userName}
|
||||
key={user.id}
|
||||
status={getUserStatus(user)}
|
||||
avatarRole={getUserRole(user)}
|
||||
avatarSource={user.avatar}
|
||||
avatarName={user.userName}
|
||||
>
|
||||
<UserContent
|
||||
userName={item.user.userName}
|
||||
department={item.department}
|
||||
phone={item.phone}
|
||||
email={item.email}
|
||||
headDepartment={item.isHead}
|
||||
status={item.user.status}
|
||||
user={user}
|
||||
history={history}
|
||||
settings={settings}
|
||||
/>
|
||||
</ContentRow>
|
||||
);
|
||||
|
@ -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
|
||||
}) => (
|
||||
<Container fluid={true}>
|
||||
<Row className="justify-content-start no-gutters">
|
||||
<Col className="col-12 col-sm-12 col-lg-4 text-truncate">
|
||||
<Link
|
||||
style={
|
||||
status === "pending" ? { color: "#A3A9AE" } : { color: "#333333" }
|
||||
}
|
||||
type="action"
|
||||
title={displayName}
|
||||
isBold={true}
|
||||
fontSize={15}
|
||||
onClick={() => {
|
||||
console.log("User name action");
|
||||
history.push(`${settings.homepage}/view/${userName}`);
|
||||
}}
|
||||
>
|
||||
{displayName}
|
||||
</Link>
|
||||
{status === "pending" && <Icons.SendClockIcon style={{marginLeft: "8px", marginTop: "-4px"}} size='small' isfill color='#3B72A7' />}
|
||||
{status === "disabled" && <Icons.CatalogSpamIcon style={{marginLeft: "8px", marginTop: "-4px"}} size='small' isfill color='#3B72A7' />}
|
||||
</Col>
|
||||
<Col
|
||||
className={`${
|
||||
headDepartment ? "col-3" : "col-auto"
|
||||
} col-sm-auto col-lg-2 text-truncate`}
|
||||
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 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 (
|
||||
<Container fluid={true}>
|
||||
<Row className="justify-content-start no-gutters">
|
||||
<Col className="col-12 col-sm-12 col-lg-4 text-truncate">
|
||||
<Link
|
||||
isSemitransparent={status === "pending"}
|
||||
type="action"
|
||||
title={displayName}
|
||||
isBold={true}
|
||||
fontSize={15}
|
||||
onClick={onUserNameClick}
|
||||
>
|
||||
<Link
|
||||
style={
|
||||
status === "pending" ? { color: "#D0D5DA" } : { color: "#A3A9AE" }
|
||||
}
|
||||
type="action"
|
||||
isHovered
|
||||
title={headDepartment ? "Head of department" : ""}
|
||||
onClick={() => console.log("Head of department action")}
|
||||
>
|
||||
{headDepartment ? "Head of department" : ""}
|
||||
</Link>
|
||||
</Col>
|
||||
<Col className={`col-3 col-sm-auto col-lg-2 text-truncate`}>
|
||||
{headDepartment && (
|
||||
<span className="d-lg-none" style={{ margin: "0 4px" }}>
|
||||
{department.title ? "|" : ""}
|
||||
</span>
|
||||
)}
|
||||
<Link
|
||||
style={
|
||||
status === "pending" ? { color: "#D0D5DA" } : { color: "#A3A9AE" }
|
||||
}
|
||||
type="action"
|
||||
isHovered
|
||||
title={department.title}
|
||||
onClick={department.action}
|
||||
>
|
||||
{department.title}
|
||||
</Link>
|
||||
</Col>
|
||||
<Col className={`col-3 col-sm-auto col-lg-2 text-truncate`}>
|
||||
{department.title && (
|
||||
<span className="d-lg-none" style={{ margin: "0 4px" }}>
|
||||
{phone.title ? "|" : ""}
|
||||
</span>
|
||||
)}
|
||||
<Link
|
||||
style={
|
||||
status === "pending" ? { color: "#D0D5DA" } : { color: "#A3A9AE" }
|
||||
}
|
||||
type="action"
|
||||
title={phone.title}
|
||||
onClick={phone.action}
|
||||
>
|
||||
{phone.title}
|
||||
</Link>
|
||||
</Col>
|
||||
<Col className={`col-3 col-sm-auto col-lg-2 text-truncate`}>
|
||||
{phone.title && (
|
||||
<span className="d-lg-none" style={{ margin: "0 4px" }}>
|
||||
{email.title ? "|" : ""}
|
||||
</span>
|
||||
)}
|
||||
<Link
|
||||
style={
|
||||
status === "pending" ? { color: "#D0D5DA" } : { color: "#A3A9AE" }
|
||||
}
|
||||
type="action"
|
||||
isHovered
|
||||
title={email.title}
|
||||
onClick={email.action}
|
||||
>
|
||||
{email.title}
|
||||
</Link>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
);
|
||||
{displayName}
|
||||
</Link>
|
||||
{status === "pending" && (
|
||||
<Icons.SendClockIcon
|
||||
style={{ marginLeft: "8px", marginTop: "-4px" }}
|
||||
size="small"
|
||||
isfill
|
||||
color="#3B72A7"
|
||||
/>
|
||||
)}
|
||||
{status === "disabled" && (
|
||||
<Icons.CatalogSpamIcon
|
||||
style={{ marginLeft: "8px", marginTop: "-4px" }}
|
||||
size="small"
|
||||
isfill
|
||||
color="#3B72A7"
|
||||
/>
|
||||
)}
|
||||
</Col>
|
||||
<Col
|
||||
className={`${
|
||||
headDepartment ? "col-3" : "col-auto"
|
||||
} col-sm-auto col-lg-2 text-truncate`}
|
||||
>
|
||||
<Link
|
||||
isSemitransparent={status === "pending"}
|
||||
type="action"
|
||||
isHovered
|
||||
title={headDepartment ? "Head of department" : ""}
|
||||
onClick={onHeadDepartmentClick}
|
||||
>
|
||||
{headDepartment ? "Head of department" : ""}
|
||||
</Link>
|
||||
</Col>
|
||||
<Col className={`col-3 col-sm-auto col-lg-2 text-truncate`}>
|
||||
{headDepartment && (
|
||||
<span className="d-lg-none" style={{ margin: "0 4px" }}>
|
||||
{department ? "|" : ""}
|
||||
</span>
|
||||
)}
|
||||
<Link
|
||||
isSemitransparent={status === "pending"}
|
||||
type="action"
|
||||
isHovered
|
||||
title={department}
|
||||
onClick={onDepartmentClick}
|
||||
>
|
||||
{department}
|
||||
</Link>
|
||||
</Col>
|
||||
<Col className={`col-3 col-sm-auto col-lg-2 text-truncate`}>
|
||||
{department && (
|
||||
<span className="d-lg-none" style={{ margin: "0 4px" }}>
|
||||
{mobilePhone ? "|" : ""}
|
||||
</span>
|
||||
)}
|
||||
<Link
|
||||
isSemitransparent={status === "pending"}
|
||||
type="action"
|
||||
title={mobilePhone}
|
||||
onClick={onPhoneClick}
|
||||
>
|
||||
{mobilePhone}
|
||||
</Link>
|
||||
</Col>
|
||||
<Col className={`col-3 col-sm-auto col-lg-2 text-truncate`}>
|
||||
{mobilePhone && (
|
||||
<span className="d-lg-none" style={{ margin: "0 4px" }}>
|
||||
{email ? "|" : ""}
|
||||
</span>
|
||||
)}
|
||||
<Link
|
||||
isSemitransparent={status === "pending"}
|
||||
type="action"
|
||||
isHovered
|
||||
title={email}
|
||||
onClick={onEmailClick}
|
||||
>
|
||||
{email}
|
||||
</Link>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
settings: state.settings
|
||||
};
|
||||
}
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
settings: state.settings
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(withRouter(UserContent));
|
@ -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 ? (
|
||||
<div style={{ margin: "0 -16px" }}>
|
||||
<GroupButtonsMenu
|
||||
checked={isHeaderChecked}
|
||||
isIndeterminate={isHeaderIndeterminate}
|
||||
onChange={onCheck}
|
||||
menuItems={getPeopleItems(onSelect)}
|
||||
menuItems={menuItems}
|
||||
visible={isHeaderVisible}
|
||||
moreLabel="More"
|
||||
closeTitle="Close"
|
||||
@ -69,6 +72,8 @@ const SectionHeaderContent = ({
|
||||
</div>
|
||||
) : (
|
||||
<Text.ContentHeader>People</Text.ContentHeader>
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
export default SectionHeaderContent;
|
@ -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}
|
||||
/>
|
||||
</NPL.SectionHeader>
|
||||
<NPL.SectionFilter>
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
}
|
||||
}
|
||||
}
|
||||
`}
|
||||
|
Loading…
Reference in New Issue
Block a user