From 630ebe3f2a46f6625a9b64126a9ef59c892e5239 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 25 May 2023 23:07:19 -0400 Subject: [PATCH] fix: added permission check for count visibility --- src/components/Layout/MobileMenu/index.tsx | 58 ++++++++++++---------- src/components/Layout/Sidebar/index.tsx | 6 ++- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/components/Layout/MobileMenu/index.tsx b/src/components/Layout/MobileMenu/index.tsx index 6e6dbee6a..c8b1f30bd 100644 --- a/src/components/Layout/MobileMenu/index.tsx +++ b/src/components/Layout/MobileMenu/index.tsx @@ -169,22 +169,28 @@ const MobileMenu = ({ className: 'h-5 w-5', })} {link.content} - {link.href === '/requests' && pendingRequestsCount && ( -
- - {pendingRequestsCount < 100 - ? pendingRequestsCount - : '99+'} - -
- )} - {link.href === '/issues' && openIssuesCount && ( -
- - {openIssuesCount < 100 ? openIssuesCount : '99+'} - -
- )} + {link.href === '/requests' && + pendingRequestsCount && + pendingRequestsCount > 0 && + hasPermission(Permission.MANAGE_REQUESTS) && ( +
+ + {pendingRequestsCount < 100 + ? pendingRequestsCount + : '99+'} + +
+ )} + {link.href === '/issues' && + openIssuesCount && + openIssuesCount && + hasPermission(Permission.MANAGE_ISSUES) && ( +
+ + {openIssuesCount < 100 ? openIssuesCount : '99+'} + +
+ )} ); @@ -210,15 +216,17 @@ const MobileMenu = ({ className: 'h-6 w-6', } )} - {link.href === '/requests' && pendingRequestsCount && ( -
- - {pendingRequestsCount < 100 - ? pendingRequestsCount - : '99+'} - -
- )} + {link.href === '/requests' && + pendingRequestsCount && + hasPermission(Permission.MANAGE_REQUESTS) && ( +
+ + {pendingRequestsCount < 100 + ? pendingRequestsCount + : '99+'} + +
+ )} ); diff --git a/src/components/Layout/Sidebar/index.tsx b/src/components/Layout/Sidebar/index.tsx index 63596a78c..ce85f69ad 100644 --- a/src/components/Layout/Sidebar/index.tsx +++ b/src/components/Layout/Sidebar/index.tsx @@ -264,7 +264,8 @@ const Sidebar = ({ )} {sidebarLink.messagesKey === 'requests' && pendingRequestsCount && - pendingRequestsCount > 0 && ( + pendingRequestsCount > 0 && + hasPermission(Permission.MANAGE_REQUESTS) && (
{pendingRequestsCount < 100 @@ -275,7 +276,8 @@ const Sidebar = ({ )} {sidebarLink.messagesKey === 'issues' && openIssuesCount && - openIssuesCount > 0 && ( + openIssuesCount > 0 && + hasPermission(Permission.MANAGE_ISSUES) && (
{openIssuesCount < 100