mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Restore "Close" and "Reopen" actions to Differential on EditEngine
Summary: Ref T11114. This restores these actions as selectable in the comment area. This does not implement one special rule ("Closing a revision in response to a commit is OK from any status.") but I have a note about that separately. Test Plan: Closed and reopened revisions. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114 Differential Revision: https://secure.phabricator.com/D17108
This commit is contained in:
parent
3c5a17ba8a
commit
a90ab7f403
4 changed files with 151 additions and 1 deletions
|
@ -511,6 +511,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionAuthorHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorHeraldField.php',
|
'DifferentialRevisionAuthorHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorHeraldField.php',
|
||||||
'DifferentialRevisionAuthorProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php',
|
'DifferentialRevisionAuthorProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php',
|
||||||
'DifferentialRevisionCloseDetailsController' => 'applications/differential/controller/DifferentialRevisionCloseDetailsController.php',
|
'DifferentialRevisionCloseDetailsController' => 'applications/differential/controller/DifferentialRevisionCloseDetailsController.php',
|
||||||
|
'DifferentialRevisionCloseTransaction' => 'applications/differential/xaction/DifferentialRevisionCloseTransaction.php',
|
||||||
'DifferentialRevisionContentAddedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php',
|
'DifferentialRevisionContentAddedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php',
|
||||||
'DifferentialRevisionContentHeraldField' => 'applications/differential/herald/DifferentialRevisionContentHeraldField.php',
|
'DifferentialRevisionContentHeraldField' => 'applications/differential/herald/DifferentialRevisionContentHeraldField.php',
|
||||||
'DifferentialRevisionContentRemovedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php',
|
'DifferentialRevisionContentRemovedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php',
|
||||||
|
@ -544,6 +545,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionReclaimTransaction' => 'applications/differential/xaction/DifferentialRevisionReclaimTransaction.php',
|
'DifferentialRevisionReclaimTransaction' => 'applications/differential/xaction/DifferentialRevisionReclaimTransaction.php',
|
||||||
'DifferentialRevisionRelationship' => 'applications/differential/relationships/DifferentialRevisionRelationship.php',
|
'DifferentialRevisionRelationship' => 'applications/differential/relationships/DifferentialRevisionRelationship.php',
|
||||||
'DifferentialRevisionRelationshipSource' => 'applications/search/relationship/DifferentialRevisionRelationshipSource.php',
|
'DifferentialRevisionRelationshipSource' => 'applications/search/relationship/DifferentialRevisionRelationshipSource.php',
|
||||||
|
'DifferentialRevisionReopenTransaction' => 'applications/differential/xaction/DifferentialRevisionReopenTransaction.php',
|
||||||
'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php',
|
'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php',
|
||||||
'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php',
|
'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php',
|
||||||
'DifferentialRevisionRepositoryTransaction' => 'applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php',
|
'DifferentialRevisionRepositoryTransaction' => 'applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php',
|
||||||
|
@ -5180,6 +5182,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionAuthorHeraldField' => 'DifferentialRevisionHeraldField',
|
'DifferentialRevisionAuthorHeraldField' => 'DifferentialRevisionHeraldField',
|
||||||
'DifferentialRevisionAuthorProjectsHeraldField' => 'DifferentialRevisionHeraldField',
|
'DifferentialRevisionAuthorProjectsHeraldField' => 'DifferentialRevisionHeraldField',
|
||||||
'DifferentialRevisionCloseDetailsController' => 'DifferentialController',
|
'DifferentialRevisionCloseDetailsController' => 'DifferentialController',
|
||||||
|
'DifferentialRevisionCloseTransaction' => 'DifferentialRevisionActionTransaction',
|
||||||
'DifferentialRevisionContentAddedHeraldField' => 'DifferentialRevisionHeraldField',
|
'DifferentialRevisionContentAddedHeraldField' => 'DifferentialRevisionHeraldField',
|
||||||
'DifferentialRevisionContentHeraldField' => 'DifferentialRevisionHeraldField',
|
'DifferentialRevisionContentHeraldField' => 'DifferentialRevisionHeraldField',
|
||||||
'DifferentialRevisionContentRemovedHeraldField' => 'DifferentialRevisionHeraldField',
|
'DifferentialRevisionContentRemovedHeraldField' => 'DifferentialRevisionHeraldField',
|
||||||
|
@ -5213,6 +5216,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionReclaimTransaction' => 'DifferentialRevisionActionTransaction',
|
'DifferentialRevisionReclaimTransaction' => 'DifferentialRevisionActionTransaction',
|
||||||
'DifferentialRevisionRelationship' => 'PhabricatorObjectRelationship',
|
'DifferentialRevisionRelationship' => 'PhabricatorObjectRelationship',
|
||||||
'DifferentialRevisionRelationshipSource' => 'PhabricatorObjectRelationshipSource',
|
'DifferentialRevisionRelationshipSource' => 'PhabricatorObjectRelationshipSource',
|
||||||
|
'DifferentialRevisionReopenTransaction' => 'DifferentialRevisionActionTransaction',
|
||||||
'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField',
|
'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField',
|
||||||
'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField',
|
'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField',
|
||||||
'DifferentialRevisionRepositoryTransaction' => 'DifferentialRevisionTransactionType',
|
'DifferentialRevisionRepositoryTransaction' => 'DifferentialRevisionTransactionType',
|
||||||
|
|
|
@ -45,7 +45,7 @@ final class DifferentialRevisionAbandonTransaction
|
||||||
pht(
|
pht(
|
||||||
'You can not abandon this revision because you are not the '.
|
'You can not abandon this revision because you are not the '.
|
||||||
'author. You can only abandon revisions you own. You can change '.
|
'author. You can only abandon revisions you own. You can change '.
|
||||||
'this behavior by adjusting the "%s" setting in Config',
|
'this behavior by adjusting the "%s" setting in Config.',
|
||||||
$config_key));
|
$config_key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialRevisionCloseTransaction
|
||||||
|
extends DifferentialRevisionActionTransaction {
|
||||||
|
|
||||||
|
const TRANSACTIONTYPE = 'differential.revision.close';
|
||||||
|
const ACTIONKEY = 'close';
|
||||||
|
|
||||||
|
protected function getRevisionActionLabel() {
|
||||||
|
return pht('Close Revision');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionDescription() {
|
||||||
|
return pht('This revision will be closed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIcon() {
|
||||||
|
return 'fa-check';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColor() {
|
||||||
|
return 'indigo';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateOldValue($object) {
|
||||||
|
return $object->isClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyInternalEffects($object, $value) {
|
||||||
|
$status_closed = ArcanistDifferentialRevisionStatus::CLOSED;
|
||||||
|
$status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
|
||||||
|
|
||||||
|
$old_status = $object->getStatus();
|
||||||
|
|
||||||
|
$object->setStatus($status_closed);
|
||||||
|
|
||||||
|
$was_accepted = ($old_status == $status_accepted);
|
||||||
|
|
||||||
|
$object->setProperty(
|
||||||
|
DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED,
|
||||||
|
$was_accepted);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function validateAction($object, PhabricatorUser $viewer) {
|
||||||
|
if ($object->isClosed()) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'You can not close this revision because it has already been '.
|
||||||
|
'closed. Only open revisions can be closed.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$config_key = 'differential.always-allow-close';
|
||||||
|
if (!PhabricatorEnv::getEnvConfig($config_key)) {
|
||||||
|
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'You can not close this revision because you are not the '.
|
||||||
|
'author. You can only close revisions you own. You can change '.
|
||||||
|
'this behavior by adjusting the "%s" setting in Config.',
|
||||||
|
$config_key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle() {
|
||||||
|
return pht(
|
||||||
|
'%s closed this revision.',
|
||||||
|
$this->renderAuthor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitleForFeed() {
|
||||||
|
return pht(
|
||||||
|
'%s closed %s.',
|
||||||
|
$this->renderAuthor(),
|
||||||
|
$this->renderObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialRevisionReopenTransaction
|
||||||
|
extends DifferentialRevisionActionTransaction {
|
||||||
|
|
||||||
|
const TRANSACTIONTYPE = 'differential.revision.reopen';
|
||||||
|
const ACTIONKEY = 'reopen';
|
||||||
|
|
||||||
|
protected function getRevisionActionLabel() {
|
||||||
|
return pht('Reopen Revision');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionDescription() {
|
||||||
|
return pht('This revision will be reopened for review.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIcon() {
|
||||||
|
return 'fa-bullhorn';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColor() {
|
||||||
|
return 'sky';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateOldValue($object) {
|
||||||
|
return !$object->isClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyInternalEffects($object, $value) {
|
||||||
|
$object->setStatus(ArcanistDifferentialRevisionStatus::NEEDS_REVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function validateAction($object, PhabricatorUser $viewer) {
|
||||||
|
// Note that we're testing for "Closed", exactly, not just any closed
|
||||||
|
// status.
|
||||||
|
$status_closed = ArcanistDifferentialRevisionStatus::CLOSED;
|
||||||
|
if ($object->getStatus() != $status_closed) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'You can not reopen this revision because it is not closed. '.
|
||||||
|
'Only closed revisions can be reopened.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$config_key = 'differential.allow-reopen';
|
||||||
|
if (!PhabricatorEnv::getEnvConfig($config_key)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'You can not reopen this revision because configuration prevents '.
|
||||||
|
'any revision from being reopened. You can change this behavior '.
|
||||||
|
'by adjusting the "%s" setting in Config.',
|
||||||
|
$config_key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle() {
|
||||||
|
return pht(
|
||||||
|
'%s reopened this revision.',
|
||||||
|
$this->renderAuthor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitleForFeed() {
|
||||||
|
return pht(
|
||||||
|
'%s reopened %s.',
|
||||||
|
$this->renderAuthor(),
|
||||||
|
$this->renderObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue