web: people: isMe refactoring

This commit is contained in:
Vladislav Makhov 2021-03-03 12:33:17 +03:00
parent b8702eb270
commit d2dd11ef91

View File

@ -7,7 +7,6 @@ import toastr from "@appserver/common/components/Toast";
import { withRouter } from "react-router";
import { withTranslation, Trans } from "react-i18next";
import styled from "styled-components";
import { isMe } from "@appserver/common/utils";
import {
resendUserInvites,
createThumbnailsAvatar,
@ -287,9 +286,9 @@ class SectionHeaderContent extends React.PureComponent {
getUserContextOptions = (user, viewer) => {
let status = "";
const { t, isAdmin } = this.props;
const { t, isAdmin, isMe } = this.props;
if (isAdmin || (!isAdmin && isMe(user, viewer.userName))) {
if (isAdmin || (!isAdmin && isMe)) {
status = getUserStatus(user);
}
@ -312,7 +311,7 @@ class SectionHeaderContent extends React.PureComponent {
label: t("EmailChangeButton"),
onClick: this.toggleChangeEmailDialog,
},
isMe(user, viewer.userName)
isMe
? viewer.isOwner
? {}
: {
@ -361,7 +360,7 @@ class SectionHeaderContent extends React.PureComponent {
label: t("InviteAgainLbl"),
onClick: this.onInviteAgainClick,
},
!isMe(user, viewer.userName) &&
!isMe &&
(user.status === EmployeeStatus.Active
? {
key: "disable",
@ -373,7 +372,7 @@ class SectionHeaderContent extends React.PureComponent {
label: t("EnableUserButton"),
onClick: this.onEnableClick,
}),
isMe(user, viewer.userName) && {
isMe && {
key: "delete-profile",
label: t("DeleteSelfProfile"),
onClick: this.toggleDeleteSelfProfileDialog,
@ -399,14 +398,14 @@ class SectionHeaderContent extends React.PureComponent {
filter,
settings,
history,
IsMe,
isMe,
} = this.props;
const { avatar, visibleAvatarEditor, dialogsVisible } = this.state;
const contextOptions = () => this.getUserContextOptions(profile, viewer);
return (
<StyledContainer
showContextButton={(isAdmin && !profile.isOwner) || IsMe}
showContextButton={(isAdmin && !profile.isOwner) || isMe}
>
<IconButton
iconName="/static/images/arrow.path.react.svg"
@ -421,7 +420,7 @@ class SectionHeaderContent extends React.PureComponent {
{profile.displayName}
{profile.isLDAP && ` (${t("LDAPLbl")})`}
</Headline>
{((isAdmin && !profile.isOwner) || IsMe) && (
{((isAdmin && !profile.isOwner) || isMe) && (
<ContextMenuButton
className="action-button"
directionX="right"
@ -501,7 +500,7 @@ export default inject(({ auth, peopleStore }) => {
resetProfile: peopleStore.targetUserStore.resetTargetUser,
fetchProfile: peopleStore.targetUserStore.getTargetUser,
profile: peopleStore.targetUserStore.targetUser,
IsMe: peopleStore.targetUserStore.isMe,
isMe: peopleStore.targetUserStore.isMe,
updateProfile: peopleStore.targetUserStore.updateProfile,
getUserPhoto: peopleStore.targetUserStore.getUserPhoto,
};