Differential D17558 Diff 42227 src/applications/differential/xaction/DifferentialRevisionResignTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/xaction/DifferentialRevisionResignTransaction.php
Show All 38 Lines | final class DifferentialRevisionResignTransaction | ||||
} | } | ||||
public function getCommandSummary() { | public function getCommandSummary() { | ||||
return pht('Resign from a revision.'); | return pht('Resign from a revision.'); | ||||
} | } | ||||
public function generateOldValue($object) { | public function generateOldValue($object) { | ||||
$actor = $this->getActor(); | $actor = $this->getActor(); | ||||
return !$this->isViewerAnyReviewer($object, $actor); | $resigned = DifferentialReviewerStatus::STATUS_RESIGNED; | ||||
return ($this->getViewerReviewerStatus($object, $actor) == $resigned); | |||||
} | } | ||||
public function applyExternalEffects($object, $value) { | public function applyExternalEffects($object, $value) { | ||||
$status = DifferentialReviewerStatus::STATUS_RESIGNED; | $status = DifferentialReviewerStatus::STATUS_RESIGNED; | ||||
$actor = $this->getActor(); | $actor = $this->getActor(); | ||||
$this->applyReviewerEffect($object, $actor, $value, $status); | $this->applyReviewerEffect($object, $actor, $value, $status); | ||||
} | } | ||||
protected function validateAction($object, PhabricatorUser $viewer) { | protected function validateAction($object, PhabricatorUser $viewer) { | ||||
if ($object->isClosed()) { | if ($object->isClosed()) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'You can not resign from this revision because it has already '. | 'You can not resign from this revision because it has already '. | ||||
'been closed. You can only resign from open revisions.')); | 'been closed. You can only resign from open revisions.')); | ||||
} | } | ||||
if (!$this->isViewerAnyReviewer($object, $viewer)) { | $resigned = DifferentialReviewerStatus::STATUS_RESIGNED; | ||||
if ($this->getViewerReviewerStatus($object, $viewer) == $resigned) { | |||||
throw new Exception( | |||||
pht( | |||||
'You can not resign from this revision because you have already '. | |||||
'resigned.')); | |||||
} | |||||
if (!$this->isViewerAnyAuthority($object, $viewer)) { | |||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'You can not resign from this revision because you are not a '. | 'You can not resign from this revision because you are not a '. | ||||
'reviewer. You can only resign from revisions where you are a '. | 'reviewer, and do not have authority over any reviewer.')); | ||||
'reviewer.')); | |||||
} | } | ||||
} | } | ||||
public function getTitle() { | public function getTitle() { | ||||
return pht( | return pht( | ||||
'%s resigned from this revision.', | '%s resigned from this revision.', | ||||
$this->renderAuthor()); | $this->renderAuthor()); | ||||
} | } | ||||
Show All 9 Lines |