Page MenuHomePhabricator

D17111.id41150.diff
No OneTemporary

D17111.id41150.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -512,6 +512,7 @@
'DifferentialRevisionAuthorProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php',
'DifferentialRevisionCloseDetailsController' => 'applications/differential/controller/DifferentialRevisionCloseDetailsController.php',
'DifferentialRevisionCloseTransaction' => 'applications/differential/xaction/DifferentialRevisionCloseTransaction.php',
+ 'DifferentialRevisionCommandeerTransaction' => 'applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php',
'DifferentialRevisionContentAddedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php',
'DifferentialRevisionContentHeraldField' => 'applications/differential/herald/DifferentialRevisionContentHeraldField.php',
'DifferentialRevisionContentRemovedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php',
@@ -5185,6 +5186,7 @@
'DifferentialRevisionAuthorProjectsHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionCloseDetailsController' => 'DifferentialController',
'DifferentialRevisionCloseTransaction' => 'DifferentialRevisionActionTransaction',
+ 'DifferentialRevisionCommandeerTransaction' => 'DifferentialRevisionActionTransaction',
'DifferentialRevisionContentAddedHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionContentHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionContentRemovedHeraldField' => 'DifferentialRevisionHeraldField',
diff --git a/src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php b/src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
@@ -0,0 +1,67 @@
+<?php
+
+final class DifferentialRevisionCommandeerTransaction
+ extends DifferentialRevisionActionTransaction {
+
+ const TRANSACTIONTYPE = 'differential.revision.commandeer';
+ const ACTIONKEY = 'commandeer';
+
+ protected function getRevisionActionLabel() {
+ return pht('Commandeer Revision');
+ }
+
+ protected function getRevisionActionDescription() {
+ return pht('You will take control of this revision and become its author.');
+ }
+
+ public function getIcon() {
+ return 'fa-flag';
+ }
+
+ public function getColor() {
+ return 'sky';
+ }
+
+ public function generateOldValue($object) {
+ return $object->getAuthorPHID();
+ }
+
+ public function generateNewValue($object, $value) {
+ $actor = $this->getActor();
+ return $actor->getPHID();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setAuthorPHID($value);
+ }
+
+ protected function validateAction($object, PhabricatorUser $viewer) {
+ if ($object->isClosed()) {
+ throw new Exception(
+ pht(
+ 'You can not commandeer this revision because it has already '.
+ 'been closed. You can only commandeer open revisions.'));
+ }
+
+ if ($this->isViewerRevisionAuthor($object, $viewer)) {
+ throw new Exception(
+ pht(
+ 'You can not commandeer this revision because you are already '.
+ 'the author.'));
+ }
+ }
+
+ public function getTitle() {
+ return pht(
+ '%s commandeered this revision.',
+ $this->renderAuthor());
+ }
+
+ public function getTitleForFeed() {
+ return pht(
+ '%s commandeered %s.',
+ $this->renderAuthor(),
+ $this->renderObject());
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Oct 17 2024, 1:34 AM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6711826
Default Alt Text
D17111.id41150.diff (3 KB)

Event Timeline