From 23ae30ce13dce940a2a85cee430cbf7ec69f4910 Mon Sep 17 00:00:00 2001 From: Ilya Oleshko Date: Thu, 31 Oct 2019 13:24:21 +0300 Subject: [PATCH] web: People: Fixed display of parameters of contextual options depending on user status --- .../pages/Profile/Section/Header/index.js | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/products/ASC.People/Client/src/components/pages/Profile/Section/Header/index.js b/products/ASC.People/Client/src/components/pages/Profile/Section/Header/index.js index c0b42f5e1d..450cdda910 100644 --- a/products/ASC.People/Client/src/components/pages/Profile/Section/Header/index.js +++ b/products/ASC.People/Client/src/components/pages/Profile/Section/Header/index.js @@ -254,7 +254,6 @@ const SectionHeaderContent = props => { .catch(error => toastr.error(error)); }; const getUserContextOptions = (user, viewer, t) => { - let status = ""; if (isAdmin || (!isAdmin && isMe(user, viewer.userName))) { @@ -285,11 +284,19 @@ const SectionHeaderContent = props => { label: t('EditPhoto'), onClick: onEditPhoto }, - { - key: "disable", - label: t('DisableUserButton'), - onClick: onDisableClick - } + isMe(user, viewer.userName) + ? viewer.isOwner + ? {} + : { + key: "delete-profile", + label: t("DeleteSelfProfile"), + onClick: onDeleteProfileClick + } + : { + key: "disable", + label: t("DisableUserButton"), + onClick: onDisableClick + } ]; case "disabled": return [ @@ -336,15 +343,28 @@ const SectionHeaderContent = props => { label: t('EditPhoto'), onClick: onEditPhoto }, - { - key: "disable", - label: t('DisableUserButton'), - onClick: onDisableClick + !isMe(user, viewer.userName) && + (user.status === EmployeeStatus.Active + ? { + key: "disable", + label: t("DisableUserButton"), + onClick: onDisableClick + } + : { + key: "enable", + label: t("EnableUserButton"), + onClick: onEnableClick + }), + isMe(user, viewer.userName) && { + key: "delete-profile", + label: t("DeleteSelfProfile"), + onClick: onDeleteProfileClick } ]; default: return []; } + }; const { t } = useTranslation();