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 @@ -4640,6 +4640,7 @@ 'PhrictionDocumentHeraldAdapter' => 'applications/phriction/herald/PhrictionDocumentHeraldAdapter.php', 'PhrictionDocumentHeraldField' => 'applications/phriction/herald/PhrictionDocumentHeraldField.php', 'PhrictionDocumentHeraldFieldGroup' => 'applications/phriction/herald/PhrictionDocumentHeraldFieldGroup.php', + 'PhrictionDocumentMoveAwayTransaction' => 'applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php', 'PhrictionDocumentMoveToTransaction' => 'applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php', 'PhrictionDocumentPHIDType' => 'applications/phriction/phid/PhrictionDocumentPHIDType.php', 'PhrictionDocumentPathHeraldField' => 'applications/phriction/herald/PhrictionDocumentPathHeraldField.php', @@ -10303,6 +10304,7 @@ 'PhrictionDocumentHeraldAdapter' => 'HeraldAdapter', 'PhrictionDocumentHeraldField' => 'HeraldField', 'PhrictionDocumentHeraldFieldGroup' => 'HeraldFieldGroup', + 'PhrictionDocumentMoveAwayTransaction' => 'PhrictionDocumentTransactionType', 'PhrictionDocumentMoveToTransaction' => 'PhrictionDocumentTransactionType', 'PhrictionDocumentPHIDType' => 'PhabricatorPHIDType', 'PhrictionDocumentPathHeraldField' => 'PhrictionDocumentHeraldField', diff --git a/src/applications/phriction/editor/PhrictionTransactionEditor.php b/src/applications/phriction/editor/PhrictionTransactionEditor.php --- a/src/applications/phriction/editor/PhrictionTransactionEditor.php +++ b/src/applications/phriction/editor/PhrictionTransactionEditor.php @@ -86,7 +86,6 @@ $types = parent::getTransactionTypes(); $types[] = PhrictionTransaction::TYPE_CONTENT; - $types[] = PhrictionTransaction::TYPE_MOVE_AWAY; $types[] = PhabricatorTransactions::TYPE_EDGE; $types[] = PhabricatorTransactions::TYPE_COMMENT; @@ -106,8 +105,6 @@ return null; } return $this->getOldContent()->getContent(); - case PhrictionTransaction::TYPE_MOVE_AWAY: - return null; } } @@ -118,15 +115,6 @@ switch ($xaction->getTransactionType()) { case PhrictionTransaction::TYPE_CONTENT: return $xaction->getNewValue(); - case PhrictionTransaction::TYPE_MOVE_AWAY: - $document = $xaction->getNewValue(); - $dict = array( - 'id' => $document->getID(), - 'phid' => $document->getPHID(), - 'content' => $document->getContent()->getContent(), - 'title' => $document->getContent()->getTitle(), - ); - return $dict; } } @@ -140,7 +128,7 @@ case PhrictionTransaction::TYPE_CONTENT: case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE: case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: - case PhrictionTransaction::TYPE_MOVE_AWAY: + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: return true; } } @@ -163,9 +151,6 @@ case PhrictionTransaction::TYPE_CONTENT: $object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS); return; - case PhrictionTransaction::TYPE_MOVE_AWAY: - $object->setStatus(PhrictionDocumentStatus::STATUS_MOVED); - return; } } @@ -213,13 +198,6 @@ case PhrictionTransaction::TYPE_CONTENT: $this->getNewContent()->setContent($xaction->getNewValue()); break; - case PhrictionTransaction::TYPE_MOVE_AWAY: - $dict = $xaction->getNewValue(); - $this->getNewContent()->setContent(''); - $this->getNewContent()->setChangeType( - PhrictionChangeType::CHANGE_MOVE_AWAY); - $this->getNewContent()->setChangeRef($dict['id']); - break; default: break; } @@ -234,9 +212,9 @@ switch ($xaction->getTransactionType()) { case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: - case PhrictionTransaction::TYPE_CONTENT: + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE: - case PhrictionTransaction::TYPE_MOVE_AWAY: + case PhrictionTransaction::TYPE_CONTENT: $save_content = true; break; default: @@ -303,7 +281,8 @@ if ($this->moveAwayDocument !== null) { $move_away_xactions = array(); $move_away_xactions[] = id(new PhrictionTransaction()) - ->setTransactionType(PhrictionTransaction::TYPE_MOVE_AWAY) + ->setTransactionType( + PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE) ->setNewValue($object); $sub_editor = id(new PhrictionTransactionEditor()) ->setActor($this->getActor()) diff --git a/src/applications/phriction/storage/PhrictionTransaction.php b/src/applications/phriction/storage/PhrictionTransaction.php --- a/src/applications/phriction/storage/PhrictionTransaction.php +++ b/src/applications/phriction/storage/PhrictionTransaction.php @@ -4,7 +4,6 @@ extends PhabricatorModularTransaction { const TYPE_CONTENT = 'content'; - const TYPE_MOVE_AWAY = 'move-away'; const MAILTAG_TITLE = 'phriction-title'; const MAILTAG_CONTENT = 'phriction-content'; @@ -33,7 +32,7 @@ $new = $this->getNewValue(); switch ($this->getTransactionType()) { case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: - case self::TYPE_MOVE_AWAY: + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: $phids[] = $new['phid']; break; case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: @@ -75,7 +74,7 @@ public function shouldHideForMail(array $xactions) { switch ($this->getTransactionType()) { case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: - case self::TYPE_MOVE_AWAY: + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: return true; case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: return $this->getMetadataValue('stub:create:phid', false); @@ -86,7 +85,7 @@ public function shouldHideForFeed() { switch ($this->getTransactionType()) { case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: - case self::TYPE_MOVE_AWAY: + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: return true; case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: return $this->getMetadataValue('stub:create:phid', false); @@ -98,8 +97,6 @@ switch ($this->getTransactionType()) { case self::TYPE_CONTENT: return 1.3; - case self::TYPE_MOVE_AWAY: - return 1.0; } return parent::getActionStrength(); @@ -112,8 +109,6 @@ switch ($this->getTransactionType()) { case self::TYPE_CONTENT: return pht('Edited'); - case self::TYPE_MOVE_AWAY: - return pht('Moved Away'); } return parent::getActionName(); @@ -126,8 +121,6 @@ switch ($this->getTransactionType()) { case self::TYPE_CONTENT: return 'fa-pencil'; - case self::TYPE_MOVE_AWAY: - return 'fa-arrows'; } return parent::getIcon(); @@ -145,13 +138,6 @@ return pht( '%s edited the document content.', $this->renderHandleLink($author_phid)); - - case self::TYPE_MOVE_AWAY: - return pht( - '%s moved this document to %s', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($new['phid'])); - } return parent::getTitle(); diff --git a/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php b/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php new file mode 100644 --- /dev/null +++ b/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php @@ -0,0 +1,62 @@ + $document->getID(), + 'phid' => $document->getPHID(), + 'content' => $document->getContent()->getContent(), + 'title' => $document->getContent()->getTitle(), + ); + return $dict; + } + + public function applyInternalEffects($object, $value) { + $object->setStatus(PhrictionDocumentStatus::STATUS_MOVED); + } + + public function applyExternalEffects($object, $value) { + $dict = $value; + $this->getEditor()->getNewContent()->setContent(''); + $this->getEditor()->getNewContent()->setChangeType( + PhrictionChangeType::CHANGE_MOVE_AWAY); + $this->getEditor()->getNewContent()->setChangeRef($dict['id']); + } + + public function getActionName() { + return pht('Moved Away'); + } + + public function getTitle() { + $new = $this->getNewValue(); + + return pht( + '%s moved this document to %s', + $this->renderAuthor(), + $this->renderHandleLink($new['phid'])); + } + + public function getTitleForFeed() { + $new = $this->getNewValue(); + + return pht( + '%s moved %s to %s', + $this->renderAuthor(), + $this->renderObject(), + $this->renderHandleLink($new['phid'])); + } + + public function getIcon() { + return 'fa-arrows'; + } + +}