@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a "Change priority to: ..." Herald action

Summary:
Ref T7848. This is a companion to "Change status to: ...".

(I'm pretty sure the only reason I didn't originally write these was the tokenizer bug in D14682, I just forgot about it).

This is basically a copy/paste of the "status" action.

Test Plan:
- Wrote a rule to change task priorities.
- Edited a task.
- Saw rule fire properly.
- Tokens also stick around correctly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7848

Differential Revision: https://secure.phabricator.com/D14683

+89
+2
src/__phutil_library_map__.php
··· 1314 1314 'ManiphestTaskPHIDType' => 'applications/maniphest/phid/ManiphestTaskPHIDType.php', 1315 1315 'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php', 1316 1316 'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php', 1317 + 'ManiphestTaskPriorityHeraldAction' => 'applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php', 1317 1318 'ManiphestTaskPriorityHeraldField' => 'applications/maniphest/herald/ManiphestTaskPriorityHeraldField.php', 1318 1319 'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php', 1319 1320 'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php', ··· 5307 5308 'ManiphestTaskPHIDType' => 'PhabricatorPHIDType', 5308 5309 'ManiphestTaskPriority' => 'ManiphestConstants', 5309 5310 'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource', 5311 + 'ManiphestTaskPriorityHeraldAction' => 'HeraldAction', 5310 5312 'ManiphestTaskPriorityHeraldField' => 'ManiphestTaskHeraldField', 5311 5313 'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 5312 5314 'ManiphestTaskResultListView' => 'ManiphestView',
+87
src/applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php
··· 1 + <?php 2 + 3 + final class ManiphestTaskPriorityHeraldAction 4 + extends HeraldAction { 5 + 6 + const ACTIONCONST = 'maniphest.priority'; 7 + const DO_PRIORITY = 'do.priority'; 8 + 9 + public function supportsObject($object) { 10 + return ($object instanceof ManiphestTask); 11 + } 12 + 13 + public function getActionGroupKey() { 14 + return HeraldApplicationActionGroup::ACTIONGROUPKEY; 15 + } 16 + 17 + public function getHeraldActionName() { 18 + return pht('Change priority to'); 19 + } 20 + 21 + public function supportsRuleType($rule_type) { 22 + return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); 23 + } 24 + 25 + public function applyEffect($object, HeraldEffect $effect) { 26 + $priority = head($effect->getTarget()); 27 + 28 + if (!$priority) { 29 + $this->logEffect(self::DO_STANDARD_EMPTY); 30 + return; 31 + } 32 + 33 + $adapter = $this->getAdapter(); 34 + $object = $adapter->getObject(); 35 + $current = $object->getPriority(); 36 + 37 + if ($current == $priority) { 38 + $this->logEffect(self::DO_STANDARD_NO_EFFECT, $priority); 39 + return; 40 + } 41 + 42 + $xaction = $adapter->newTransaction() 43 + ->setTransactionType(ManiphestTransaction::TYPE_PRIORITY) 44 + ->setNewValue($priority); 45 + 46 + $adapter->queueTransaction($xaction); 47 + $this->logEffect(self::DO_PRIORITY, $priority); 48 + } 49 + 50 + public function getHeraldActionStandardType() { 51 + return self::STANDARD_PHID_LIST; 52 + } 53 + 54 + public function renderActionDescription($value) { 55 + $priority = head($value); 56 + $name = ManiphestTaskPriority::getTaskPriorityName($priority); 57 + return pht('Change priority to: %s.', $name); 58 + } 59 + 60 + protected function getDatasource() { 61 + return new ManiphestTaskPriorityDatasource(); 62 + } 63 + 64 + protected function getDatasourceValueMap() { 65 + return ManiphestTaskPriority::getTaskPriorityMap(); 66 + } 67 + 68 + protected function getActionEffectMap() { 69 + return array( 70 + self::DO_PRIORITY => array( 71 + 'icon' => 'fa-pencil', 72 + 'color' => 'green', 73 + 'name' => pht('Changed Task Priority'), 74 + ), 75 + ); 76 + } 77 + 78 + protected function renderActionEffectDescription($type, $data) { 79 + switch ($type) { 80 + case self::DO_PRIORITY: 81 + return pht( 82 + 'Changed task priority to "%s".', 83 + ManiphestTaskPriority::getTaskPriorityName($data)); 84 + } 85 + } 86 + 87 + }