mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-22 20:51:10 +01:00
d07292df7f
Summary: Ref T2222. Implements Commandeer on the new stuff. Test Plan: {F117768} {F117769} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D8331
162 lines
5.4 KiB
PHP
162 lines
5.4 KiB
PHP
<?php
|
|
|
|
final class DifferentialTransaction extends PhabricatorApplicationTransaction {
|
|
|
|
const TYPE_INLINE = 'differential:inline';
|
|
const TYPE_UPDATE = 'differential:update';
|
|
const TYPE_ACTION = 'differential:action';
|
|
|
|
public function getApplicationName() {
|
|
return 'differential';
|
|
}
|
|
|
|
public function getApplicationTransactionType() {
|
|
return DifferentialPHIDTypeRevision::TYPECONST;
|
|
}
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
|
return new DifferentialTransactionComment();
|
|
}
|
|
|
|
public function getTitle() {
|
|
$author_phid = $this->getAuthorPHID();
|
|
$author_handle = $this->renderHandleLink($author_phid);
|
|
|
|
$old = $this->getOldValue();
|
|
$new = $this->getNewValue();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_INLINE:
|
|
return pht(
|
|
'%s added inline comments.',
|
|
$author_handle);
|
|
case self::TYPE_UPDATE:
|
|
if ($new) {
|
|
// TODO: Migrate to PHIDs and use handles here?
|
|
// TODO: Link this?
|
|
return pht(
|
|
'%s updated this revision to Diff #%d.',
|
|
$author_handle,
|
|
$new);
|
|
} else {
|
|
return pht(
|
|
'%s updated this revision.',
|
|
$author_handle);
|
|
}
|
|
case self::TYPE_ACTION:
|
|
return DifferentialAction::getBasicStoryText($new, $author_handle);
|
|
}
|
|
|
|
return parent::getTitle();
|
|
}
|
|
|
|
public function getIcon() {
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_INLINE:
|
|
return 'comment';
|
|
case self::TYPE_UPDATE:
|
|
return 'refresh';
|
|
case self::TYPE_ACTION:
|
|
switch ($this->getNewValue()) {
|
|
case DifferentialAction::ACTION_CLOSE:
|
|
return 'ok';
|
|
case DifferentialAction::ACTION_ACCEPT:
|
|
return 'enable';
|
|
case DifferentialAction::ACTION_REJECT:
|
|
case DifferentialAction::ACTION_ABANDON:
|
|
return 'delete';
|
|
case DifferentialAction::ACTION_RETHINK:
|
|
return 'disable';
|
|
case DifferentialAction::ACTION_REQUEST:
|
|
return 'refresh';
|
|
case DifferentialAction::ACTION_RECLAIM:
|
|
case DifferentialAction::ACTION_REOPEN:
|
|
return 'new';
|
|
case DifferentialAction::ACTION_RESIGN:
|
|
return 'undo';
|
|
case DifferentialAction::ACTION_CLAIM:
|
|
return 'user';
|
|
}
|
|
}
|
|
|
|
return parent::getIcon();
|
|
}
|
|
|
|
public function getColor() {
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_UPDATE:
|
|
return PhabricatorTransactions::COLOR_SKY;
|
|
case self::TYPE_ACTION:
|
|
switch ($this->getNewValue()) {
|
|
case DifferentialAction::ACTION_CLOSE:
|
|
return PhabricatorTransactions::COLOR_BLUE;
|
|
case DifferentialAction::ACTION_ACCEPT:
|
|
return PhabricatorTransactions::COLOR_GREEN;
|
|
case DifferentialAction::ACTION_REJECT:
|
|
return PhabricatorTransactions::COLOR_RED;
|
|
case DifferentialAction::ACTION_ABANDON:
|
|
return PhabricatorTransactions::COLOR_BLACK;
|
|
case DifferentialAction::ACTION_RETHINK:
|
|
return PhabricatorTransactions::COLOR_RED;
|
|
case DifferentialAction::ACTION_REQUEST:
|
|
return PhabricatorTransactions::COLOR_SKY;
|
|
case DifferentialAction::ACTION_RECLAIM:
|
|
return PhabricatorTransactions::COLOR_SKY;
|
|
case DifferentialAction::ACTION_REOPEN:
|
|
return PhabricatorTransactions::COLOR_SKY;
|
|
case DifferentialAction::ACTION_RESIGN:
|
|
return PhabricatorTransactions::COLOR_ORANGE;
|
|
case DifferentialAction::ACTION_CLAIM:
|
|
return PhabricatorTransactions::COLOR_YELLOW;
|
|
}
|
|
}
|
|
|
|
|
|
return parent::getColor();
|
|
}
|
|
|
|
public function getNoEffectDescription() {
|
|
switch ($this->getTransactionType()) {
|
|
case PhabricatorTransactions::TYPE_EDGE:
|
|
switch ($this->getMetadataValue('edge:type')) {
|
|
case PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER:
|
|
return pht(
|
|
'The reviewers you are trying to add are already reviewing '.
|
|
'this revision.');
|
|
}
|
|
break;
|
|
case DifferentialTransaction::TYPE_ACTION:
|
|
switch ($this->getNewValue()) {
|
|
case DifferentialAction::ACTION_CLOSE:
|
|
return pht('This revision is already closed.');
|
|
case DifferentialAction::ACTION_ABANDON:
|
|
return pht('This revision has already been abandoned.');
|
|
case DifferentialAction::ACTION_RECLAIM:
|
|
return pht(
|
|
'You can not reclaim this revision because his revision is '.
|
|
'not abandoned.');
|
|
case DifferentialAction::ACTION_REOPEN:
|
|
return pht(
|
|
'You can not reopen this revision because this revision is '.
|
|
'not closed.');
|
|
case DifferentialAction::ACTION_RETHINK:
|
|
return pht('This revision already requires changes.');
|
|
case DifferentialAction::ACTION_REQUEST:
|
|
return pht('Review is already requested for this revision.');
|
|
case DifferentialAction::ACTION_RESIGN:
|
|
return pht(
|
|
'You can not resign from this revision because you are not '.
|
|
'a reviewer.');
|
|
case DifferentialAction::ACTION_CLAIM:
|
|
return pht(
|
|
'You can not commandeer this revision because you already own '.
|
|
'it.');
|
|
}
|
|
break;
|
|
}
|
|
|
|
return parent::getNoEffectDescription();
|
|
}
|
|
|
|
|
|
}
|