mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 10:42:41 +01:00
Allow accepting accepted revisions, and rejecting rejected revisions
Summary: Ref T1279. With the new per-reviewer status, you can always accept or reject a revision. This is primarily cosmetic/UI changes. In particular, you've always been able to reject a rejected revision, the UI just didn't show you an option. Test Plan: Accepted accepted revisions; rejected rejected revisions. See screenshots. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1279 Differential Revision: https://secure.phabricator.com/D7243
This commit is contained in:
parent
d518f3c9de
commit
929ad86b57
2 changed files with 38 additions and 28 deletions
|
@ -588,9 +588,24 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||
$viewer_phid = $viewer->getPHID();
|
||||
$viewer_is_owner = ($viewer_phid == $revision->getAuthorPHID());
|
||||
$viewer_is_reviewer = in_array($viewer_phid, $revision->getReviewers());
|
||||
$viewer_did_accept = ($viewer_phid === $revision->loadReviewedBy());
|
||||
$status = $revision->getStatus();
|
||||
|
||||
$viewer_has_accepted = false;
|
||||
$viewer_has_rejected = false;
|
||||
$status_accepted = DifferentialReviewerStatus::STATUS_ACCEPTED;
|
||||
$status_rejected = DifferentialReviewerStatus::STATUS_REJECTED;
|
||||
foreach ($revision->getReviewerStatus() as $reviewer) {
|
||||
if ($reviewer->getReviewerPHID() == $viewer_phid) {
|
||||
if ($reviewer->getStatus() == $status_accepted) {
|
||||
$viewer_has_accepted = true;
|
||||
}
|
||||
if ($reviewer->getStatus() == $status_rejected) {
|
||||
$viewer_has_rejected = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$allow_self_accept = PhabricatorEnv::getEnvConfig(
|
||||
'differential.allow-self-accept');
|
||||
$always_allow_close = PhabricatorEnv::getEnvConfig(
|
||||
|
@ -631,12 +646,13 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||
break;
|
||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
|
||||
$actions[DifferentialAction::ACTION_ACCEPT] = true;
|
||||
$actions[DifferentialAction::ACTION_REJECT] = !$viewer_has_rejected;
|
||||
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
||||
break;
|
||||
case ArcanistDifferentialRevisionStatus::ACCEPTED:
|
||||
$actions[DifferentialAction::ACTION_ACCEPT] = !$viewer_has_accepted;
|
||||
$actions[DifferentialAction::ACTION_REJECT] = true;
|
||||
$actions[DifferentialAction::ACTION_RESIGN] =
|
||||
$viewer_is_reviewer && !$viewer_did_accept;
|
||||
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
||||
break;
|
||||
case ArcanistDifferentialRevisionStatus::CLOSED:
|
||||
case ArcanistDifferentialRevisionStatus::ABANDONED:
|
||||
|
|
|
@ -210,28 +210,23 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
|
|||
throw new Exception('You can not accept your own revision.');
|
||||
}
|
||||
|
||||
if (($revision_status !=
|
||||
ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) &&
|
||||
($revision_status !=
|
||||
ArcanistDifferentialRevisionStatus::NEEDS_REVISION)) {
|
||||
|
||||
switch ($revision_status) {
|
||||
case ArcanistDifferentialRevisionStatus::ACCEPTED:
|
||||
throw new DifferentialActionHasNoEffectException(
|
||||
"You can not accept this revision because someone else ".
|
||||
"already accepted it.");
|
||||
case ArcanistDifferentialRevisionStatus::ABANDONED:
|
||||
throw new DifferentialActionHasNoEffectException(
|
||||
"You can not accept this revision because it has been ".
|
||||
"abandoned.");
|
||||
case ArcanistDifferentialRevisionStatus::CLOSED:
|
||||
throw new DifferentialActionHasNoEffectException(
|
||||
"You can not accept this revision because it has already ".
|
||||
"been closed.");
|
||||
default:
|
||||
throw new Exception(
|
||||
"Unexpected revision state '{$revision_status}'!");
|
||||
}
|
||||
switch ($revision_status) {
|
||||
case ArcanistDifferentialRevisionStatus::ABANDONED:
|
||||
throw new DifferentialActionHasNoEffectException(
|
||||
"You can not accept this revision because it has been ".
|
||||
"abandoned.");
|
||||
case ArcanistDifferentialRevisionStatus::CLOSED:
|
||||
throw new DifferentialActionHasNoEffectException(
|
||||
"You can not accept this revision because it has already ".
|
||||
"been closed.");
|
||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
|
||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
|
||||
case ArcanistDifferentialRevisionStatus::ACCEPTED:
|
||||
// We expect "Accept" from these states.
|
||||
break;
|
||||
default:
|
||||
throw new Exception(
|
||||
"Unexpected revision state '{$revision_status}'!");
|
||||
}
|
||||
|
||||
$revision
|
||||
|
@ -306,9 +301,7 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
|
|||
case ArcanistDifferentialRevisionStatus::ACCEPTED:
|
||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
|
||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
|
||||
// NOTE: We allow you to reject an already-rejected revision
|
||||
// because it doesn't create any ambiguity and avoids a rather
|
||||
// needless dialog.
|
||||
// We expect rejects from these states.
|
||||
break;
|
||||
case ArcanistDifferentialRevisionStatus::ABANDONED:
|
||||
throw new DifferentialActionHasNoEffectException(
|
||||
|
@ -343,6 +336,7 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
|
|||
case ArcanistDifferentialRevisionStatus::ACCEPTED:
|
||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
|
||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
|
||||
// We expect accepts from these states.
|
||||
break;
|
||||
case ArcanistDifferentialRevisionStatus::ABANDONED:
|
||||
throw new DifferentialActionHasNoEffectException(
|
||||
|
|
Loading…
Reference in a new issue