mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
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
This commit is contained in:
parent
77d33ec7be
commit
a77bf877d4
2 changed files with 89 additions and 0 deletions
|
@ -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',
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?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 = head($effect->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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue