mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-28 12:08:14 +01:00
Summary: Ref T2543. Most actions are not available for drafts. Authors can "Request Review" (move out of draft to become a normal revision) or "Abandon". Non-authors can't do anything (maybe we'll let them do something later -- like "Commandeer"? -- if there's a good reason). Test Plan: Viewed a draft revision as an author and non-author, saw fewer actions available. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T2543 Differential Revision: https://secure.phabricator.com/D18626
95 lines
2.1 KiB
PHP
95 lines
2.1 KiB
PHP
<?php
|
|
|
|
final class DifferentialRevisionCommandeerTransaction
|
|
extends DifferentialRevisionActionTransaction {
|
|
|
|
const TRANSACTIONTYPE = 'differential.revision.commandeer';
|
|
const ACTIONKEY = 'commandeer';
|
|
|
|
protected function getRevisionActionLabel() {
|
|
return pht('Commandeer Revision');
|
|
}
|
|
|
|
protected function getRevisionActionDescription(
|
|
DifferentialRevision $revision) {
|
|
return pht('You will take control of this revision and become its author.');
|
|
}
|
|
|
|
public function getIcon() {
|
|
return 'fa-flag';
|
|
}
|
|
|
|
public function getColor() {
|
|
return 'sky';
|
|
}
|
|
|
|
protected function getRevisionActionOrder() {
|
|
return 700;
|
|
}
|
|
|
|
public function getActionName() {
|
|
return pht('Commandeered');
|
|
}
|
|
|
|
public function getCommandKeyword() {
|
|
return 'commandeer';
|
|
}
|
|
|
|
public function getCommandAliases() {
|
|
return array(
|
|
'claim',
|
|
);
|
|
}
|
|
|
|
public function getCommandSummary() {
|
|
return pht('Commandeer a revision.');
|
|
}
|
|
|
|
public function generateOldValue($object) {
|
|
return $object->getAuthorPHID();
|
|
}
|
|
|
|
public function generateNewValue($object, $value) {
|
|
$actor = $this->getActor();
|
|
return $actor->getPHID();
|
|
}
|
|
|
|
public function applyInternalEffects($object, $value) {
|
|
$object->setAuthorPHID($value);
|
|
}
|
|
|
|
protected function validateAction($object, PhabricatorUser $viewer) {
|
|
if ($object->isClosed()) {
|
|
throw new Exception(
|
|
pht(
|
|
'You can not commandeer this revision because it has already '.
|
|
'been closed. You can only commandeer open revisions.'));
|
|
}
|
|
|
|
if ($object->isDraft()) {
|
|
throw new Exception(
|
|
pht('You can not commandeer a draft revision.'));
|
|
}
|
|
|
|
if ($this->isViewerRevisionAuthor($object, $viewer)) {
|
|
throw new Exception(
|
|
pht(
|
|
'You can not commandeer this revision because you are already '.
|
|
'the author.'));
|
|
}
|
|
}
|
|
|
|
public function getTitle() {
|
|
return pht(
|
|
'%s commandeered this revision.',
|
|
$this->renderAuthor());
|
|
}
|
|
|
|
public function getTitleForFeed() {
|
|
return pht(
|
|
'%s commandeered %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderObject());
|
|
}
|
|
|
|
}
|