Skip to content

Commit ee13050

Browse files
committed
header view for others fix
1 parent 4fc6a2f commit ee13050

1 file changed

Lines changed: 66 additions & 57 deletions

File tree

src/components/Header/Header.jsx

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -82,65 +82,67 @@ export function Header(props) {
8282
[ALLOWED_ROLES_TO_INTERACT, props.auth.user.role],
8383
);
8484

85+
const headerDisabled = isAuthUser ? false : !canInteractWithViewingUser;
8586
// Reports
8687
const canGetReports = props.hasPermission(
8788
'getReports',
88-
!isAuthUser && canInteractWithViewingUser,
89+
!isAuthUser,
8990
);
9091
const canGetWeeklySummaries = props.hasPermission(
9192
'getWeeklySummaries',
92-
!isAuthUser && canInteractWithViewingUser,
93+
!isAuthUser,
9394
);
94-
const canGetWeeklyVolunteerSummary = props.hasPermission('getWeeklySummaries');
9595

96+
97+
const canGetWeeklyVolunteerSummary = props.hasPermission('getWeeklySummaries',!isAuthUser);
9698
// Users
9799
const canAccessUserManagement =
98-
props.hasPermission('postUserProfile', !isAuthUser && canInteractWithViewingUser) ||
99-
props.hasPermission('deleteUserProfile', !isAuthUser && canInteractWithViewingUser) ||
100-
props.hasPermission('changeUserStatus', !isAuthUser && canInteractWithViewingUser) ||
101-
props.hasPermission('getUserProfiles', !isAuthUser && canInteractWithViewingUser);
100+
props.hasPermission('postUserProfile', !isAuthUser ) ||
101+
props.hasPermission('deleteUserProfile', !isAuthUser ) ||
102+
props.hasPermission('changeUserStatus', !isAuthUser ) ||
103+
props.hasPermission('getUserProfiles', !isAuthUser );
102104

103105
// Badges
104106
const canAccessBadgeManagement =
105-
props.hasPermission('seeBadges', !isAuthUser && canInteractWithViewingUser) ||
106-
props.hasPermission('createBadges', !isAuthUser && canInteractWithViewingUser) ||
107-
props.hasPermission('updateBadges', !isAuthUser && canInteractWithViewingUser) ||
108-
props.hasPermission('deleteBadges', !isAuthUser && canInteractWithViewingUser);
107+
props.hasPermission('seeBadges', !isAuthUser ) ||
108+
props.hasPermission('createBadges', !isAuthUser ) ||
109+
props.hasPermission('updateBadges', !isAuthUser ) ||
110+
props.hasPermission('deleteBadges', !isAuthUser );
109111
// Projects
110112
const canAccessProjects =
111-
props.hasPermission('postProject', !isAuthUser && canInteractWithViewingUser) ||
112-
props.hasPermission('deleteProject', !isAuthUser && canInteractWithViewingUser) ||
113-
props.hasPermission('putProject', !isAuthUser && canInteractWithViewingUser) ||
114-
props.hasPermission('getProjectMembers', !isAuthUser && canInteractWithViewingUser) ||
115-
props.hasPermission('assignProjectToUsers', !isAuthUser && canInteractWithViewingUser) ||
116-
props.hasPermission('postWbs', !isAuthUser && canInteractWithViewingUser) ||
117-
props.hasPermission('deleteWbs', !isAuthUser && canInteractWithViewingUser) ||
118-
props.hasPermission('postTask', !isAuthUser && canInteractWithViewingUser) ||
119-
props.hasPermission('updateTask', !isAuthUser && canInteractWithViewingUser) ||
120-
props.hasPermission('deleteTask', !isAuthUser && canInteractWithViewingUser);
113+
props.hasPermission('postProject', !isAuthUser ) ||
114+
props.hasPermission('deleteProject', !isAuthUser ) ||
115+
props.hasPermission('putProject', !isAuthUser ) ||
116+
props.hasPermission('getProjectMembers', !isAuthUser ) ||
117+
props.hasPermission('assignProjectToUsers', !isAuthUser ) ||
118+
props.hasPermission('postWbs', !isAuthUser) ||
119+
props.hasPermission('deleteWbs', !isAuthUser ) ||
120+
props.hasPermission('postTask', !isAuthUser ) ||
121+
props.hasPermission('updateTask', !isAuthUser ) ||
122+
props.hasPermission('deleteTask', !isAuthUser );
121123
// Tasks
122124
const canUpdateTask = props.hasPermission(
123125
'updateTask',
124-
!isAuthUser && canInteractWithViewingUser,
126+
!isAuthUser ,
125127
);
126128
// Teams
127129
const canAccessTeams =
128-
props.hasPermission('postTeam', !isAuthUser && canInteractWithViewingUser) ||
129-
props.hasPermission('putTeam', !isAuthUser && canInteractWithViewingUser) ||
130-
props.hasPermission('deleteTeam', !isAuthUser && canInteractWithViewingUser) ||
131-
props.hasPermission('assignTeamToUsers', !isAuthUser && canInteractWithViewingUser);
130+
props.hasPermission('postTeam', !isAuthUser ) ||
131+
props.hasPermission('putTeam', !isAuthUser ) ||
132+
props.hasPermission('deleteTeam', !isAuthUser ) ||
133+
props.hasPermission('assignTeamToUsers', !isAuthUser);
132134
// Popups
133135
const canAccessPopups =
134-
props.hasPermission('createPopup', !isAuthUser && canInteractWithViewingUser) ||
135-
props.hasPermission('updatePopup', !isAuthUser && canInteractWithViewingUser);
136+
props.hasPermission('createPopup', !isAuthUser ) ||
137+
props.hasPermission('updatePopup', !isAuthUser );
136138
// SendEmails
137139
const canAccessSendEmails = props.hasPermission('sendEmails', !isAuthUser);
138140
// Permissions
139141
const canAccessPermissionsManagement =
140-
props.hasPermission('postRole', !isAuthUser && canInteractWithViewingUser) ||
141-
props.hasPermission('putRole', !isAuthUser && canInteractWithViewingUser) ||
142-
props.hasPermission('deleteRole', !isAuthUser && canInteractWithViewingUser) ||
143-
props.hasPermission('putUserProfilePermissions', !isAuthUser && canInteractWithViewingUser);
142+
props.hasPermission('postRole', !isAuthUser) ||
143+
props.hasPermission('putRole', !isAuthUser ) ||
144+
props.hasPermission('deleteRole', !isAuthUser ) ||
145+
props.hasPermission('putUserProfilePermissions', !isAuthUser);
144146

