Skip to content

Commit

Permalink
Merge pull request #2582 from objectcomputing/bugfix-2579/error-trans…
Browse files Browse the repository at this point in the history
…itioning-review-period-to-awaiting-review

Bugfix 2579/error transitioning review period to awaiting review
  • Loading branch information
mkimberlin authored Sep 4, 2024
2 parents 63232f1 + d3bd559 commit 614e704
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import jakarta.validation.constraints.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashSet;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -139,6 +138,7 @@ private void notifyRevieweeSupervisorsByReviewPeriod(UUID reviewPeriodId, String
Set<ReviewAssignment> reviewAssignments = reviewAssignmentRepository.findByReviewPeriodId(reviewPeriodId);
Set<UUID> revieweeIds = reviewAssignments.stream().map(ReviewAssignment::getRevieweeId).collect(Collectors.toSet());
Set<UUID> supervisorIds = new HashSet<>(memberProfileRepository.findSupervisoridByIdIn(revieweeIds));
supervisorIds.removeIf(Objects::isNull);
if (supervisorIds.isEmpty()) {
LOG.info(String.format("Supervisors not found for Reviewees %s", revieweeIds));
return;
Expand Down
61 changes: 42 additions & 19 deletions web-ui/src/components/reviews/TeamReviews.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ const TeamReviews = ({ onBack, periodId }) => {
const [toDelete, setToDelete] = useState(null);
const [unapproved, setUnapproved] = useState([]);
const [validationMessage, setValidationMessage] = useState(null);
const [confirmRevieweesWithNoSupervisorOpen, setConfirmRevieweesWithNoSupervisorOpen] = useState(false);
const [confirmRevieweesWithNoSupervisorQuestion, setConfirmRevieweesWithNoSupervisorQuestionText] = useState('');

const loadedReviews = useRef(false);
const loadingReviews = useRef(false);
Expand Down Expand Up @@ -652,25 +654,16 @@ const TeamReviews = ({ onBack, periodId }) => {
setValidationMessage(msg);
if (msg) return;

if (period.reviewStatus === ReviewStatus.PLANNING) {
updateReviewPeriodStatus(ReviewStatus.AWAITING_APPROVAL);
} else if (period.reviewStatus === ReviewStatus.AWAITING_APPROVAL) {
const visibleIds = new Set(visibleTeamMembers().map(m => m.id));
const unapproved = assignments.filter(
a => !a.approved && visibleIds.has(a.revieweeId)
);
// logAssignments(unapproved); // for debugging
setUnapproved(unapproved);
setConfirmationText(
unapproved.length === 0
? 'Are you sure you want to launch the review period?'
: unapproved.length === 1
? 'There is one visible, unapproved review assignment. ' +
'Would you like to approve it and launch this review period?'
: `There are ${unapproved.length} visible, unapproved review assignments. ` +
'Would you like to approve all of them and launch this review period?'
);
setConfirmationDialogOpen(true);
const uniqueNamesWithNoSupervisor = [...new Set(
visibleTeamMembers()
.filter(member => member.supervisorid === null) // Filter by null supervisorid
.map(member => member.name) // Map to the name property
)].join(', ');
if (uniqueNamesWithNoSupervisor.trim().length > 0) {
setConfirmRevieweesWithNoSupervisorQuestionText(uniqueNamesWithNoSupervisor);
setConfirmRevieweesWithNoSupervisorOpen(true);
} else {
return requestApprovalPost();
}
};

Expand Down Expand Up @@ -784,6 +777,29 @@ const TeamReviews = ({ onBack, periodId }) => {
onBack();
};

const requestApprovalPost = async () => {
if (period.reviewStatus === ReviewStatus.PLANNING) {
updateReviewPeriodStatus(ReviewStatus.AWAITING_APPROVAL);
} else if (period.reviewStatus === ReviewStatus.AWAITING_APPROVAL) {
const visibleIds = new Set(visibleTeamMembers().map(m => m.id));
const unapproved = assignments.filter(
a => !a.approved && visibleIds.has(a.revieweeId)
);
// logAssignments(unapproved); // for debugging
setUnapproved(unapproved);
setConfirmationText(
unapproved.length === 0
? 'Are you sure you want to launch the review period?'
: unapproved.length === 1
? 'There is one visible, unapproved review assignment. ' +
'Would you like to approve it and launch this review period?'
: `There are ${unapproved.length} visible, unapproved review assignments. ` +
'Would you like to approve all of them and launch this review period?'
);
setConfirmationDialogOpen(true);
}
}

const unapproveAll = () => {
visibleTeamMembers().map(member => approveMember(member, false));
};
Expand Down Expand Up @@ -1054,6 +1070,13 @@ const TeamReviews = ({ onBack, periodId }) => {
setOpen={setConfirmationDialogOpen}
title="Approve and Launch"
/>
<ConfirmationDialog
open={confirmRevieweesWithNoSupervisorOpen}
onYes={requestApprovalPost}
question={confirmRevieweesWithNoSupervisorQuestion}
setOpen={setConfirmRevieweesWithNoSupervisorOpen}
title="These reviewees have no supervisor. Continue?"
/>
</Root>
);
};
Expand Down

0 comments on commit 614e704

Please sign in to comment.