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:
parent
6a9dd61c42
commit
6888472b56
6 changed files with 45 additions and 81 deletions
|
@ -4401,6 +4401,7 @@ phutil_register_library_map(array(
|
||||||
'PholioMockHeraldField' => 'applications/pholio/herald/PholioMockHeraldField.php',
|
'PholioMockHeraldField' => 'applications/pholio/herald/PholioMockHeraldField.php',
|
||||||
'PholioMockHeraldFieldGroup' => 'applications/pholio/herald/PholioMockHeraldFieldGroup.php',
|
'PholioMockHeraldFieldGroup' => 'applications/pholio/herald/PholioMockHeraldFieldGroup.php',
|
||||||
'PholioMockImagesView' => 'applications/pholio/view/PholioMockImagesView.php',
|
'PholioMockImagesView' => 'applications/pholio/view/PholioMockImagesView.php',
|
||||||
|
'PholioMockInlineTransaction' => 'applications/pholio/xaction/PholioMockInlineTransaction.php',
|
||||||
'PholioMockListController' => 'applications/pholio/controller/PholioMockListController.php',
|
'PholioMockListController' => 'applications/pholio/controller/PholioMockListController.php',
|
||||||
'PholioMockMailReceiver' => 'applications/pholio/mail/PholioMockMailReceiver.php',
|
'PholioMockMailReceiver' => 'applications/pholio/mail/PholioMockMailReceiver.php',
|
||||||
'PholioMockNameHeraldField' => 'applications/pholio/herald/PholioMockNameHeraldField.php',
|
'PholioMockNameHeraldField' => 'applications/pholio/herald/PholioMockNameHeraldField.php',
|
||||||
|
@ -9981,6 +9982,7 @@ phutil_register_library_map(array(
|
||||||
'PholioMockHeraldField' => 'HeraldField',
|
'PholioMockHeraldField' => 'HeraldField',
|
||||||
'PholioMockHeraldFieldGroup' => 'HeraldFieldGroup',
|
'PholioMockHeraldFieldGroup' => 'HeraldFieldGroup',
|
||||||
'PholioMockImagesView' => 'AphrontView',
|
'PholioMockImagesView' => 'AphrontView',
|
||||||
|
'PholioMockInlineTransaction' => 'PholioMockTransactionType',
|
||||||
'PholioMockListController' => 'PholioController',
|
'PholioMockListController' => 'PholioController',
|
||||||
'PholioMockMailReceiver' => 'PhabricatorObjectMailReceiver',
|
'PholioMockMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||||
'PholioMockNameHeraldField' => 'PholioMockHeraldField',
|
'PholioMockNameHeraldField' => 'PholioMockHeraldField',
|
||||||
|
|
|
@ -45,7 +45,7 @@ final class PholioMockCommentController extends PholioController {
|
||||||
|
|
||||||
foreach ($inline_comments as $inline_comment) {
|
foreach ($inline_comments as $inline_comment) {
|
||||||
$xactions[] = id(new PholioTransaction())
|
$xactions[] = id(new PholioTransaction())
|
||||||
->setTransactionType(PholioTransaction::TYPE_INLINE)
|
->setTransactionType(PholioMockInlineTransaction::TRANSACTIONTYPE)
|
||||||
->attachComment($inline_comment);
|
->attachComment($inline_comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,23 +30,9 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
||||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
|
|
||||||
$types[] = PholioTransaction::TYPE_INLINE;
|
|
||||||
|
|
||||||
return $types;
|
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(
|
protected function shouldApplyInitialEffects(
|
||||||
PhabricatorLiskDAO $object,
|
PhabricatorLiskDAO $object,
|
||||||
array $xactions) {
|
array $xactions) {
|
||||||
|
@ -147,7 +133,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
||||||
}
|
}
|
||||||
$comment = $xaction->getComment();
|
$comment = $xaction->getComment();
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PholioTransaction::TYPE_INLINE:
|
case PholioMockInlineTransaction::TRANSACTIONTYPE:
|
||||||
if ($comment && strlen($comment->getContent())) {
|
if ($comment && strlen($comment->getContent())) {
|
||||||
$inline_comments[] = $comment;
|
$inline_comments[] = $comment;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +223,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
||||||
// Move inline comments to the end, so the comments precede them.
|
// Move inline comments to the end, so the comments precede them.
|
||||||
foreach ($xactions as $xaction) {
|
foreach ($xactions as $xaction) {
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
if ($type == PholioTransaction::TYPE_INLINE) {
|
if ($type == PholioMockInlineTransaction::TRANSACTIONTYPE) {
|
||||||
$tail[] = $xaction;
|
$tail[] = $xaction;
|
||||||
} else {
|
} else {
|
||||||
$head[] = $xaction;
|
$head[] = $xaction;
|
||||||
|
@ -252,7 +238,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PholioTransaction::TYPE_INLINE:
|
case PholioMockInlineTransaction::TRANSACTIONTYPE:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
final class PholioTransaction extends PhabricatorModularTransaction {
|
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_STATUS = 'pholio-status';
|
||||||
const MAILTAG_COMMENT = 'pholio-comment';
|
const MAILTAG_COMMENT = 'pholio-comment';
|
||||||
const MAILTAG_UPDATED = 'pholio-updated';
|
const MAILTAG_UPDATED = 'pholio-updated';
|
||||||
|
@ -30,19 +27,10 @@ final class PholioTransaction extends PhabricatorModularTransaction {
|
||||||
return new PholioTransactionView();
|
return new PholioTransactionView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIcon() {
|
|
||||||
switch ($this->getTransactionType()) {
|
|
||||||
case self::TYPE_INLINE:
|
|
||||||
return 'fa-comment';
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::getIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMailTags() {
|
public function getMailTags() {
|
||||||
$tags = array();
|
$tags = array();
|
||||||
switch ($this->getTransactionType()) {
|
switch ($this->getTransactionType()) {
|
||||||
case self::TYPE_INLINE:
|
case PholioMockInlineTransaction::TRANSACTIONTYPE:
|
||||||
case PhabricatorTransactions::TYPE_COMMENT:
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
$tags[] = self::MAILTAG_COMMENT;
|
$tags[] = self::MAILTAG_COMMENT;
|
||||||
break;
|
break;
|
||||||
|
@ -65,50 +53,4 @@ final class PholioTransaction extends PhabricatorModularTransaction {
|
||||||
return $tags;
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,14 @@ final class PholioTransactionView
|
||||||
|
|
||||||
switch ($u->getTransactionType()) {
|
switch ($u->getTransactionType()) {
|
||||||
case PhabricatorTransactions::TYPE_COMMENT:
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
case PholioTransaction::TYPE_INLINE:
|
case PholioMockInlineTransaction::TRANSACTIONTYPE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($v->getTransactionType()) {
|
switch ($v->getTransactionType()) {
|
||||||
case PholioTransaction::TYPE_INLINE:
|
case PholioMockInlineTransaction::TRANSACTIONTYPE:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ final class PholioTransactionView
|
||||||
$out = array();
|
$out = array();
|
||||||
|
|
||||||
$group = $xaction->getTransactionGroup();
|
$group = $xaction->getTransactionGroup();
|
||||||
if ($xaction->getTransactionType() == PholioTransaction::TYPE_INLINE) {
|
$type = $xaction->getTransactionType();
|
||||||
|
if ($type == PholioMockInlineTransaction::TRANSACTIONTYPE) {
|
||||||
array_unshift($group, $xaction);
|
array_unshift($group, $xaction);
|
||||||
} else {
|
} else {
|
||||||
$out[] = parent::renderTransactionContent($xaction);
|
$out[] = parent::renderTransactionContent($xaction);
|
||||||
|
@ -63,7 +64,7 @@ final class PholioTransactionView
|
||||||
$inlines = array();
|
$inlines = array();
|
||||||
foreach ($group as $xaction) {
|
foreach ($group as $xaction) {
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PholioTransaction::TYPE_INLINE:
|
case PholioMockInlineTransaction::TRANSACTIONTYPE:
|
||||||
$inlines[] = $xaction;
|
$inlines[] = $xaction;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue