From a77bf877d4f1dd09042b78d48be2483fdffc7846 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sat, 5 Dec 2015 10:51:34 -0800 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 2 + .../ManiphestTaskStatusHeraldAction.php | 87 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 src/applications/maniphest/herald/ManiphestTaskStatusHeraldAction.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ab3ba4a37f..5df4706857 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1321,6 +1321,7 @@ phutil_register_library_map(array( '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', @@ -5313,6 +5314,7 @@ phutil_register_library_map(array( '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 index 0000000000..26e212d9c7 --- /dev/null +++ b/src/applications/maniphest/herald/ManiphestTaskStatusHeraldAction.php @@ -0,0 +1,87 @@ +getTarget()); + + if (!$status) { + $this->logEffect(self::DO_STANDARD_EMPTY); + 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) { + $status = head($value); + $name = ManiphestTaskStatus::getTaskStatusName($status); + return pht('Change status to: %s.', $name); + } + + 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)); + } + } + +}