From 4d32c990ab3e5dcecc34a06b7f87aef1eb16603e Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 6 Apr 2016 06:22:44 -0700 Subject: [PATCH] Allow stacked comment actions to be explicitly ordered Summary: Ref T6027. Normally, actions use the same order as the form, but in some cases (like moving stuff on workboards) it makes sense to reorder them explicitly. Pin "Move on board" near the bottom, and "projects/subscribers" at the bottom. I think these are generally reasonable rules in all cases. Test Plan: Opened menu, saw slightly better action order. Reviewers: chad Reviewed By: chad Maniphest Tasks: T6027 Differential Revision: https://secure.phabricator.com/D15639 --- .../maniphest/editor/ManiphestEditEngine.php | 1 + .../PhabricatorProjectsEditEngineExtension.php | 1 + ...habricatorSubscriptionsEditEngineExtension.php | 1 + .../PhabricatorEditEngineCommentAction.php | 15 +++++++++++++++ .../editengine/PhabricatorEditEngine.php | 2 ++ .../editfield/PhabricatorEditField.php | 13 ++++++++++++- 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php index d49851cdfd..58606538ca 100644 --- a/src/applications/maniphest/editor/ManiphestEditEngine.php +++ b/src/applications/maniphest/editor/ManiphestEditEngine.php @@ -163,6 +163,7 @@ EODOCS ->setIsDefaultable(false) ->setIsLockable(false) ->setCommentActionLabel(pht('Move on Workboard')) + ->setCommentActionOrder(2000) ->setColumnMap($column_map), id(new PhabricatorTextEditField()) ->setKey('title') diff --git a/src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php b/src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php index cd481946b2..ce9fbf332c 100644 --- a/src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php +++ b/src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php @@ -50,6 +50,7 @@ final class PhabricatorProjectsEditEngineExtension ->setIsCopyable(true) ->setUseEdgeTransactions(true) ->setCommentActionLabel(pht('Change Project Tags')) + ->setCommentActionOrder(8000) ->setDescription(pht('Select project tags for the object.')) ->setTransactionType($edge_type) ->setMetadataValue('edge:type', $project_edge_type) diff --git a/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php b/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php index 19b9281d02..a0a6cbf7be 100644 --- a/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php +++ b/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php @@ -45,6 +45,7 @@ final class PhabricatorSubscriptionsEditEngineExtension ->setIsCopyable(true) ->setUseEdgeTransactions(true) ->setCommentActionLabel(pht('Change Subscribers')) + ->setCommentActionOrder(9000) ->setDescription(pht('Choose subscribers.')) ->setTransactionType($subscribers_type) ->setValue($sub_phids); diff --git a/src/applications/transactions/commentaction/PhabricatorEditEngineCommentAction.php b/src/applications/transactions/commentaction/PhabricatorEditEngineCommentAction.php index 548039ce15..dc676630ba 100644 --- a/src/applications/transactions/commentaction/PhabricatorEditEngineCommentAction.php +++ b/src/applications/transactions/commentaction/PhabricatorEditEngineCommentAction.php @@ -6,6 +6,7 @@ abstract class PhabricatorEditEngineCommentAction extends Phobject { private $label; private $value; private $initialValue; + private $order; abstract public function getPHUIXControlType(); abstract public function getPHUIXControlSpecification(); @@ -37,6 +38,20 @@ abstract class PhabricatorEditEngineCommentAction extends Phobject { return $this->value; } + public function setOrder($order) { + $this->order = $order; + return $this; + } + + public function getOrder() { + return $this->order; + } + + public function getSortVector() { + return id(new PhutilSortVector()) + ->addInt($this->getOrder()); + } + public function setInitialValue($initial_value) { $this->initialValue = $initial_value; return $this; diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php index 9655a83e65..185ac13a5a 100644 --- a/src/applications/transactions/editengine/PhabricatorEditEngine.php +++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php @@ -1382,6 +1382,8 @@ abstract class PhabricatorEditEngine $comment_actions[$key] = $comment_action; } + $comment_actions = msortv($comment_actions, 'getSortVector'); + $view->setCommentActions($comment_actions); return $view; diff --git a/src/applications/transactions/editfield/PhabricatorEditField.php b/src/applications/transactions/editfield/PhabricatorEditField.php index 1216370819..3b4c4e264b 100644 --- a/src/applications/transactions/editfield/PhabricatorEditField.php +++ b/src/applications/transactions/editfield/PhabricatorEditField.php @@ -24,6 +24,7 @@ abstract class PhabricatorEditField extends Phobject { private $commentActionLabel; private $commentActionValue; + private $commentActionOrder = 1000; private $hasCommentActionValue; private $isLocked; @@ -243,6 +244,15 @@ abstract class PhabricatorEditField extends Phobject { return $this->commentActionLabel; } + public function setCommentActionOrder($order) { + $this->commentActionOrder = $order; + return $this; + } + + public function getCommentActionOrder() { + return $this->commentActionOrder; + } + public function setCommentActionValue($comment_action_value) { $this->hasCommentActionValue = true; $this->commentActionValue = $comment_action_value; @@ -686,7 +696,8 @@ abstract class PhabricatorEditField extends Phobject { $action ->setKey($this->getKey()) ->setLabel($label) - ->setValue($this->getValueForCommentAction($value)); + ->setValue($this->getValueForCommentAction($value)) + ->setOrder($this->getCommentActionOrder()); return $action; }