diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index bceb28a334..bfc054b88b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4640,6 +4640,7 @@ phutil_register_library_map(array( '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 @@ phutil_register_library_map(array( '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 index e29bd50152..eaa6ea93f1 100644 --- a/src/applications/phriction/editor/PhrictionTransactionEditor.php +++ b/src/applications/phriction/editor/PhrictionTransactionEditor.php @@ -86,7 +86,6 @@ final class PhrictionTransactionEditor $types = parent::getTransactionTypes(); $types[] = PhrictionTransaction::TYPE_CONTENT; - $types[] = PhrictionTransaction::TYPE_MOVE_AWAY; $types[] = PhabricatorTransactions::TYPE_EDGE; $types[] = PhabricatorTransactions::TYPE_COMMENT; @@ -106,8 +105,6 @@ final class PhrictionTransactionEditor return null; } return $this->getOldContent()->getContent(); - case PhrictionTransaction::TYPE_MOVE_AWAY: - return null; } } @@ -118,15 +115,6 @@ final class PhrictionTransactionEditor 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 @@ final class PhrictionTransactionEditor case PhrictionTransaction::TYPE_CONTENT: case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE: case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: - case PhrictionTransaction::TYPE_MOVE_AWAY: + case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: return true; } } @@ -163,9 +151,6 @@ final class PhrictionTransactionEditor 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 @@ final class PhrictionTransactionEditor 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 @@ final class PhrictionTransactionEditor 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 @@ final class PhrictionTransactionEditor 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 index e447bf0bb4..542e9b3e58 100644 --- a/src/applications/phriction/storage/PhrictionTransaction.php +++ b/src/applications/phriction/storage/PhrictionTransaction.php @@ -4,7 +4,6 @@ final class PhrictionTransaction 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 @@ final class PhrictionTransaction $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 @@ final class PhrictionTransaction 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 @@ final class PhrictionTransaction 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 @@ final class PhrictionTransaction 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 @@ final class PhrictionTransaction 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 @@ final class PhrictionTransaction 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 @@ final class PhrictionTransaction 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 index 0000000000..c827f7337d --- /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'; + } + +}