@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.

Herald support for changing task status

Summary:
Ref T7848. This patch is incomplete and has the following issues:

- Multiple statuses can be entered on the edit rule page (only the first one is used).
- Statuses are not rendered correctly when re-editing a rule.

Test Plan: Applied to our local phab instance and verified it works with our task workflow.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: joshuaspence, revi, epriestley, jsmith

Maniphest Tasks: T7848

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

authored by

Jason Smith and committed by
epriestley
a77bf877 77d33ec7

+89
+2
src/__phutil_library_map__.php
··· 1321 1321 'ManiphestTaskStatus' => 'applications/maniphest/constants/ManiphestTaskStatus.php', 1322 1322 'ManiphestTaskStatusDatasource' => 'applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php', 1323 1323 'ManiphestTaskStatusFunctionDatasource' => 'applications/maniphest/typeahead/ManiphestTaskStatusFunctionDatasource.php', 1324 + 'ManiphestTaskStatusHeraldAction' => 'applications/maniphest/herald/ManiphestTaskStatusHeraldAction.php', 1324 1325 'ManiphestTaskStatusHeraldField' => 'applications/maniphest/herald/ManiphestTaskStatusHeraldField.php', 1325 1326 'ManiphestTaskStatusTestCase' => 'applications/maniphest/constants/__tests__/ManiphestTaskStatusTestCase.php', 1326 1327 'ManiphestTaskTestCase' => 'applications/maniphest/__tests__/ManiphestTaskTestCase.php', ··· 5313 5314 'ManiphestTaskStatus' => 'ManiphestConstants', 5314 5315 'ManiphestTaskStatusDatasource' => 'PhabricatorTypeaheadDatasource', 5315 5316 'ManiphestTaskStatusFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 5317 + 'ManiphestTaskStatusHeraldAction' => 'HeraldAction', 5316 5318 'ManiphestTaskStatusHeraldField' => 'ManiphestTaskHeraldField', 5317 5319 'ManiphestTaskStatusTestCase' => 'PhabricatorTestCase', 5318 5320 'ManiphestTaskTestCase' => 'PhabricatorTestCase',
+87
src/applications/maniphest/herald/ManiphestTaskStatusHeraldAction.php
··· 1 + <?php 2 + 3 + final class ManiphestTaskStatusHeraldAction 4 + extends HeraldAction { 5 + 6 + const ACTIONCONST = 'maniphest.status'; 7 + const DO_STATUS = 'do.status'; 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 status 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 + $status = head($effect->getTarget()); 27 + 28 + if (!$status) { 29 + $this->logEffect(self::DO_STANDARD_EMPTY); 30 + return; 31 + } 32 + 33 + $adapter = $this->getAdapter(); 34 + $object = $adapter->getObject(); 35 + $current = $object->getStatus(); 36 + 37 + if ($current == $status) { 38 + $this->logEffect(self::DO_STANDARD_NO_EFFECT, $status); 39 + return; 40 + } 41 + 42 + $xaction = $adapter->newTransaction() 43 + ->setTransactionType(ManiphestTransaction::TYPE_STATUS) 44 + ->setNewValue($status); 45 + 46 + $adapter->queueTransaction($xaction); 47 + $this->logEffect(self::DO_STATUS, $status); 48 + } 49 + 50 + public function getHeraldActionStandardType() { 51 + return self::STANDARD_PHID_LIST; 52 + } 53 + 54 + public function renderActionDescription($value) { 55 + $status = head($value); 56 + $name = ManiphestTaskStatus::getTaskStatusName($status); 57 + return pht('Change status to: %s.', $name); 58 + } 59 + 60 + protected function getDatasource() { 61 + return new ManiphestTaskStatusDatasource(); 62 + } 63 + 64 + protected function getDatasourceValueMap() { 65 + return ManiphestTaskStatus::getTaskStatusMap(); 66 + } 67 + 68 + protected function getActionEffectMap() { 69 + return array( 70 + self::DO_STATUS => array( 71 + 'icon' => 'fa-pencil', 72 + 'color' => 'green', 73 + 'name' => pht('Changed Task Status'), 74 + ), 75 + ); 76 + } 77 + 78 + protected function renderActionEffectDescription($type, $data) { 79 + switch ($type) { 80 + case self::DO_STATUS: 81 + return pht( 82 + 'Changed task status to "%s".', 83 + ManiphestTaskStatus::getTaskStatusName($data)); 84 + } 85 + } 86 + 87 + }