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 20 Lines • Show All 180 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 |