diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 6929ce05e3..d4106da800 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -541,6 +541,7 @@ phutil_register_library_map(array( 'DifferentialRevisionPHIDType' => 'applications/differential/phid/DifferentialRevisionPHIDType.php', 'DifferentialRevisionPackageHeraldField' => 'applications/differential/herald/DifferentialRevisionPackageHeraldField.php', 'DifferentialRevisionPackageOwnerHeraldField' => 'applications/differential/herald/DifferentialRevisionPackageOwnerHeraldField.php', + 'DifferentialRevisionPlanChangesTransaction' => 'applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php', 'DifferentialRevisionQuery' => 'applications/differential/query/DifferentialRevisionQuery.php', 'DifferentialRevisionReclaimTransaction' => 'applications/differential/xaction/DifferentialRevisionReclaimTransaction.php', 'DifferentialRevisionRelationship' => 'applications/differential/relationships/DifferentialRevisionRelationship.php', @@ -549,6 +550,7 @@ phutil_register_library_map(array( 'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php', 'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php', 'DifferentialRevisionRepositoryTransaction' => 'applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php', + 'DifferentialRevisionRequestReviewTransaction' => 'applications/differential/xaction/DifferentialRevisionRequestReviewTransaction.php', 'DifferentialRevisionRequiredActionResultBucket' => 'applications/differential/query/DifferentialRevisionRequiredActionResultBucket.php', 'DifferentialRevisionResultBucket' => 'applications/differential/query/DifferentialRevisionResultBucket.php', 'DifferentialRevisionReviewersHeraldField' => 'applications/differential/herald/DifferentialRevisionReviewersHeraldField.php', @@ -5212,6 +5214,7 @@ phutil_register_library_map(array( 'DifferentialRevisionPHIDType' => 'PhabricatorPHIDType', 'DifferentialRevisionPackageHeraldField' => 'DifferentialRevisionHeraldField', 'DifferentialRevisionPackageOwnerHeraldField' => 'DifferentialRevisionHeraldField', + 'DifferentialRevisionPlanChangesTransaction' => 'DifferentialRevisionActionTransaction', 'DifferentialRevisionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'DifferentialRevisionReclaimTransaction' => 'DifferentialRevisionActionTransaction', 'DifferentialRevisionRelationship' => 'PhabricatorObjectRelationship', @@ -5220,6 +5223,7 @@ phutil_register_library_map(array( 'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField', 'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField', 'DifferentialRevisionRepositoryTransaction' => 'DifferentialRevisionTransactionType', + 'DifferentialRevisionRequestReviewTransaction' => 'DifferentialRevisionActionTransaction', 'DifferentialRevisionRequiredActionResultBucket' => 'DifferentialRevisionResultBucket', 'DifferentialRevisionResultBucket' => 'PhabricatorSearchResultBucket', 'DifferentialRevisionReviewersHeraldField' => 'DifferentialRevisionHeraldField', diff --git a/src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php b/src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php new file mode 100644 index 0000000000..e08e3e7277 --- /dev/null +++ b/src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php @@ -0,0 +1,75 @@ +getStatus() == $status_planned); + } + + public function applyInternalEffects($object, $value) { + $status_planned = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED; + $object->setStatus($status_planned); + } + + protected function validateAction($object, PhabricatorUser $viewer) { + $status_planned = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED; + + if ($object->getStatus() == $status_planned) { + throw new Exception( + pht( + 'You can not request review of this revision because this '. + 'revision is already under review and the action would have '. + 'no effect.')); + } + + if ($object->isClosed()) { + throw new Exception( + pht( + 'You can not plan changes to this this revision because it has '. + 'already been closed.')); + } + + if (!$this->isViewerRevisionAuthor($object, $viewer)) { + throw new Exception( + pht( + 'You can not plan changes to this revision because you do not '. + 'own it. Only the author of a revision can plan changes to it.')); + } + } + + public function getTitle() { + return pht( + '%s planned changes to this revision.', + $this->renderAuthor()); + } + + public function getTitleForFeed() { + return pht( + '%s planned changes to %s.', + $this->renderAuthor(), + $this->renderObject()); + } + +} diff --git a/src/applications/differential/xaction/DifferentialRevisionRequestReviewTransaction.php b/src/applications/differential/xaction/DifferentialRevisionRequestReviewTransaction.php new file mode 100644 index 0000000000..bd0320624f --- /dev/null +++ b/src/applications/differential/xaction/DifferentialRevisionRequestReviewTransaction.php @@ -0,0 +1,70 @@ +getStatus() == $status_review); + } + + public function applyInternalEffects($object, $value) { + $status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW; + $object->setStatus($status_review); + } + + protected function validateAction($object, PhabricatorUser $viewer) { + $status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW; + if ($object->getStatus() == $status_review) { + throw new Exception( + pht( + 'You can not request review of this revision because this '. + 'revision is already under review and the action would have '. + 'no effect.')); + } + + if ($object->isClosed()) { + throw new Exception( + pht( + 'You can not request review of this revision because it has '. + 'already been closed. You can only request review of open '. + 'revisions.')); + } + + if (!$this->isViewerRevisionAuthor($object, $viewer)) { + throw new Exception( + pht( + 'You can not request review of this revision because you are not '. + 'the author of the revision.')); + } + } + + public function getTitle() { + return pht( + '%s requested review of this revision.', + $this->renderAuthor()); + } + + public function getTitleForFeed() { + return pht( + '%s requested review of %s.', + $this->renderAuthor(), + $this->renderObject()); + } + +}