@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update Phriction Move Away transaction to modular transactions

Summary: Ref T12625

Test Plan: Move a document to a new location, verify the old and new document. Edit both. Grep for MOVE_AWAY

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12625

Differential Revision: https://secure.phabricator.com/D17988

+72 -43
+2
src/__phutil_library_map__.php
··· 4640 4640 'PhrictionDocumentHeraldAdapter' => 'applications/phriction/herald/PhrictionDocumentHeraldAdapter.php', 4641 4641 'PhrictionDocumentHeraldField' => 'applications/phriction/herald/PhrictionDocumentHeraldField.php', 4642 4642 'PhrictionDocumentHeraldFieldGroup' => 'applications/phriction/herald/PhrictionDocumentHeraldFieldGroup.php', 4643 + 'PhrictionDocumentMoveAwayTransaction' => 'applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php', 4643 4644 'PhrictionDocumentMoveToTransaction' => 'applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php', 4644 4645 'PhrictionDocumentPHIDType' => 'applications/phriction/phid/PhrictionDocumentPHIDType.php', 4645 4646 'PhrictionDocumentPathHeraldField' => 'applications/phriction/herald/PhrictionDocumentPathHeraldField.php', ··· 10303 10304 'PhrictionDocumentHeraldAdapter' => 'HeraldAdapter', 10304 10305 'PhrictionDocumentHeraldField' => 'HeraldField', 10305 10306 'PhrictionDocumentHeraldFieldGroup' => 'HeraldFieldGroup', 10307 + 'PhrictionDocumentMoveAwayTransaction' => 'PhrictionDocumentTransactionType', 10306 10308 'PhrictionDocumentMoveToTransaction' => 'PhrictionDocumentTransactionType', 10307 10309 'PhrictionDocumentPHIDType' => 'PhabricatorPHIDType', 10308 10310 'PhrictionDocumentPathHeraldField' => 'PhrictionDocumentHeraldField',
+5 -26
src/applications/phriction/editor/PhrictionTransactionEditor.php
··· 86 86 $types = parent::getTransactionTypes(); 87 87 88 88 $types[] = PhrictionTransaction::TYPE_CONTENT; 89 - $types[] = PhrictionTransaction::TYPE_MOVE_AWAY; 90 89 91 90 $types[] = PhabricatorTransactions::TYPE_EDGE; 92 91 $types[] = PhabricatorTransactions::TYPE_COMMENT; ··· 106 105 return null; 107 106 } 108 107 return $this->getOldContent()->getContent(); 109 - case PhrictionTransaction::TYPE_MOVE_AWAY: 110 - return null; 111 108 } 112 109 } 113 110 ··· 118 115 switch ($xaction->getTransactionType()) { 119 116 case PhrictionTransaction::TYPE_CONTENT: 120 117 return $xaction->getNewValue(); 121 - case PhrictionTransaction::TYPE_MOVE_AWAY: 122 - $document = $xaction->getNewValue(); 123 - $dict = array( 124 - 'id' => $document->getID(), 125 - 'phid' => $document->getPHID(), 126 - 'content' => $document->getContent()->getContent(), 127 - 'title' => $document->getContent()->getTitle(), 128 - ); 129 - return $dict; 130 118 } 131 119 } 132 120 ··· 140 128 case PhrictionTransaction::TYPE_CONTENT: 141 129 case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE: 142 130 case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: 143 - case PhrictionTransaction::TYPE_MOVE_AWAY: 131 + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: 144 132 return true; 145 133 } 146 134 } ··· 163 151 case PhrictionTransaction::TYPE_CONTENT: 164 152 $object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS); 165 153 return; 166 - case PhrictionTransaction::TYPE_MOVE_AWAY: 167 - $object->setStatus(PhrictionDocumentStatus::STATUS_MOVED); 168 - return; 169 154 } 170 155 } 171 156 ··· 212 197 switch ($xaction->getTransactionType()) { 213 198 case PhrictionTransaction::TYPE_CONTENT: 214 199 $this->getNewContent()->setContent($xaction->getNewValue()); 215 - break; 216 - case PhrictionTransaction::TYPE_MOVE_AWAY: 217 - $dict = $xaction->getNewValue(); 218 - $this->getNewContent()->setContent(''); 219 - $this->getNewContent()->setChangeType( 220 - PhrictionChangeType::CHANGE_MOVE_AWAY); 221 - $this->getNewContent()->setChangeRef($dict['id']); 222 200 break; 223 201 default: 224 202 break; ··· 234 212 switch ($xaction->getTransactionType()) { 235 213 case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 236 214 case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: 237 - case PhrictionTransaction::TYPE_CONTENT: 215 + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: 238 216 case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE: 239 - case PhrictionTransaction::TYPE_MOVE_AWAY: 217 + case PhrictionTransaction::TYPE_CONTENT: 240 218 $save_content = true; 241 219 break; 242 220 default: ··· 303 281 if ($this->moveAwayDocument !== null) { 304 282 $move_away_xactions = array(); 305 283 $move_away_xactions[] = id(new PhrictionTransaction()) 306 - ->setTransactionType(PhrictionTransaction::TYPE_MOVE_AWAY) 284 + ->setTransactionType( 285 + PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE) 307 286 ->setNewValue($object); 308 287 $sub_editor = id(new PhrictionTransactionEditor()) 309 288 ->setActor($this->getActor())
+3 -17
src/applications/phriction/storage/PhrictionTransaction.php
··· 4 4 extends PhabricatorModularTransaction { 5 5 6 6 const TYPE_CONTENT = 'content'; 7 - const TYPE_MOVE_AWAY = 'move-away'; 8 7 9 8 const MAILTAG_TITLE = 'phriction-title'; 10 9 const MAILTAG_CONTENT = 'phriction-content'; ··· 33 32 $new = $this->getNewValue(); 34 33 switch ($this->getTransactionType()) { 35 34 case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: 36 - case self::TYPE_MOVE_AWAY: 35 + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: 37 36 $phids[] = $new['phid']; 38 37 break; 39 38 case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: ··· 75 74 public function shouldHideForMail(array $xactions) { 76 75 switch ($this->getTransactionType()) { 77 76 case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: 78 - case self::TYPE_MOVE_AWAY: 77 + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: 79 78 return true; 80 79 case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 81 80 return $this->getMetadataValue('stub:create:phid', false); ··· 86 85 public function shouldHideForFeed() { 87 86 switch ($this->getTransactionType()) { 88 87 case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: 89 - case self::TYPE_MOVE_AWAY: 88 + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: 90 89 return true; 91 90 case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 92 91 return $this->getMetadataValue('stub:create:phid', false); ··· 98 97 switch ($this->getTransactionType()) { 99 98 case self::TYPE_CONTENT: 100 99 return 1.3; 101 - case self::TYPE_MOVE_AWAY: 102 - return 1.0; 103 100 } 104 101 105 102 return parent::getActionStrength(); ··· 112 109 switch ($this->getTransactionType()) { 113 110 case self::TYPE_CONTENT: 114 111 return pht('Edited'); 115 - case self::TYPE_MOVE_AWAY: 116 - return pht('Moved Away'); 117 112 } 118 113 119 114 return parent::getActionName(); ··· 126 121 switch ($this->getTransactionType()) { 127 122 case self::TYPE_CONTENT: 128 123 return 'fa-pencil'; 129 - case self::TYPE_MOVE_AWAY: 130 - return 'fa-arrows'; 131 124 } 132 125 133 126 return parent::getIcon(); ··· 145 138 return pht( 146 139 '%s edited the document content.', 147 140 $this->renderHandleLink($author_phid)); 148 - 149 - case self::TYPE_MOVE_AWAY: 150 - return pht( 151 - '%s moved this document to %s', 152 - $this->renderHandleLink($author_phid), 153 - $this->renderHandleLink($new['phid'])); 154 - 155 141 } 156 142 157 143 return parent::getTitle();
+62
src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php
··· 1 + <?php 2 + 3 + final class PhrictionDocumentMoveAwayTransaction 4 + extends PhrictionDocumentTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'move-away'; 7 + 8 + public function generateOldValue($object) { 9 + return null; 10 + } 11 + 12 + public function generateNewValue($object, $value) { 13 + $document = $value; 14 + $dict = array( 15 + 'id' => $document->getID(), 16 + 'phid' => $document->getPHID(), 17 + 'content' => $document->getContent()->getContent(), 18 + 'title' => $document->getContent()->getTitle(), 19 + ); 20 + return $dict; 21 + } 22 + 23 + public function applyInternalEffects($object, $value) { 24 + $object->setStatus(PhrictionDocumentStatus::STATUS_MOVED); 25 + } 26 + 27 + public function applyExternalEffects($object, $value) { 28 + $dict = $value; 29 + $this->getEditor()->getNewContent()->setContent(''); 30 + $this->getEditor()->getNewContent()->setChangeType( 31 + PhrictionChangeType::CHANGE_MOVE_AWAY); 32 + $this->getEditor()->getNewContent()->setChangeRef($dict['id']); 33 + } 34 + 35 + public function getActionName() { 36 + return pht('Moved Away'); 37 + } 38 + 39 + public function getTitle() { 40 + $new = $this->getNewValue(); 41 + 42 + return pht( 43 + '%s moved this document to %s', 44 + $this->renderAuthor(), 45 + $this->renderHandleLink($new['phid'])); 46 + } 47 + 48 + public function getTitleForFeed() { 49 + $new = $this->getNewValue(); 50 + 51 + return pht( 52 + '%s moved %s to %s', 53 + $this->renderAuthor(), 54 + $this->renderObject(), 55 + $this->renderHandleLink($new['phid'])); 56 + } 57 + 58 + public function getIcon() { 59 + return 'fa-arrows'; 60 + } 61 + 62 + }