Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/storage/DifferentialTransaction.php
<?php | <?php | ||||
final class DifferentialTransaction | final class DifferentialTransaction | ||||
extends PhabricatorModularTransaction { | extends PhabricatorModularTransaction { | ||||
private $isCommandeerSideEffect; | private $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 MAILTAG_REVIEWERS = 'differential-reviewers'; | const MAILTAG_REVIEWERS = 'differential-reviewers'; | ||||
const MAILTAG_CLOSED = 'differential-committed'; | const MAILTAG_CLOSED = 'differential-committed'; | ||||
const MAILTAG_CC = 'differential-cc'; | const MAILTAG_CC = 'differential-cc'; | ||||
const MAILTAG_COMMENT = 'differential-comment'; | const MAILTAG_COMMENT = 'differential-comment'; | ||||
const MAILTAG_UPDATED = 'differential-updated'; | const MAILTAG_UPDATED = 'differential-updated'; | ||||
const MAILTAG_REVIEW_REQUEST = 'differential-review-request'; | const MAILTAG_REVIEW_REQUEST = 'differential-review-request'; | ||||
const MAILTAG_OTHER = 'differential-other'; | const MAILTAG_OTHER = 'differential-other'; | ||||
Show All 17 Lines | if ($xaction_type == PhabricatorTransactions::TYPE_CUSTOMFIELD) { | ||||
return new DifferentialRevisionTitleTransaction(); | return new DifferentialRevisionTitleTransaction(); | ||||
case 'differential:test-plan': | case 'differential:test-plan': | ||||
return new DifferentialRevisionTestPlanTransaction(); | return new DifferentialRevisionTestPlanTransaction(); | ||||
case 'differential:repository': | case 'differential:repository': | ||||
return new DifferentialRevisionRepositoryTransaction(); | return new DifferentialRevisionRepositoryTransaction(); | ||||
} | } | ||||
} | } | ||||
if ($xaction_type == 'differential:status') { | |||||
return new DifferentialRevisionStatusTransaction(); | |||||
} | |||||
return parent::newFallbackModularTransactionType(); | return parent::newFallbackModularTransactionType(); | ||||
} | } | ||||
public function setIsCommandeerSideEffect($is_side_effect) { | public function setIsCommandeerSideEffect($is_side_effect) { | ||||
$this->isCommandeerSideEffect = $is_side_effect; | $this->isCommandeerSideEffect = $is_side_effect; | ||||
return $this; | return $this; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | switch ($this->getTransactionType()) { | ||||
$commit_name, | $commit_name, | ||||
$author_name); | $author_name); | ||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
return DifferentialAction::getBasicStoryText($new, $author_handle); | return DifferentialAction::getBasicStoryText($new, $author_handle); | ||||
} | } | ||||
break; | break; | ||||
case self::TYPE_STATUS: | |||||
switch ($this->getNewValue()) { | |||||
case ArcanistDifferentialRevisionStatus::ACCEPTED: | |||||
return pht('This revision is now accepted and ready to land.'); | |||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION: | |||||
return pht('This revision now requires changes to proceed.'); | |||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: | |||||
return pht('This revision now requires review to proceed.'); | |||||
} | |||||
} | } | ||||
return parent::getTitle(); | return parent::getTitle(); | ||||
} | } | ||||
public function renderExtraInformationLink() { | public function renderExtraInformationLink() { | ||||
if ($this->getMetadataValue('revisionMatchData')) { | if ($this->getMetadataValue('revisionMatchData')) { | ||||
$details_href = | $details_href = | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | switch ($this->getTransactionType()) { | ||||
$object_link); | $object_link); | ||||
case DifferentialAction::ACTION_REOPEN: | case DifferentialAction::ACTION_REOPEN: | ||||
return pht( | return pht( | ||||
'%s reopened %s.', | '%s reopened %s.', | ||||
$author_link, | $author_link, | ||||
$object_link); | $object_link); | ||||
} | } | ||||
break; | break; | ||||
case self::TYPE_STATUS: | |||||
switch ($this->getNewValue()) { | |||||
case ArcanistDifferentialRevisionStatus::ACCEPTED: | |||||
return pht( | |||||
'%s is now accepted and ready to land.', | |||||
$object_link); | |||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION: | |||||
return pht( | |||||
'%s now requires changes to proceed.', | |||||
$object_link); | |||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: | |||||
return pht( | |||||
'%s now requires review to proceed.', | |||||
$object_link); | |||||
} | |||||
} | } | ||||
return parent::getTitleForFeed(); | return parent::getTitleForFeed(); | ||||
} | } | ||||
public function getIcon() { | public function getIcon() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_INLINE: | case self::TYPE_INLINE: | ||||
return 'fa-comment'; | return 'fa-comment'; | ||||
case self::TYPE_UPDATE: | case self::TYPE_UPDATE: | ||||
return 'fa-refresh'; | return 'fa-refresh'; | ||||
case self::TYPE_STATUS: | |||||
switch ($this->getNewValue()) { | |||||
case ArcanistDifferentialRevisionStatus::ACCEPTED: | |||||
return 'fa-check'; | |||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION: | |||||
return 'fa-times'; | |||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: | |||||
return 'fa-undo'; | |||||
} | |||||
break; | |||||
case self::TYPE_ACTION: | case self::TYPE_ACTION: | ||||
switch ($this->getNewValue()) { | switch ($this->getNewValue()) { | ||||
case DifferentialAction::ACTION_CLOSE: | case DifferentialAction::ACTION_CLOSE: | ||||
return 'fa-check'; | return 'fa-check'; | ||||
case DifferentialAction::ACTION_ACCEPT: | case DifferentialAction::ACTION_ACCEPT: | ||||
return 'fa-check-circle-o'; | return 'fa-check-circle-o'; | ||||
case DifferentialAction::ACTION_REJECT: | case DifferentialAction::ACTION_REJECT: | ||||
return 'fa-times-circle-o'; | return 'fa-times-circle-o'; | ||||
Show All 21 Lines | public function getIcon() { | ||||
return parent::getIcon(); | return parent::getIcon(); | ||||
} | } | ||||
public function shouldDisplayGroupWith(array $group) { | public function shouldDisplayGroupWith(array $group) { | ||||
// Never group status changes with other types of actions, they're indirect | // Never group status changes with other types of actions, they're indirect | ||||
// and don't make sense when combined with direct actions. | // and don't make sense when combined with direct actions. | ||||
$type_status = self::TYPE_STATUS; | if ($this->isStatusTransaction($this)) { | ||||
if ($this->getTransactionType() == $type_status) { | |||||
return false; | return false; | ||||
} | } | ||||
foreach ($group as $xaction) { | foreach ($group as $xaction) { | ||||
if ($xaction->getTransactionType() == $type_status) { | if ($this->isStatusTransaction($xaction)) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return parent::shouldDisplayGroupWith($group); | return parent::shouldDisplayGroupWith($group); | ||||
} | } | ||||
private function isStatusTransaction($xaction) { | |||||
$old_status = 'differential:status'; | |||||
if ($xaction->getTransactionType() == $old_status) { | |||||
return true; | |||||
} | |||||
$new_status = DifferentialRevisionStatusTransaction::TRANSACTIONTYPE; | |||||
if ($xaction->getTransactionType() == $new_status) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
public function getColor() { | public function getColor() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_UPDATE: | case self::TYPE_UPDATE: | ||||
return PhabricatorTransactions::COLOR_SKY; | return PhabricatorTransactions::COLOR_SKY; | ||||
case self::TYPE_STATUS: | |||||
switch ($this->getNewValue()) { | |||||
case ArcanistDifferentialRevisionStatus::ACCEPTED: | |||||
return PhabricatorTransactions::COLOR_GREEN; | |||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION: | |||||
return PhabricatorTransactions::COLOR_RED; | |||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: | |||||
return PhabricatorTransactions::COLOR_ORANGE; | |||||
} | |||||
break; | |||||
case self::TYPE_ACTION: | case self::TYPE_ACTION: | ||||
switch ($this->getNewValue()) { | switch ($this->getNewValue()) { | ||||
case DifferentialAction::ACTION_CLOSE: | case DifferentialAction::ACTION_CLOSE: | ||||
return PhabricatorTransactions::COLOR_INDIGO; | return PhabricatorTransactions::COLOR_INDIGO; | ||||
case DifferentialAction::ACTION_ACCEPT: | case DifferentialAction::ACTION_ACCEPT: | ||||
return PhabricatorTransactions::COLOR_GREEN; | return PhabricatorTransactions::COLOR_GREEN; | ||||
case DifferentialAction::ACTION_REJECT: | case DifferentialAction::ACTION_REJECT: | ||||
return PhabricatorTransactions::COLOR_RED; | return PhabricatorTransactions::COLOR_RED; | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |