Skip to content

Commit d25170a

Browse files
committed
2024-09-04 - bugfix-2579 - add check on null supervisors
1 parent 1f727d7 commit d25170a

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

web-ui/src/components/reviews/TeamReviews.jsx

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ const TeamReviews = ({ onBack, periodId }) => {
124124
const [canUpdate, setCanUpdate] = useState(false);
125125
const [confirmApproveAllOpen, setConfirmApproveAllOpen] = useState(false);
126126
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
127-
const [confirmRevieweesWithNoSupervisorOpen, setConfirmRevieweesWithNoSupervisorOpen] = useState(false);
128127
const [confirmationText, setConfirmationText] = useState('');
129128
const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false);
130129
const [memberSelectorOpen, setMemberSelectorOpen] = useState(false);
@@ -140,6 +139,8 @@ const TeamReviews = ({ onBack, periodId }) => {
140139
const [toDelete, setToDelete] = useState(null);
141140
const [unapproved, setUnapproved] = useState([]);
142141
const [validationMessage, setValidationMessage] = useState(null);
142+
const [confirmRevieweesWithNoSupervisorOpen, setConfirmRevieweesWithNoSupervisorOpen] = useState(false);
143+
const [confirmRevieweesWithNoSupervisorQuestion, setConfirmRevieweesWithNoSupervisorQuestionText] = useState('');
143144

144145
const loadedReviews = useRef(false);
145146
const loadingReviews = useRef(false);
@@ -662,29 +663,12 @@ const TeamReviews = ({ onBack, periodId }) => {
662663
console.log("TeamReviews, requestApproval, uniqueNamesWithNoSupervisor", uniqueNamesWithNoSupervisor);
663664

664665
if (uniqueNamesWithNoSupervisor.trim().length > 0) {
665-
666+
setConfirmRevieweesWithNoSupervisorQuestionText(uniqueNamesWithNoSupervisor);
667+
setConfirmRevieweesWithNoSupervisorOpen(true);
668+
} else {
669+
return requestApprovalPost();
666670
}
667671

668-
if (period.reviewStatus === ReviewStatus.PLANNING) {
669-
updateReviewPeriodStatus(ReviewStatus.AWAITING_APPROVAL);
670-
} else if (period.reviewStatus === ReviewStatus.AWAITING_APPROVAL) {
671-
const visibleIds = new Set(visibleTeamMembers().map(m => m.id));
672-
const unapproved = assignments.filter(
673-
a => !a.approved && visibleIds.has(a.revieweeId)
674-
);
675-
// logAssignments(unapproved); // for debugging
676-
setUnapproved(unapproved);
677-
setConfirmationText(
678-
unapproved.length === 0
679-
? 'Are you sure you want to launch the review period?'
680-
: unapproved.length === 1
681-
? 'There is one visible, unapproved review assignment. ' +
682-
'Would you like to approve it and launch this review period?'
683-
: `There are ${unapproved.length} visible, unapproved review assignments. ` +
684-
'Would you like to approve all of them and launch this review period?'
685-
);
686-
setConfirmationDialogOpen(true);
687-
}
688672
};
689673

690674
const compareStrings = (s1, s2) => (s1 || '').localeCompare(s2 || '');
@@ -797,6 +781,29 @@ const TeamReviews = ({ onBack, periodId }) => {
797781
onBack();
798782
};
799783

784+
const requestApprovalPost = async () => {
785+
if (period.reviewStatus === ReviewStatus.PLANNING) {
786+
updateReviewPeriodStatus(ReviewStatus.AWAITING_APPROVAL);
787+
} else if (period.reviewStatus === ReviewStatus.AWAITING_APPROVAL) {
788+
const visibleIds = new Set(visibleTeamMembers().map(m => m.id));
789+
const unapproved = assignments.filter(
790+
a => !a.approved && visibleIds.has(a.revieweeId)
791+
);
792+
// logAssignments(unapproved); // for debugging
793+
setUnapproved(unapproved);
794+
setConfirmationText(
795+
unapproved.length === 0
796+
? 'Are you sure you want to launch the review period?'
797+
: unapproved.length === 1
798+
? 'There is one visible, unapproved review assignment. ' +
799+
'Would you like to approve it and launch this review period?'
800+
: `There are ${unapproved.length} visible, unapproved review assignments. ` +
801+
'Would you like to approve all of them and launch this review period?'
802+
);
803+
setConfirmationDialogOpen(true);
804+
}
805+
}
806+
800807
const unapproveAll = () => {
801808
visibleTeamMembers().map(member => approveMember(member, false));
802809
};
@@ -1069,7 +1076,7 @@ const TeamReviews = ({ onBack, periodId }) => {
10691076
/>
10701077
<ConfirmationDialog
10711078
open={confirmRevieweesWithNoSupervisorOpen}
1072-
onYes={confirmRevieweesWithNoSupervisorYes}
1079+
onYes={requestApprovalPost}
10731080
question={confirmRevieweesWithNoSupervisorQuestion}
10741081
setOpen={setConfirmRevieweesWithNoSupervisorOpen}
10751082
title="These reviewees have no supervisor. Continue?"

0 commit comments

Comments
 (0)