Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14440536
D17108.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D17108.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -511,6 +511,7 @@
'DifferentialRevisionAuthorHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorHeraldField.php',
'DifferentialRevisionAuthorProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php',
'DifferentialRevisionCloseDetailsController' => 'applications/differential/controller/DifferentialRevisionCloseDetailsController.php',
+ 'DifferentialRevisionCloseTransaction' => 'applications/differential/xaction/DifferentialRevisionCloseTransaction.php',
'DifferentialRevisionContentAddedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php',
'DifferentialRevisionContentHeraldField' => 'applications/differential/herald/DifferentialRevisionContentHeraldField.php',
'DifferentialRevisionContentRemovedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php',
@@ -544,6 +545,7 @@
'DifferentialRevisionReclaimTransaction' => 'applications/differential/xaction/DifferentialRevisionReclaimTransaction.php',
'DifferentialRevisionRelationship' => 'applications/differential/relationships/DifferentialRevisionRelationship.php',
'DifferentialRevisionRelationshipSource' => 'applications/search/relationship/DifferentialRevisionRelationshipSource.php',
+ 'DifferentialRevisionReopenTransaction' => 'applications/differential/xaction/DifferentialRevisionReopenTransaction.php',
'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php',
'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php',
'DifferentialRevisionRepositoryTransaction' => 'applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php',
@@ -5180,6 +5182,7 @@
'DifferentialRevisionAuthorHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionAuthorProjectsHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionCloseDetailsController' => 'DifferentialController',
+ 'DifferentialRevisionCloseTransaction' => 'DifferentialRevisionActionTransaction',
'DifferentialRevisionContentAddedHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionContentHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionContentRemovedHeraldField' => 'DifferentialRevisionHeraldField',
@@ -5213,6 +5216,7 @@
'DifferentialRevisionReclaimTransaction' => 'DifferentialRevisionActionTransaction',
'DifferentialRevisionRelationship' => 'PhabricatorObjectRelationship',
'DifferentialRevisionRelationshipSource' => 'PhabricatorObjectRelationshipSource',
+ 'DifferentialRevisionReopenTransaction' => 'DifferentialRevisionActionTransaction',
'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionRepositoryTransaction' => 'DifferentialRevisionTransactionType',
diff --git a/src/applications/differential/xaction/DifferentialRevisionAbandonTransaction.php b/src/applications/differential/xaction/DifferentialRevisionAbandonTransaction.php
--- a/src/applications/differential/xaction/DifferentialRevisionAbandonTransaction.php
+++ b/src/applications/differential/xaction/DifferentialRevisionAbandonTransaction.php
@@ -45,7 +45,7 @@
pht(
'You can not abandon this revision because you are not the '.
'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));
}
}
diff --git a/src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php b/src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
@@ -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());
+ }
+
+}
diff --git a/src/applications/differential/xaction/DifferentialRevisionReopenTransaction.php b/src/applications/differential/xaction/DifferentialRevisionReopenTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/xaction/DifferentialRevisionReopenTransaction.php
@@ -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());
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 27, 5:31 AM (10 h, 55 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6931138
Default Alt Text
D17108.diff (8 KB)
Attached To
Mode
D17108: Restore "Close" and "Reopen" actions to Differential on EditEngine
Attached
Detach File
Event Timeline
Log In to Comment