Page MenuHomePhabricator

D14683.diff
No OneTemporary

D14683.diff

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
@@ -1314,6 +1314,7 @@
'ManiphestTaskPHIDType' => 'applications/maniphest/phid/ManiphestTaskPHIDType.php',
'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php',
'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php',
+ 'ManiphestTaskPriorityHeraldAction' => 'applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php',
'ManiphestTaskPriorityHeraldField' => 'applications/maniphest/herald/ManiphestTaskPriorityHeraldField.php',
'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php',
'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php',
@@ -5307,6 +5308,7 @@
'ManiphestTaskPHIDType' => 'PhabricatorPHIDType',
'ManiphestTaskPriority' => 'ManiphestConstants',
'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource',
+ 'ManiphestTaskPriorityHeraldAction' => 'HeraldAction',
'ManiphestTaskPriorityHeraldField' => 'ManiphestTaskHeraldField',
'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'ManiphestTaskResultListView' => 'ManiphestView',
diff --git a/src/applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php b/src/applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php
@@ -0,0 +1,87 @@
+<?php
+
+final class ManiphestTaskPriorityHeraldAction
+ extends HeraldAction {
+
+ const ACTIONCONST = 'maniphest.priority';
+ const DO_PRIORITY = 'do.priority';
+
+ public function supportsObject($object) {
+ return ($object instanceof ManiphestTask);
+ }
+
+ public function getActionGroupKey() {
+ return HeraldApplicationActionGroup::ACTIONGROUPKEY;
+ }
+
+ public function getHeraldActionName() {
+ return pht('Change priority to');
+ }
+
+ public function supportsRuleType($rule_type) {
+ return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
+ }
+
+ public function applyEffect($object, HeraldEffect $effect) {
+ $priority = head($effect->getTarget());
+
+ if (!$priority) {
+ $this->logEffect(self::DO_STANDARD_EMPTY);
+ return;
+ }
+
+ $adapter = $this->getAdapter();
+ $object = $adapter->getObject();
+ $current = $object->getPriority();
+
+ if ($current == $priority) {
+ $this->logEffect(self::DO_STANDARD_NO_EFFECT, $priority);
+ return;
+ }
+
+ $xaction = $adapter->newTransaction()
+ ->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)
+ ->setNewValue($priority);
+
+ $adapter->queueTransaction($xaction);
+ $this->logEffect(self::DO_PRIORITY, $priority);
+ }
+
+ public function getHeraldActionStandardType() {
+ return self::STANDARD_PHID_LIST;
+ }
+
+ public function renderActionDescription($value) {
+ $priority = head($value);
+ $name = ManiphestTaskPriority::getTaskPriorityName($priority);
+ return pht('Change priority to: %s.', $name);
+ }
+
+ protected function getDatasource() {
+ return new ManiphestTaskPriorityDatasource();
+ }
+
+ protected function getDatasourceValueMap() {
+ return ManiphestTaskPriority::getTaskPriorityMap();
+ }
+
+ protected function getActionEffectMap() {
+ return array(
+ self::DO_PRIORITY => array(
+ 'icon' => 'fa-pencil',
+ 'color' => 'green',
+ 'name' => pht('Changed Task Priority'),
+ ),
+ );
+ }
+
+ protected function renderActionEffectDescription($type, $data) {
+ switch ($type) {
+ case self::DO_PRIORITY:
+ return pht(
+ 'Changed task priority to "%s".',
+ ManiphestTaskPriority::getTaskPriorityName($data));
+ }
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 13, 5:48 AM (6 d, 9 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714641
Default Alt Text
D14683.diff (3 KB)

Event Timeline