1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Allow to resign from an accepted revision when you didn't accept the diff.

Summary: Girish wants to be able to do this.

Test Plan: Checked that I had the option in my sandbox on an accepted diff.

Reviewers: epriestley, jungejason

Reviewed By: jungejason

CC: aran, jungejason, tuomaspelkonen, epriestley

Differential Revision: 1020
This commit is contained in:
tuomaspelkonen 2011-10-18 23:35:45 -07:00
parent dfa2e29a01
commit a102c9a0fe
5 changed files with 29 additions and 21 deletions

View file

@ -368,6 +368,7 @@ class DifferentialRevisionViewController extends DifferentialController {
$viewer_phid = $this->getRequest()->getUser()->getPHID();
$viewer_is_owner = ($viewer_phid == $revision->getAuthorPHID());
$viewer_is_reviewer = in_array($viewer_phid, $revision->getReviewers());
$viewer_did_accept = ($viewer_phid === $revision->loadReviewedBy());
if ($viewer_is_owner) {
switch ($revision->getStatus()) {
@ -403,6 +404,8 @@ class DifferentialRevisionViewController extends DifferentialController {
break;
case DifferentialRevisionStatus::ACCEPTED:
$actions[DifferentialAction::ACTION_REJECT] = true;
$actions[DifferentialAction::ACTION_RESIGN] =
$viewer_is_reviewer && !$viewer_did_accept;
break;
case DifferentialRevisionStatus::COMMITTED:
case DifferentialRevisionStatus::ABANDONED:

View file

@ -24,26 +24,10 @@ final class DifferentialReviewedByFieldSpecification
protected function didSetRevision() {
$this->reviewedBy = array();
$revision = $this->getRevision();
$reviewer = $revision->loadReviewedBy();
$status = $revision->getStatus();
if ($status == DifferentialRevisionStatus::ACCEPTED ||
$status == DifferentialRevisionStatus::COMMITTED) {
$reviewer = null;
$comments = $revision->loadComments();
foreach ($comments as $comment) {
$action = $comment->getAction();
if ($action == DifferentialAction::ACTION_ACCEPT) {
$reviewer = $comment->getAuthorPHID();
} else if ($action == DifferentialAction::ACTION_REJECT ||
$action == DifferentialAction::ACTION_ABANDON ||
$action == DifferentialAction::ACTION_RETHINK) {
$reviewer = null;
}
}
if ($reviewer) {
$this->reviewedBy = array($reviewer);
}
if ($reviewer) {
$this->reviewedBy = array($reviewer);
}
}

View file

@ -6,8 +6,6 @@
phutil_require_module('phabricator', 'applications/differential/constants/action');
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
phutil_require_module('phabricator', 'applications/differential/field/specification/base');

View file

@ -165,4 +165,25 @@ class DifferentialRevision extends DifferentialDAO {
public function getUnsubscribedPHIDs() {
return array_keys($this->getUnsubscribed());
}
public function loadReviewedBy() {
$reviewer = null;
if ($this->status == DifferentialRevisionStatus::ACCEPTED ||
$this->status == DifferentialRevisionStatus::COMMITTED) {
$comments = $this->loadComments();
foreach ($comments as $comment) {
$action = $comment->getAction();
if ($action == DifferentialAction::ACTION_ACCEPT) {
$reviewer = $comment->getAuthorPHID();
} else if ($action == DifferentialAction::ACTION_REJECT ||
$action == DifferentialAction::ACTION_ABANDON ||
$action == DifferentialAction::ACTION_RETHINK) {
$reviewer = null;
}
}
}
return $reviewer;
}
}

View file

@ -6,6 +6,8 @@
phutil_require_module('phabricator', 'applications/differential/constants/action');
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
phutil_require_module('phabricator', 'applications/differential/storage/base');
phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/diff');