Page MenuHomePhorge

D25913.1742921403.diff
No OneTemporary

D25913.1742921403.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
@@ -5899,6 +5899,7 @@
'RemarkupValue' => 'applications/remarkup/RemarkupValue.php',
'RepositoryConduitAPIMethod' => 'applications/repository/conduit/RepositoryConduitAPIMethod.php',
'RepositoryQueryConduitAPIMethod' => 'applications/repository/conduit/RepositoryQueryConduitAPIMethod.php',
+ 'SetSubtypeHeraldAction' => 'applications/maniphest/herald/SetSubtypeHeraldAction.php',
'ShellLogView' => 'applications/harbormaster/view/ShellLogView.php',
'SlowvoteConduitAPIMethod' => 'applications/slowvote/conduit/SlowvoteConduitAPIMethod.php',
'SlowvoteEmbedView' => 'applications/slowvote/view/SlowvoteEmbedView.php',
@@ -12836,6 +12837,7 @@
'RemarkupValue' => 'Phobject',
'RepositoryConduitAPIMethod' => 'ConduitAPIMethod',
'RepositoryQueryConduitAPIMethod' => 'RepositoryConduitAPIMethod',
+ 'SetSubtypeHeraldAction' => 'HeraldAction',
'ShellLogView' => 'AphrontView',
'SlowvoteConduitAPIMethod' => 'ConduitAPIMethod',
'SlowvoteEmbedView' => 'AphrontView',
diff --git a/src/applications/maniphest/herald/SetSubtypeHeraldAction.php b/src/applications/maniphest/herald/SetSubtypeHeraldAction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/herald/SetSubtypeHeraldAction.php
@@ -0,0 +1,74 @@
+<?php
+
+final class SetSubtypeHeraldAction extends HeraldAction {
+ const ACTIONCONST = 'maniphest.subtype';
+ const DO_SUBTYPE = 'do.subtype';
+
+ public function getActionGroupKey() {
+ return HeraldApplicationActionGroup::ACTIONGROUPKEY;
+ }
+
+ public function supportsObject($object) {
+ return $object instanceof ManiphestTask;
+ }
+
+ public function supportsRuleType($rule_type) {
+ return $rule_type == HeraldRuleTypeConfig::RULE_TYPE_GLOBAL;
+ }
+
+ public function getActionKey() {
+ return self::ACTIONCONST;
+ }
+
+ public function getHeraldActionName() {
+ return pht('Change subtype to');
+ }
+
+ public function renderActionDescription($value) {
+ $type = head($value);
+ return pht('Change subtype to "%s"', $type);
+ }
+
+ public function getHeraldActionStandardType() {
+ return self::STANDARD_PHID_LIST;
+ }
+
+ protected function getDatasource() {
+ return id(new ManiphestTaskSubtypeDatasource())
+ ->setLimit(1);
+ }
+
+ protected function getDatasourceValueMap() {
+ $map = id(new ManiphestTask())->newEditEngineSubtypeMap();
+ return $map->getSubtypes();
+ }
+
+ public function applyEffect($object, HeraldEffect $effect) {
+ $new_subtype = head($effect->getTarget());
+
+ $adapter = $this->getAdapter();
+ $adapter->queueTransaction(id(new ManiphestTransaction())
+ ->setTransactionType(PhabricatorTransactions::TYPE_SUBTYPE)
+ ->setNewValue($new_subtype));
+
+ $this->logEffect(self::DO_SUBTYPE, $new_subtype);
+ }
+
+ protected function getActionEffectMap() {
+ return array(
+ self::DO_SUBTYPE => array(
+ 'icon' => 'fa-pencil',
+ 'color' => 'green',
+ 'name' => pht('Changed Subtype'),
+ ),
+ );
+ }
+
+ protected function renderActionEffectDescription($type, $data) {
+ switch ($type) {
+ case self::DO_SUBTYPE:
+ return pht('Change subtype to "%s."', $data);
+ }
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 25, 16:50 (19 h, 43 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1260373
Default Alt Text
D25913.1742921403.diff (3 KB)

Event Timeline