1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-09 22:31:03 +01:00

When a revision has only human reviewers but none can view it, show a warning banner

Summary: Ref T13602. Warn when a reivison has at least one human reviewer, no non-human reviewers, and no human reviewers can view it.

Test Plan: {F8430683}

Maniphest Tasks: T13602

Differential Revision: https://secure.phabricator.com/D21556
This commit is contained in:
epriestley 2021-02-13 13:19:04 -08:00
parent 2f33dedc8b
commit 42c26821ef

View file

@ -72,22 +72,40 @@ final class DifferentialReviewersField
return array(); return array();
} }
$viewer = $this->getViewer();
PhabricatorPolicyFilterSet::loadHandleViewCapabilities(
$viewer,
$handles,
array($revision));
$all_resigned = true; $all_resigned = true;
$all_disabled = true; $all_disabled = true;
$any_reviewers = false; $any_reviewers = false;
$all_exiled = true;
foreach ($this->getValue() as $reviewer) { foreach ($this->getValue() as $reviewer) {
$reviewer_phid = $reviewer->getReviewerPHID(); $reviewer_phid = $reviewer->getReviewerPHID();
$handle = $handles[$reviewer_phid];
$any_reviewers = true; $any_reviewers = true;
if (!$handles[$reviewer_phid]->isDisabled()) { if (!$handle->isDisabled()) {
$all_disabled = false; $all_disabled = false;
} }
if (!$reviewer->isResigned()) { if (!$reviewer->isResigned()) {
$all_resigned = false; $all_resigned = false;
} }
if (!$handle->hasCapabilities()) {
$all_exiled = false;
} else {
if ($handle->hasViewCapability($revision)) {
$all_exiled = false;
}
}
} }
$warnings = array(); $warnings = array();
@ -101,6 +119,10 @@ final class DifferentialReviewersField
} else if ($all_resigned) { } else if ($all_resigned) {
$warnings[] = pht( $warnings[] = pht(
'This revision needs review, but all reviewers have resigned.'); 'This revision needs review, but all reviewers have resigned.');
} else if ($all_exiled) {
$warnings[] = pht(
'This revision needs review, but no reviewers have permission '.
'to view it.');
} }
return $warnings; return $warnings;