Page MenuHomePhabricator

D14359.id34669.diff
No OneTemporary

D14359.id34669.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
@@ -1306,6 +1306,7 @@
'ManiphestTaskStatus' => 'applications/maniphest/constants/ManiphestTaskStatus.php',
'ManiphestTaskStatusDatasource' => 'applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php',
'ManiphestTaskStatusFunctionDatasource' => 'applications/maniphest/typeahead/ManiphestTaskStatusFunctionDatasource.php',
+ 'ManiphestTaskStatusHeraldAction' => 'applications/maniphest/herald/ManiphestTaskStatusHeraldAction.php',
'ManiphestTaskStatusHeraldField' => 'applications/maniphest/herald/ManiphestTaskStatusHeraldField.php',
'ManiphestTaskStatusTestCase' => 'applications/maniphest/constants/__tests__/ManiphestTaskStatusTestCase.php',
'ManiphestTaskTestCase' => 'applications/maniphest/__tests__/ManiphestTaskTestCase.php',
@@ -5195,6 +5196,7 @@
'ManiphestTaskStatus' => 'ManiphestConstants',
'ManiphestTaskStatusDatasource' => 'PhabricatorTypeaheadDatasource',
'ManiphestTaskStatusFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
+ 'ManiphestTaskStatusHeraldAction' => 'HeraldAction',
'ManiphestTaskStatusHeraldField' => 'ManiphestTaskHeraldField',
'ManiphestTaskStatusTestCase' => 'PhabricatorTestCase',
'ManiphestTaskTestCase' => 'PhabricatorTestCase',
diff --git a/src/applications/maniphest/herald/ManiphestTaskStatusHeraldAction.php b/src/applications/maniphest/herald/ManiphestTaskStatusHeraldAction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/herald/ManiphestTaskStatusHeraldAction.php
@@ -0,0 +1,85 @@
+<?php
+
+final class ManiphestTaskStatusHeraldAction
+ extends HeraldAction {
+
+ const ACTIONCONST = 'maniphest.status';
+ const DO_STATUS = 'do.status';
+
+ public function supportsObject($object) {
+ return ($object instanceof ManiphestTask);
+ }
+
+ public function getActionGroupKey() {
+ return HeraldApplicationActionGroup::ACTIONGROUPKEY;
+ }
+
+ public function getHeraldActionName() {
+ return pht('Change status to');
+ }
+
+ public function supportsRuleType($rule_type) {
+ return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
+ }
+
+ public function applyEffect($object, HeraldEffect $effect) {
+ $status = reset($effect->getTarget());
+ if (!$status) {
+ $this->logEffect(self::DO_STANDARD_NO_EFFECT, null);
+ return;
+ }
+
+ $adapter = $this->getAdapter();
+ $object = $adapter->getObject();
+ $current = $object->getStatus();
+
+ if ($current == $status) {
+ $this->logEffect(self::DO_STANDARD_NO_EFFECT, $status);
+ return;
+ }
+
+ $xaction = $adapter->newTransaction()
+ ->setTransactionType(ManiphestTransaction::TYPE_STATUS)
+ ->setNewValue($status);
+
+ $adapter->queueTransaction($xaction);
+ $this->logEffect(self::DO_STATUS, $status);
+ }
+
+ public function getHeraldActionStandardType() {
+ return self::STANDARD_PHID_LIST;
+ }
+
+ public function renderActionDescription($value) {
+ return pht('Change status to: %s.', implode(',', $value));
+ // return pht('Change status to: %s.', $this->renderHandleList($value));
+ }
+
+ protected function getDatasource() {
+ return new ManiphestTaskStatusDatasource();
+ }
+
+ protected function getDatasourceValueMap() {
+ return ManiphestTaskStatus::getTaskStatusMap();
+ }
+
+ protected function getActionEffectMap() {
+ return array(
+ self::DO_STATUS => array(
+ 'icon' => 'fa-pencil',
+ 'color' => 'green',
+ 'name' => pht('Changed Task Status'),
+ ),
+ );
+ }
+
+ protected function renderActionEffectDescription($type, $data) {
+ switch ($type) {
+ case self::DO_STATUS:
+ return pht(
+ 'Changed task status to: %s.',
+ ManiphestTaskStatus::getTaskStatusName($data));
+ }
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 1:19 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6762647
Default Alt Text
D14359.id34669.diff (3 KB)

Event Timeline