Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/storage/DifferentialTransaction.php
Show All 12 Lines | final class DifferentialTransaction extends PhabricatorApplicationTransaction { | ||||
public function getIsCommandeerSideEffect() { | public function getIsCommandeerSideEffect() { | ||||
return $this->isCommandeerSideEffect; | return $this->isCommandeerSideEffect; | ||||
} | } | ||||
const TYPE_INLINE = 'differential:inline'; | const TYPE_INLINE = 'differential:inline'; | ||||
const TYPE_UPDATE = 'differential:update'; | const TYPE_UPDATE = 'differential:update'; | ||||
const TYPE_ACTION = 'differential:action'; | const TYPE_ACTION = 'differential:action'; | ||||
const TYPE_STATUS = 'differential:status'; | const TYPE_STATUS = 'differential:status'; | ||||
const TYPE_INLINEDONE = 'differential:inlinedone'; | |||||
public function getApplicationName() { | public function getApplicationName() { | ||||
return 'differential'; | return 'differential'; | ||||
} | } | ||||
public function getApplicationTransactionType() { | public function getApplicationTransactionType() { | ||||
return DifferentialRevisionPHIDType::TYPECONST; | return DifferentialRevisionPHIDType::TYPECONST; | ||||
} | } | ||||
public function getApplicationTransactionCommentObject() { | public function getApplicationTransactionCommentObject() { | ||||
return new DifferentialTransactionComment(); | return new DifferentialTransactionComment(); | ||||
} | } | ||||
public function getApplicationTransactionViewObject() { | public function getApplicationTransactionViewObject() { | ||||
return new DifferentialTransactionView(); | return new DifferentialTransactionView(); | ||||
} | } | ||||
public function shouldGenerateOldValue() { | |||||
switch ($this->getTransactionType()) { | |||||
case DifferentialTransaction::TYPE_INLINEDONE: | |||||
return false; | |||||
} | |||||
return parent::shouldGenerateOldValue(); | |||||
} | |||||
public function shouldHide() { | public function shouldHide() { | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_UPDATE: | case self::TYPE_UPDATE: | ||||
// Older versions of this transaction have an ID for the new value, | // Older versions of this transaction have an ID for the new value, | ||||
// and/or do not record the old value. Only hide the transaction if | // and/or do not record the old value. Only hide the transaction if | ||||
Show All 19 Lines | switch ($this->getTransactionType()) { | ||||
return true; | return true; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
return parent::shouldHide(); | return parent::shouldHide(); | ||||
} | } | ||||
public function shouldHideForMail(array $xactions) { | public function isInlineCommentTransaction() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_INLINE: | case self::TYPE_INLINE: | ||||
// Hide inlines when rendering mail transactions if any other | |||||
// transaction type exists. | |||||
foreach ($xactions as $xaction) { | |||||
if ($xaction->getTransactionType() != self::TYPE_INLINE) { | |||||
return true; | return true; | ||||
} | } | ||||
} | |||||
// If only inline transactions exist, we just render the first one. | return parent::isInlineCommentTransaction(); | ||||
return ($this !== head($xactions)); | |||||
} | |||||
return parent::shouldHideForMail($xactions); | |||||
} | |||||
public function getBodyForMail() { | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_INLINE: | |||||
// Don't render inlines into the mail body; they render into a special | |||||
// section immediately after the body instead. | |||||
return null; | |||||
} | |||||
return parent::getBodyForMail(); | |||||
} | } | ||||
public function getRequiredHandlePHIDs() { | public function getRequiredHandlePHIDs() { | ||||
$phids = parent::getRequiredHandlePHIDs(); | $phids = parent::getRequiredHandlePHIDs(); | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
Show All 22 Lines | final class DifferentialTransaction extends PhabricatorApplicationTransaction { | ||||
public function getActionStrength() { | public function getActionStrength() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_ACTION: | case self::TYPE_ACTION: | ||||
return 3; | return 3; | ||||
case self::TYPE_UPDATE: | case self::TYPE_UPDATE: | ||||
return 2; | return 2; | ||||
case self::TYPE_INLINE: | |||||
return 0.25; | |||||
} | } | ||||
return parent::getActionStrength(); | return parent::getActionStrength(); | ||||
} | } | ||||
public function getActionName() { | public function getActionName() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | public function getTitle() { | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_INLINE: | case self::TYPE_INLINE: | ||||
return pht( | return pht( | ||||
'%s added inline comments.', | '%s added inline comments.', | ||||
$author_handle); | $author_handle); | ||||
case self::TYPE_INLINEDONE: | |||||
$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.', | |||||
$author_handle, | |||||
new PhutilNumber($done), | |||||
new PhutilNumber($undone)); | |||||
} else if ($done) { | |||||
return pht( | |||||
'%s marked %s inline comment(s) as done.', | |||||
$author_handle, | |||||
new PhutilNumber($done)); | |||||
} else { | |||||
return pht( | |||||
'%s marked %s inline comment(s) as not done.', | |||||
$author_handle, | |||||
new PhutilNumber($undone)); | |||||
} | |||||
break; | |||||
case self::TYPE_UPDATE: | case self::TYPE_UPDATE: | ||||
if ($this->getMetadataValue('isCommitUpdate')) { | if ($this->getMetadataValue('isCommitUpdate')) { | ||||
return pht( | return pht( | ||||
'This revision was automatically updated to reflect the '. | 'This revision was automatically updated to reflect the '. | ||||
'committed changes.'); | 'committed changes.'); | ||||
} else if ($new) { | } else if ($new) { | ||||
// TODO: Migrate to PHIDs and use handles here? | // TODO: Migrate to PHIDs and use handles here? | ||||
if (phid_get_type($new) == DifferentialDiffPHIDType::TYPECONST) { | if (phid_get_type($new) == DifferentialDiffPHIDType::TYPECONST) { | ||||
▲ Show 20 Lines • Show All 446 Lines • Show Last 20 Lines |