Differential D12129 Diff 29186 src/applications/transactions/storage/PhabricatorApplicationTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | public function getIgnoreOnNoEffect() { | ||||
return $this->ignoreOnNoEffect; | return $this->ignoreOnNoEffect; | ||||
} | } | ||||
public function shouldGenerateOldValue() { | public function shouldGenerateOldValue() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhabricatorTransactions::TYPE_BUILDABLE: | case PhabricatorTransactions::TYPE_BUILDABLE: | ||||
case PhabricatorTransactions::TYPE_TOKEN: | case PhabricatorTransactions::TYPE_TOKEN: | ||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD: | case PhabricatorTransactions::TYPE_CUSTOMFIELD: | ||||
case PhabricatorTransactions::TYPE_INLINESTATE: | |||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
abstract public function getApplicationTransactionType(); | abstract public function getApplicationTransactionType(); | ||||
private function getApplicationObjectTypeName() { | private function getApplicationObjectTypeName() { | ||||
▲ Show 20 Lines • Show All 428 Lines • ▼ Show 20 Lines | case PhabricatorTransactions::TYPE_EDGE: | ||||
return true; | return true; | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
// If a transaction publishes an inline comment: | |||||
// | |||||
// - Don't show it if there are other kinds of transactions. The | |||||
// rationale here is that application mail will make the presence | |||||
// of inline comments obvious enough by including them prominently | |||||
// in the body. We could change this in the future if the obviousness | |||||
// needs to be increased. | |||||
// - If there are only inline transactions, only show the first | |||||
// transaction. The rationale is that seeing multiple "added an inline | |||||
// comment" transactions is not useful. | |||||
if ($this->isInlineCommentTransaction()) { | |||||
foreach ($xactions as $xaction) { | |||||
if (!$xaction->isInlineCommentTransaction()) { | |||||
return true; | |||||
} | |||||
} | |||||
return ($this !== head($xactions)); | |||||
} | |||||
return $this->shouldHide(); | return $this->shouldHide(); | ||||
} | } | ||||
public function shouldHideForFeed() { | public function shouldHideForFeed() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhabricatorTransactions::TYPE_TOKEN: | case PhabricatorTransactions::TYPE_TOKEN: | ||||
return true; | return true; | ||||
case PhabricatorTransactions::TYPE_BUILDABLE: | case PhabricatorTransactions::TYPE_BUILDABLE: | ||||
Show All 22 Lines | public function shouldHideForFeed() { | ||||
return $this->shouldHide(); | return $this->shouldHide(); | ||||
} | } | ||||
public function getTitleForMail() { | public function getTitleForMail() { | ||||
return id(clone $this)->setRenderingTarget('text')->getTitle(); | return id(clone $this)->setRenderingTarget('text')->getTitle(); | ||||
} | } | ||||
public function getBodyForMail() { | public function getBodyForMail() { | ||||
if ($this->isInlineCommentTransaction()) { | |||||
// We don't return inline comment content as mail body content, because | |||||
// applications need to contextualize it (by adding line numbers, for | |||||
// example) in order for it to make sense. | |||||
return null; | |||||
} | |||||
$comment = $this->getComment(); | $comment = $this->getComment(); | ||||
if ($comment && strlen($comment->getContent())) { | if ($comment && strlen($comment->getContent())) { | ||||
return $comment->getContent(); | return $comment->getContent(); | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
public function getNoEffectDescription() { | public function getNoEffectDescription() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhabricatorTransactions::TYPE_COMMENT: | case PhabricatorTransactions::TYPE_COMMENT: | ||||
return pht('You can not post an empty comment.'); | return pht('You can not post an empty comment.'); | ||||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | switch ($this->getTransactionType()) { | ||||
'%s failed to build %s!', | '%s failed to build %s!', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderHandleLink( | $this->renderHandleLink( | ||||
$this->getMetadataValue('harbormaster:buildablePHID'))); | $this->getMetadataValue('harbormaster:buildablePHID'))); | ||||
default: | default: | ||||
return null; | return null; | ||||
} | } | ||||
case PhabricatorTransactions::TYPE_INLINESTATE: | |||||
$done = 0; | |||||
$undone = 0; | |||||
foreach ($new as $phid => $state) { | |||||
if ($state == PhabricatorInlineCommentInterface::STATE_DONE) { | |||||
$done++; | |||||
} else { | |||||
$undone++; | |||||
} | |||||
} | |||||
if ($done && $undone) { | |||||
return pht( | |||||
'%s marked %s inline comment(s) as done and %s inline comment(s) '. | |||||
'as not done.', | |||||
$this->renderHandleLink($author_phid), | |||||
new PhutilNumber($done), | |||||
new PhutilNumber($undone)); | |||||
} else if ($done) { | |||||
return pht( | |||||
'%s marked %s inline comment(s) as done.', | |||||
$this->renderHandleLink($author_phid), | |||||
new PhutilNumber($done)); | |||||
} else { | |||||
return pht( | |||||
'%s marked %s inline comment(s) as not done.', | |||||
$this->renderHandleLink($author_phid), | |||||
new PhutilNumber($undone)); | |||||
} | |||||
break; | |||||
default: | default: | ||||
return pht( | return pht( | ||||
'%s edited this %s.', | '%s edited this %s.', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->getApplicationObjectTypeName()); | $this->getApplicationObjectTypeName()); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | public function isCommentTransaction() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhabricatorTransactions::TYPE_COMMENT: | case PhabricatorTransactions::TYPE_COMMENT: | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
public function isInlineCommentTransaction() { | |||||
return false; | |||||
} | |||||
public function getActionName() { | public function getActionName() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhabricatorTransactions::TYPE_COMMENT: | case PhabricatorTransactions::TYPE_COMMENT: | ||||
return pht('Commented On'); | return pht('Commented On'); | ||||
case PhabricatorTransactions::TYPE_VIEW_POLICY: | case PhabricatorTransactions::TYPE_VIEW_POLICY: | ||||
case PhabricatorTransactions::TYPE_EDIT_POLICY: | case PhabricatorTransactions::TYPE_EDIT_POLICY: | ||||
case PhabricatorTransactions::TYPE_JOIN_POLICY: | case PhabricatorTransactions::TYPE_JOIN_POLICY: | ||||
return pht('Changed Policy'); | return pht('Changed Policy'); | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |