mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Order actions sensibly within Differential revision comment action groups
Summary: Ref T11114. See D17114 for some discussion. For review actions: accept, reject, resign. For revision actions, order is basically least-severe to most-severe action pairs: plan changes, request review, close, reopen, abandon, reclaim, commandeer. Test Plan: Viewed revisions as an author and a reviewer, saw sensible action order within action groups. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114 Differential Revision: https://secure.phabricator.com/D17115
This commit is contained in:
parent
48fcfeadaf
commit
f7b5955d33
13 changed files with 63 additions and 0 deletions
|
@ -229,6 +229,8 @@ final class DifferentialRevisionEditEngine
|
||||||
->setValue(array());
|
->setValue(array());
|
||||||
|
|
||||||
$actions = DifferentialRevisionActionTransaction::loadAllActions();
|
$actions = DifferentialRevisionActionTransaction::loadAllActions();
|
||||||
|
$actions = msortv($actions, 'getRevisionActionOrderVector');
|
||||||
|
|
||||||
foreach ($actions as $key => $action) {
|
foreach ($actions as $key => $action) {
|
||||||
$fields[] = $action->newEditField($object, $viewer);
|
$fields[] = $action->newEditField($object, $viewer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -447,6 +447,11 @@ final class DifferentialRevision extends DifferentialDAO
|
||||||
return ($this->getStatus() == $status_abandoned);
|
return ($this->getStatus() == $status_abandoned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAccepted() {
|
||||||
|
$status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
|
||||||
|
return ($this->getStatus() == $status_accepted);
|
||||||
|
}
|
||||||
|
|
||||||
public function getStatusIcon() {
|
public function getStatusIcon() {
|
||||||
$map = array(
|
$map = array(
|
||||||
ArcanistDifferentialRevisionStatus::NEEDS_REVIEW
|
ArcanistDifferentialRevisionStatus::NEEDS_REVIEW
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class DifferentialRevisionAbandonTransaction
|
||||||
return 'indigo';
|
return 'indigo';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
return $object->isAbandoned();
|
return $object->isAbandoned();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class DifferentialRevisionAcceptTransaction
|
||||||
return 'green';
|
return 'green';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
$actor = $this->getActor();
|
$actor = $this->getActor();
|
||||||
return $this->isViewerAcceptingReviewer($object, $actor);
|
return $this->isViewerAcceptingReviewer($object, $actor);
|
||||||
|
|
|
@ -19,6 +19,15 @@ abstract class DifferentialRevisionActionTransaction
|
||||||
abstract protected function validateAction($object, PhabricatorUser $viewer);
|
abstract protected function validateAction($object, PhabricatorUser $viewer);
|
||||||
abstract protected function getRevisionActionLabel();
|
abstract protected function getRevisionActionLabel();
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRevisionActionOrderVector() {
|
||||||
|
return id(new PhutilSortVector())
|
||||||
|
->addInt($this->getRevisionActionOrder());
|
||||||
|
}
|
||||||
|
|
||||||
protected function getRevisionActionGroupKey() {
|
protected function getRevisionActionGroupKey() {
|
||||||
return DifferentialRevisionEditEngine::ACTIONGROUP_REVISION;
|
return DifferentialRevisionEditEngine::ACTIONGROUP_REVISION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class DifferentialRevisionCloseTransaction
|
||||||
return 'indigo';
|
return 'indigo';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 300;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
return $object->isClosed();
|
return $object->isClosed();
|
||||||
}
|
}
|
||||||
|
@ -49,6 +53,13 @@ final class DifferentialRevisionCloseTransaction
|
||||||
'closed. Only open revisions can be closed.'));
|
'closed. Only open revisions can be closed.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$object->isAccepted()) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'You can not close this revision because it has not been accepted. '.
|
||||||
|
'Revisions must be accepted before they can be closed.'));
|
||||||
|
}
|
||||||
|
|
||||||
$config_key = 'differential.always-allow-close';
|
$config_key = 'differential.always-allow-close';
|
||||||
if (!PhabricatorEnv::getEnvConfig($config_key)) {
|
if (!PhabricatorEnv::getEnvConfig($config_key)) {
|
||||||
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
|
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class DifferentialRevisionCommandeerTransaction
|
||||||
return 'sky';
|
return 'sky';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 700;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
return $object->getAuthorPHID();
|
return $object->getAuthorPHID();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,10 @@ final class DifferentialRevisionPlanChangesTransaction
|
||||||
return 'red';
|
return 'red';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
$status_planned = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED;
|
$status_planned = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED;
|
||||||
return ($object->getStatus() == $status_planned);
|
return ($object->getStatus() == $status_planned);
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class DifferentialRevisionReclaimTransaction
|
||||||
return 'sky';
|
return 'sky';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 600;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
return !$object->isAbandoned();
|
return !$object->isAbandoned();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class DifferentialRevisionRejectTransaction
|
||||||
return 'red';
|
return 'red';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 600;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
$actor = $this->getActor();
|
$actor = $this->getActor();
|
||||||
return $this->isViewerRejectingReviewer($object, $actor);
|
return $this->isViewerRejectingReviewer($object, $actor);
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class DifferentialRevisionReopenTransaction
|
||||||
return 'sky';
|
return 'sky';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 400;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
return !$object->isClosed();
|
return !$object->isClosed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,10 @@ final class DifferentialRevisionRequestReviewTransaction
|
||||||
return 'sky';
|
return 'sky';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
$status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
|
$status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
|
||||||
return ($object->getStatus() == $status_review);
|
return ($object->getStatus() == $status_review);
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class DifferentialRevisionResignTransaction
|
||||||
return 'orange';
|
return 'orange';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRevisionActionOrder() {
|
||||||
|
return 700;
|
||||||
|
}
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
$actor = $this->getActor();
|
$actor = $this->getActor();
|
||||||
return !$this->isViewerAnyReviewer($object, $actor);
|
return !$this->isViewerAnyReviewer($object, $actor);
|
||||||
|
|
Loading…
Reference in a new issue