1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Migrate Pholio inline comments to modular transactions

Summary: Fixes T12626.

Test Plan: Made lots of comments, confirmed no UI changes

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T12626

Differential Revision: https://secure.phabricator.com/D17914
This commit is contained in:
Austin McKinley 2017-05-16 12:10:00 -07:00
parent 6a9dd61c42
commit 6888472b56
6 changed files with 45 additions and 81 deletions

View file

@ -4401,6 +4401,7 @@ phutil_register_library_map(array(
'PholioMockHeraldField' => 'applications/pholio/herald/PholioMockHeraldField.php',
'PholioMockHeraldFieldGroup' => 'applications/pholio/herald/PholioMockHeraldFieldGroup.php',
'PholioMockImagesView' => 'applications/pholio/view/PholioMockImagesView.php',
'PholioMockInlineTransaction' => 'applications/pholio/xaction/PholioMockInlineTransaction.php',
'PholioMockListController' => 'applications/pholio/controller/PholioMockListController.php',
'PholioMockMailReceiver' => 'applications/pholio/mail/PholioMockMailReceiver.php',
'PholioMockNameHeraldField' => 'applications/pholio/herald/PholioMockNameHeraldField.php',
@ -9981,6 +9982,7 @@ phutil_register_library_map(array(
'PholioMockHeraldField' => 'HeraldField',
'PholioMockHeraldFieldGroup' => 'HeraldFieldGroup',
'PholioMockImagesView' => 'AphrontView',
'PholioMockInlineTransaction' => 'PholioMockTransactionType',
'PholioMockListController' => 'PholioController',
'PholioMockMailReceiver' => 'PhabricatorObjectMailReceiver',
'PholioMockNameHeraldField' => 'PholioMockHeraldField',

View file

@ -45,7 +45,7 @@ final class PholioMockCommentController extends PholioController {
foreach ($inline_comments as $inline_comment) {
$xactions[] = id(new PholioTransaction())
->setTransactionType(PholioTransaction::TYPE_INLINE)
->setTransactionType(PholioMockInlineTransaction::TRANSACTIONTYPE)
->attachComment($inline_comment);
}

View file

@ -30,23 +30,9 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
$types[] = PholioTransaction::TYPE_INLINE;
return $types;
}
protected function transactionHasEffect(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PholioTransaction::TYPE_INLINE:
return true;
}
return parent::transactionHasEffect($object, $xaction);
}
protected function shouldApplyInitialEffects(
PhabricatorLiskDAO $object,
array $xactions) {
@ -147,7 +133,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
}
$comment = $xaction->getComment();
switch ($xaction->getTransactionType()) {
case PholioTransaction::TYPE_INLINE:
case PholioMockInlineTransaction::TRANSACTIONTYPE:
if ($comment && strlen($comment->getContent())) {
$inline_comments[] = $comment;
}
@ -237,7 +223,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
// Move inline comments to the end, so the comments precede them.
foreach ($xactions as $xaction) {
$type = $xaction->getTransactionType();
if ($type == PholioTransaction::TYPE_INLINE) {
if ($type == PholioMockInlineTransaction::TRANSACTIONTYPE) {
$tail[] = $xaction;
} else {
$head[] = $xaction;
@ -252,7 +238,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PholioTransaction::TYPE_INLINE:
case PholioMockInlineTransaction::TRANSACTIONTYPE:
return true;
}

View file

@ -2,9 +2,6 @@
final class PholioTransaction extends PhabricatorModularTransaction {
// Your witty commentary at the mock : image : x,y level
const TYPE_INLINE = 'inline';
const MAILTAG_STATUS = 'pholio-status';
const MAILTAG_COMMENT = 'pholio-comment';
const MAILTAG_UPDATED = 'pholio-updated';
@ -30,19 +27,10 @@ final class PholioTransaction extends PhabricatorModularTransaction {
return new PholioTransactionView();
}
public function getIcon() {
switch ($this->getTransactionType()) {
case self::TYPE_INLINE:
return 'fa-comment';
}
return parent::getIcon();
}
public function getMailTags() {
$tags = array();
switch ($this->getTransactionType()) {
case self::TYPE_INLINE:
case PholioMockInlineTransaction::TRANSACTIONTYPE:
case PhabricatorTransactions::TYPE_COMMENT:
$tags[] = self::MAILTAG_COMMENT;
break;
@ -65,50 +53,4 @@ final class PholioTransaction extends PhabricatorModularTransaction {
return $tags;
}
public function getTitle() {
$author_phid = $this->getAuthorPHID();
$old = $this->getOldValue();
$new = $this->getNewValue();
$type = $this->getTransactionType();
switch ($type) {
case self::TYPE_INLINE:
$count = 1;
foreach ($this->getTransactionGroup() as $xaction) {
if ($xaction->getTransactionType() == $type) {
$count++;
}
}
return pht(
'%s added %d inline comment(s).',
$this->renderHandleLink($author_phid),
$count);
break;
}
return parent::getTitle();
}
public function getTitleForFeed() {
$author_phid = $this->getAuthorPHID();
$object_phid = $this->getObjectPHID();
$old = $this->getOldValue();
$new = $this->getNewValue();
$type = $this->getTransactionType();
switch ($type) {
case self::TYPE_INLINE:
return pht(
'%s added an inline comment to %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
break;
}
return parent::getTitleForFeed();
}
}

View file

@ -30,14 +30,14 @@ final class PholioTransactionView
switch ($u->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
case PholioTransaction::TYPE_INLINE:
case PholioMockInlineTransaction::TRANSACTIONTYPE:
break;
default:
return false;
}
switch ($v->getTransactionType()) {
case PholioTransaction::TYPE_INLINE:
case PholioMockInlineTransaction::TRANSACTIONTYPE:
return true;
}
@ -50,7 +50,8 @@ final class PholioTransactionView
$out = array();
$group = $xaction->getTransactionGroup();
if ($xaction->getTransactionType() == PholioTransaction::TYPE_INLINE) {
$type = $xaction->getTransactionType();
if ($type == PholioMockInlineTransaction::TRANSACTIONTYPE) {
array_unshift($group, $xaction);
} else {
$out[] = parent::renderTransactionContent($xaction);
@ -63,7 +64,7 @@ final class PholioTransactionView
$inlines = array();
foreach ($group as $xaction) {
switch ($xaction->getTransactionType()) {
case PholioTransaction::TYPE_INLINE:
case PholioMockInlineTransaction::TRANSACTIONTYPE:
$inlines[] = $xaction;
break;
default:

View file

@ -0,0 +1,33 @@
<?php
final class PholioMockInlineTransaction
extends PholioMockTransactionType {
const TRANSACTIONTYPE = 'inline';
public function generateOldValue($object) {
return null;
}
public function getTitle() {
return pht(
'%s added inline comment(s).',
$this->renderAuthor());
}
public function getTitleForFeed() {
return pht(
'%s added an inline comment to %s.',
$this->renderAuthor(),
$this->renderObject());
}
public function getIcon() {
return 'fa-comment';
}
public function getTransactionHasEffect($object, $old, $new) {
return true;
}
}