@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 actions: Allow setting subtype on Maniphest tasks

Summary:
https://secure.phabricator.com/T12314 introduced task subtypes. Allow Herald rules which change/set the subtype of a task.
Code originally written by @20after4 for Wikimedia.

Closes T16022

Test Plan:
1. Have the default subtype configuration with three types under http://phorge.localhost/config/edit/maniphest.subtypes/ defined in src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
2. Go to http://phorge.localhost/herald/edit/?content_type=HeraldManiphestTaskAdapter&rule_type=global
3. Under "Action", select the new "Change subtype to" option. Test the subtype search by clicking the magnifier icon, set up a Herald rule to test execution.
4. Remove the config for http://phorge.localhost/config/edit/maniphest.subtypes/
5. Repeat step 3, no explosions, default "Task" subtype still exists after removing the config.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, 20after4, Cigaryno

Maniphest Tasks: T16022

Differential Revision: https://we.phorge.it/D25913

+76
+2
src/__phutil_library_map__.php
··· 5899 5899 'RemarkupValue' => 'applications/remarkup/RemarkupValue.php', 5900 5900 'RepositoryConduitAPIMethod' => 'applications/repository/conduit/RepositoryConduitAPIMethod.php', 5901 5901 'RepositoryQueryConduitAPIMethod' => 'applications/repository/conduit/RepositoryQueryConduitAPIMethod.php', 5902 + 'SetSubtypeHeraldAction' => 'applications/maniphest/herald/SetSubtypeHeraldAction.php', 5902 5903 'ShellLogView' => 'applications/harbormaster/view/ShellLogView.php', 5903 5904 'SlowvoteConduitAPIMethod' => 'applications/slowvote/conduit/SlowvoteConduitAPIMethod.php', 5904 5905 'SlowvoteEmbedView' => 'applications/slowvote/view/SlowvoteEmbedView.php', ··· 12836 12837 'RemarkupValue' => 'Phobject', 12837 12838 'RepositoryConduitAPIMethod' => 'ConduitAPIMethod', 12838 12839 'RepositoryQueryConduitAPIMethod' => 'RepositoryConduitAPIMethod', 12840 + 'SetSubtypeHeraldAction' => 'HeraldAction', 12839 12841 'ShellLogView' => 'AphrontView', 12840 12842 'SlowvoteConduitAPIMethod' => 'ConduitAPIMethod', 12841 12843 'SlowvoteEmbedView' => 'AphrontView',
+74
src/applications/maniphest/herald/SetSubtypeHeraldAction.php
··· 1 + <?php 2 + 3 + final class SetSubtypeHeraldAction extends HeraldAction { 4 + const ACTIONCONST = 'maniphest.subtype'; 5 + const DO_SUBTYPE = 'do.subtype'; 6 + 7 + public function getActionGroupKey() { 8 + return HeraldApplicationActionGroup::ACTIONGROUPKEY; 9 + } 10 + 11 + public function supportsObject($object) { 12 + return $object instanceof ManiphestTask; 13 + } 14 + 15 + public function supportsRuleType($rule_type) { 16 + return $rule_type == HeraldRuleTypeConfig::RULE_TYPE_GLOBAL; 17 + } 18 + 19 + public function getActionKey() { 20 + return self::ACTIONCONST; 21 + } 22 + 23 + public function getHeraldActionName() { 24 + return pht('Change subtype to'); 25 + } 26 + 27 + public function renderActionDescription($value) { 28 + $type = head($value); 29 + return pht('Change subtype to "%s"', $type); 30 + } 31 + 32 + public function getHeraldActionStandardType() { 33 + return self::STANDARD_PHID_LIST; 34 + } 35 + 36 + protected function getDatasource() { 37 + return id(new ManiphestTaskSubtypeDatasource()) 38 + ->setLimit(1); 39 + } 40 + 41 + protected function getDatasourceValueMap() { 42 + $map = id(new ManiphestTask())->newEditEngineSubtypeMap(); 43 + return $map->getSubtypes(); 44 + } 45 + 46 + public function applyEffect($object, HeraldEffect $effect) { 47 + $new_subtype = head($effect->getTarget()); 48 + 49 + $adapter = $this->getAdapter(); 50 + $adapter->queueTransaction(id(new ManiphestTransaction()) 51 + ->setTransactionType(PhabricatorTransactions::TYPE_SUBTYPE) 52 + ->setNewValue($new_subtype)); 53 + 54 + $this->logEffect(self::DO_SUBTYPE, $new_subtype); 55 + } 56 + 57 + protected function getActionEffectMap() { 58 + return array( 59 + self::DO_SUBTYPE => array( 60 + 'icon' => 'fa-pencil', 61 + 'color' => 'green', 62 + 'name' => pht('Changed Subtype'), 63 + ), 64 + ); 65 + } 66 + 67 + protected function renderActionEffectDescription($type, $data) { 68 + switch ($type) { 69 + case self::DO_SUBTYPE: 70 + return pht('Change subtype to "%s."', $data); 71 + } 72 + } 73 + 74 + }