Skip to content

Commit

Permalink
Fix for viewer permissions when viewing users in schedule (#1648)
Browse files Browse the repository at this point in the history
# What this PR does

Fix for #999
  • Loading branch information
teodosii authored Mar 28, 2023
1 parent 4857e74 commit acf19b2
Showing 1 changed file with 37 additions and 34 deletions.
71 changes: 37 additions & 34 deletions src/containers/ScheduleSlot/ScheduleSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,51 @@ const ScheduleSlot: FC<ScheduleSlotProps> = observer((props) => {
)}
</div>
) : (
users.map(({ pk: userPk }, userIndex) => {
users.map(({ display_name, pk: userPk }, userIndex) => {
const storeUser = store.userStore.items[userPk];

// TODO remove
if (!storeUser) {
store.userStore.updateItem(userPk);
}

const inactive = false;

const title = getTitle(storeUser);
const title = storeUser ? getTitle(storeUser) : display_name;

const isOncall = Boolean(
storeUser && onCallNow && onCallNow.some((onCallUser) => storeUser.pk === onCallUser.pk)
);

const scheduleSlotContent = (
<div
className={cx('root', { root__inactive: inactive })}
style={{
backgroundColor: color,
}}
onMouseMove={trackMouse ? handleMouseMove : undefined}
onMouseLeave={trackMouse ? () => setMouseX(0) : undefined}
>
{trackMouse && mouseX > 0 && <div style={{ left: `${mouseX}px` }} className={cx('time')} />}
{storeUser && (
<WorkingHours
className={cx('working-hours')}
timezone={storeUser.timezone}
workingHours={storeUser.working_hours}
startMoment={start}
duration={duration}
/>
)}
<div className={cx('title')}>
{userIndex === 0 && label && (
<div className={cx('label')} style={{ color }}>
{label}
</div>
)}
{title}
</div>
</div>
);

if (!storeUser) {
return scheduleSlotContent;
} // show without a tooltip as we're lacking user info

return (
<Tooltip
key={userPk}
Expand All @@ -105,33 +134,7 @@ const ScheduleSlot: FC<ScheduleSlotProps> = observer((props) => {
/>
}
>
<div
className={cx('root', { root__inactive: inactive })}
style={{
backgroundColor: color,
}}
onMouseMove={trackMouse ? handleMouseMove : undefined}
onMouseLeave={trackMouse ? () => setMouseX(0) : undefined}
>
{trackMouse && mouseX > 0 && <div style={{ left: `${mouseX}px` }} className={cx('time')} />}
{storeUser && (
<WorkingHours
className={cx('working-hours')}
timezone={storeUser.timezone}
workingHours={storeUser.working_hours}
startMoment={start}
duration={duration}
/>
)}
<div className={cx('title')}>
{userIndex === 0 && label && (
<div className={cx('label')} style={{ color }}>
{label}
</div>
)}
{title}
</div>
</div>
{scheduleSlotContent}
</Tooltip>
);
})
Expand Down

0 comments on commit acf19b2

Please sign in to comment.