145147
const userId = user.userid;
146148
const [isModalVisible, setModalVisible] = useState(false);
@@ -355,71 +357,74 @@ export function Header(props) {
355357
>
356358
{canUpdateTask && (
357359
<NavItem className="responsive-spacing">
358-
<NavLink tag={Link} to="/taskeditsuggestions">
360+
<NavLink tag={Link} to="/taskeditsuggestions" disabled={headerDisabled}>
359361
<div className="redBackGroupHeader">
360362
<span>{props.taskEditSuggestionCount}</span>
361363
</div>
362364
</NavLink>
363365
</NavItem>
364366
)}
365367
<NavItem className="responsive-spacing">
366-
<NavLink tag={Link} to="/dashboard">
368+
<NavLink tag={Link} to="/dashboard" disabled={headerDisabled}>
367369
<span className="dashboard-text-link">{DASHBOARD}</span>
368370
</NavLink>
369371
</NavItem>
370372
<NavItem className="responsive-spacing">
371-
<NavLink tag={Link} to="/timelog#currentWeek">
373+
<NavLink tag={Link} to="/timelog#currentWeek" disabled={headerDisabled}>
372374
<span className="dashboard-text-link">{TIMELOG}</span>
373375
</NavLink>
374376
</NavItem>
375377

376378
{showProjectDropdown && (
377379
<UncontrolledDropdown nav inNavbar className="responsive-spacing">
378-
<DropdownToggle nav caret>
380+
<DropdownToggle nav caret disabled={headerDisabled}>
379381
<span className="dashboard-text-link">{PROJECTS}</span>
380382
</DropdownToggle>
381-
<DropdownMenu className={darkMode ? 'bg-yinmn-blue' : ''}>
383+
<DropdownMenu className={darkMode ? 'bg-yinmn-blue' : ''} disabled={headerDisabled}>
382384
<DropdownItem
383385
tag={Link}
384386
to="/bmdashboard/materials/add"
385387
className={fontColor}
386388
>
387389
Add Material
388390
</DropdownItem>
389-
<DropdownItem tag={Link} to="/bmdashboard/logMaterial" className={fontColor}>
391+
<DropdownItem tag={Link} to="/bmdashboard/logMaterial" className={fontColor} disabled={headerDisabled}>
390392
Log Material
391393
</DropdownItem>
392-
<DropdownItem tag={Link} to="/bmdashboard/materials" className={fontColor}>
394+
<DropdownItem tag={Link} to="/bmdashboard/materials" className={fontColor} disabled={headerDisabled}>
393395
Material List
394396
</DropdownItem>
395397
<DropdownItem
396398
tag={Link}
397399
to="/bmdashboard/equipment/add"
398400
className={fontColor}
401+
disabled={headerDisabled}
399402
>
400403
Add Equipment/Tool
401404
</DropdownItem>
402405
<DropdownItem
403406
tag={Link}
404407
to="/bmdashboard/equipment/:equipmentId"
405408
className={fontColor}
409+
disabled={headerDisabled}
406410
>
407411
Log Equipment/Tool
408412
</DropdownItem>
409413
<DropdownItem
410414
tag={Link}
411415
to="/bmdashboard/tools/:equipmentId/update"
412416
className={fontColor}
417+
disabled={headerDisabled}
413418
>
414419
Update Equipment/Tool
415420
</DropdownItem>
416-
<DropdownItem tag={Link} to="/bmdashboard/equipment" className={fontColor}>
421+
<DropdownItem tag={Link} to="/bmdashboard/equipment" className={fontColor} disabled={headerDisabled}>
417422
Equipment/Tool List
418423
</DropdownItem>
419-
<DropdownItem tag={Link} to="/bmdashboard/Issue" className={fontColor}>
424+
<DropdownItem tag={Link} to="/bmdashboard/Issue" className={fontColor} disabled={headerDisabled}>
420425
Issue
421426
</DropdownItem>
422-
<DropdownItem tag={Link} to="/bmdashboard/lessonform/" className={fontColor}>
427+
<DropdownItem tag={Link} to="/bmdashboard/lessonform/" className={fontColor} disabled={headerDisabled}>
423428
Lesson
424429
</DropdownItem>
425430
</DropdownMenu>
@@ -428,46 +433,47 @@ export function Header(props) {
428433
</div>
429434
<div className="d-flex align-items-center justify-content-center">
430435
{canGetReports || canGetWeeklySummaries || canGetWeeklyVolunteerSummary ? (
431-
<UncontrolledDropdown nav inNavbar className="responsive-spacing">
436+
<UncontrolledDropdown nav inNavbar className="responsive-spacing" >
432437
<DropdownToggle nav caret>
433438
<span className="dashboard-text-link">{REPORTS}</span>
434439
</DropdownToggle>
435440
<DropdownMenu className={darkMode ? 'bg-yinmn-blue' : ''}>
436441
{canGetReports && (
437-
<DropdownItem tag={Link} to="/reports" className={`${fontColor}`}>
442+
<DropdownItem tag={Link} to="/reports" className={`${fontColor}`} disabled={headerDisabled}>
438443
{REPORTS}
439444
</DropdownItem>
440445
)}
441446
{canGetWeeklySummaries && (
442-
<DropdownItem tag={Link} to="/weeklysummariesreport" className={fontColor}>
447+
<DropdownItem tag={Link} to="/weeklysummariesreport" className={fontColor} disabled={headerDisabled}>
443448
{WEEKLY_SUMMARIES_REPORT}
444449
</DropdownItem>
445450
)}
446451
{canGetWeeklyVolunteerSummary && (
447-
<DropdownItem tag={Link} to="/totalorgsummary" className={fontColor}>
452+
<DropdownItem tag={Link} to="/totalorgsummary" className={fontColor} disabled={headerDisabled}>
448453
{TOTAL_ORG_SUMMARY}
449454
</DropdownItem>
450455
)}
451-
<DropdownItem tag={Link} to="/teamlocations" className={fontColor}>
456+
<DropdownItem tag={Link} to="/teamlocations" className={fontColor} disabled={headerDisabled}>
452457
{TEAM_LOCATIONS}
453458
</DropdownItem>
454459
<DropdownItem
455460
tag={Link}
456461
to="/bmdashboard/totalconstructionsummary"
457462
className={fontColor}
463+
disabled={headerDisabled}
458464
>
459465
{TOTAL_CONSTRUCTION_SUMMARY}
460466
</DropdownItem>
461467
</DropdownMenu>
462468
</UncontrolledDropdown>
463469
) : (
464470
<NavItem className="responsive-spacing">
465-
<NavLink tag={Link} to="/teamlocations">
471+
<NavLink tag={Link} to="/teamlocations" disabled={headerDisabled}>
466472
<span className="dashboard-text-link">{TEAM_LOCATIONS}</span>
467473
</NavLink>
468474
</NavItem>
469475
)}
470-
<NavItem className="responsive-spacing">
476+
<NavItem className="responsive-spacing" disabled={headerDisabled}>
471477
<BellNotification userId={displayUserId} />
472478
</NavItem>
473479
{(canAccessUserManagement ||
@@ -483,27 +489,27 @@ export function Header(props) {
483489
</DropdownToggle>
484490
<DropdownMenu className={darkMode ? 'bg-yinmn-blue' : ''}>
485491
{canAccessUserManagement && (
486-
<DropdownItem tag={Link} to="/usermanagement" className={fontColor}>
492+
<DropdownItem tag={Link} to="/usermanagement" className={fontColor} disabled={headerDisabled}>
487493
{USER_MANAGEMENT}
488494
</DropdownItem>
489495
)}
490496
{canAccessBadgeManagement && (
491-
<DropdownItem tag={Link} to="/badgemanagement" className={fontColor}>
497+
<DropdownItem tag={Link} to="/badgemanagement" className={fontColor} disabled={headerDisabled}>
492498
{BADGE_MANAGEMENT}
493499
</DropdownItem>
494500
)}
495501
{canAccessProjects && (
496-
<DropdownItem tag={Link} to="/projects" className={fontColor}>
502+
<DropdownItem tag={Link} to="/projects" className={fontColor} disabled={headerDisabled}>
497503
{PROJECTS}
498504
</DropdownItem>
499505
)}
500506
{canAccessTeams && (
501-
<DropdownItem tag={Link} to="/teams" className={fontColor}>
507+
<DropdownItem tag={Link} to="/teams" className={fontColor} disabled={headerDisabled}>
502508
{TEAMS}
503509
</DropdownItem>
504510
)}
505511
{canAccessSendEmails && (
506-
<DropdownItem tag={Link} to="/announcements" className={fontColor}>
512+
<DropdownItem tag={Link} to="/announcements" className={fontColor} disabled={headerDisabled}>
507513
{SEND_EMAILS}
508514
</DropdownItem>
509515
)}
@@ -514,20 +520,21 @@ export function Header(props) {
514520
tag={Link}
515521
to="/permissionsmanagement"
516522
className={fontColor}
523+
disabled={headerDisabled}
517524
>
518525
{PERMISSIONS_MANAGEMENT}
519526
</DropdownItem>
520527
</>
521528
)}
522529
<DropdownItem divider />
523-
<DropdownItem tag={Link} to="/pr-dashboard/overview" className={fontColor}>
530+
<DropdownItem tag={Link} to="/pr-dashboard/overview" className={fontColor} disabled={headerDisabled}>
524531
PR Team Analytics
525532
</DropdownItem>
526533
</DropdownMenu>
527534
</UncontrolledDropdown>
528535
)}
529536
<NavItem className="responsive-spacing">
530-
<NavLink tag={Link} to={`/userprofile/${displayUserId}`}>
537+
<NavLink tag={Link} to={`/userprofile/${displayUserId}`} disabled={headerDisabled}>
531538
<div
532539
style={{
533540
width: '60px',
@@ -558,6 +565,7 @@ export function Header(props) {
558565
tag={Link}
559566
to={`/userprofile/${displayUserId}`}
560567
className={fontColor}
568+
disabled={headerDisabled}
561569
>
562570
{VIEW_PROFILE}
563571
</DropdownItem>
@@ -569,6 +577,7 @@ export function Header(props) {
569577
tag={Link}
570578
to={`/updatepassword/${displayUserId}`}
571579
className={fontColor}
580+
disabled={headerDisabled}
572581
>
573582
{UPDATE_PASSWORD}
574583
</DropdownItem>
@@ -577,7 +586,7 @@ export function Header(props) {
577586
<DarkModeButton />
578587
</DropdownItem>
579588
<DropdownItem divider />
580-
<DropdownItem onClick={openModal} className={fontColor}>
589+
<DropdownItem onClick={openModal} className={fontColor} disabled={headerDisabled}>
581590
{LOGOUT}
582591
</DropdownItem>
583592
</DropdownMenu>

0 commit comments

Comments
 (0)