mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 16:30:59 +01:00
T5015, Allow Herald rules for Maniphest to act on task status changes
Summary: Fixes T5015, Allow Herald rules for Maniphest to act on task status changes. Test Plan: Create Herald rule for Maniphest tasks to flag a task with status "wontfix". Change status of Maniphest task to "wontfix". Task should be flagged. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T5015 Differential Revision: https://secure.phabricator.com/D10842
This commit is contained in:
parent
22551d106d
commit
3d2e03d0e2
7 changed files with 61 additions and 1 deletions
|
@ -1014,6 +1014,7 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php',
|
'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php',
|
||||||
'ManiphestTaskSearchEngine' => 'applications/maniphest/query/ManiphestTaskSearchEngine.php',
|
'ManiphestTaskSearchEngine' => 'applications/maniphest/query/ManiphestTaskSearchEngine.php',
|
||||||
'ManiphestTaskStatus' => 'applications/maniphest/constants/ManiphestTaskStatus.php',
|
'ManiphestTaskStatus' => 'applications/maniphest/constants/ManiphestTaskStatus.php',
|
||||||
|
'ManiphestTaskStatusDatasource' => 'applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php',
|
||||||
'ManiphestTaskStatusTestCase' => 'applications/maniphest/constants/__tests__/ManiphestTaskStatusTestCase.php',
|
'ManiphestTaskStatusTestCase' => 'applications/maniphest/constants/__tests__/ManiphestTaskStatusTestCase.php',
|
||||||
'ManiphestTaskSubscriber' => 'applications/maniphest/storage/ManiphestTaskSubscriber.php',
|
'ManiphestTaskSubscriber' => 'applications/maniphest/storage/ManiphestTaskSubscriber.php',
|
||||||
'ManiphestTransaction' => 'applications/maniphest/storage/ManiphestTransaction.php',
|
'ManiphestTransaction' => 'applications/maniphest/storage/ManiphestTransaction.php',
|
||||||
|
@ -4073,6 +4074,7 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTaskResultListView' => 'ManiphestView',
|
'ManiphestTaskResultListView' => 'ManiphestView',
|
||||||
'ManiphestTaskSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'ManiphestTaskSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'ManiphestTaskStatus' => 'ManiphestConstants',
|
'ManiphestTaskStatus' => 'ManiphestConstants',
|
||||||
|
'ManiphestTaskStatusDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'ManiphestTaskStatusTestCase' => 'PhabricatorTestCase',
|
'ManiphestTaskStatusTestCase' => 'PhabricatorTestCase',
|
||||||
'ManiphestTaskSubscriber' => 'ManiphestDAO',
|
'ManiphestTaskSubscriber' => 'ManiphestDAO',
|
||||||
'ManiphestTransaction' => 'PhabricatorApplicationTransaction',
|
'ManiphestTransaction' => 'PhabricatorApplicationTransaction',
|
||||||
|
|
|
@ -40,6 +40,7 @@ abstract class HeraldAdapter {
|
||||||
const FIELD_COMMITTER_RAW = 'committer-raw';
|
const FIELD_COMMITTER_RAW = 'committer-raw';
|
||||||
const FIELD_IS_NEW_OBJECT = 'new-object';
|
const FIELD_IS_NEW_OBJECT = 'new-object';
|
||||||
const FIELD_TASK_PRIORITY = 'taskpriority';
|
const FIELD_TASK_PRIORITY = 'taskpriority';
|
||||||
|
const FIELD_TASK_STATUS = 'taskstatus';
|
||||||
const FIELD_ARCANIST_PROJECT = 'arcanist-project';
|
const FIELD_ARCANIST_PROJECT = 'arcanist-project';
|
||||||
const FIELD_PUSHER_IS_COMMITTER = 'pusher-is-committer';
|
const FIELD_PUSHER_IS_COMMITTER = 'pusher-is-committer';
|
||||||
const FIELD_PATH = 'path';
|
const FIELD_PATH = 'path';
|
||||||
|
@ -96,6 +97,7 @@ abstract class HeraldAdapter {
|
||||||
const VALUE_USER_OR_PROJECT = 'userorproject';
|
const VALUE_USER_OR_PROJECT = 'userorproject';
|
||||||
const VALUE_BUILD_PLAN = 'buildplan';
|
const VALUE_BUILD_PLAN = 'buildplan';
|
||||||
const VALUE_TASK_PRIORITY = 'taskpriority';
|
const VALUE_TASK_PRIORITY = 'taskpriority';
|
||||||
|
const VALUE_TASK_STATUS = 'taskstatus';
|
||||||
const VALUE_ARCANIST_PROJECT = 'arcanistprojects';
|
const VALUE_ARCANIST_PROJECT = 'arcanistprojects';
|
||||||
const VALUE_LEGAL_DOCUMENTS = 'legaldocuments';
|
const VALUE_LEGAL_DOCUMENTS = 'legaldocuments';
|
||||||
|
|
||||||
|
@ -311,6 +313,7 @@ abstract class HeraldAdapter {
|
||||||
self::FIELD_COMMITTER_RAW => pht('Raw committer name'),
|
self::FIELD_COMMITTER_RAW => pht('Raw committer name'),
|
||||||
self::FIELD_IS_NEW_OBJECT => pht('Is newly created?'),
|
self::FIELD_IS_NEW_OBJECT => pht('Is newly created?'),
|
||||||
self::FIELD_TASK_PRIORITY => pht('Task priority'),
|
self::FIELD_TASK_PRIORITY => pht('Task priority'),
|
||||||
|
self::FIELD_TASK_STATUS => pht('Task status'),
|
||||||
self::FIELD_ARCANIST_PROJECT => pht('Arcanist Project'),
|
self::FIELD_ARCANIST_PROJECT => pht('Arcanist Project'),
|
||||||
self::FIELD_PUSHER_IS_COMMITTER => pht('Pusher same as committer'),
|
self::FIELD_PUSHER_IS_COMMITTER => pht('Pusher same as committer'),
|
||||||
self::FIELD_PATH => pht('Path'),
|
self::FIELD_PATH => pht('Path'),
|
||||||
|
@ -366,6 +369,7 @@ abstract class HeraldAdapter {
|
||||||
case self::FIELD_REVIEWER:
|
case self::FIELD_REVIEWER:
|
||||||
case self::FIELD_PUSHER:
|
case self::FIELD_PUSHER:
|
||||||
case self::FIELD_TASK_PRIORITY:
|
case self::FIELD_TASK_PRIORITY:
|
||||||
|
case self::FIELD_TASK_STATUS:
|
||||||
case self::FIELD_ARCANIST_PROJECT:
|
case self::FIELD_ARCANIST_PROJECT:
|
||||||
return array(
|
return array(
|
||||||
self::CONDITION_IS_ANY,
|
self::CONDITION_IS_ANY,
|
||||||
|
@ -843,6 +847,8 @@ abstract class HeraldAdapter {
|
||||||
return self::VALUE_REPOSITORY;
|
return self::VALUE_REPOSITORY;
|
||||||
case self::FIELD_TASK_PRIORITY:
|
case self::FIELD_TASK_PRIORITY:
|
||||||
return self::VALUE_TASK_PRIORITY;
|
return self::VALUE_TASK_PRIORITY;
|
||||||
|
case self::FIELD_TASK_STATUS:
|
||||||
|
return self::VALUE_TASK_STATUS;
|
||||||
case self::FIELD_ARCANIST_PROJECT:
|
case self::FIELD_ARCANIST_PROJECT:
|
||||||
return self::VALUE_ARCANIST_PROJECT;
|
return self::VALUE_ARCANIST_PROJECT;
|
||||||
default:
|
default:
|
||||||
|
@ -1162,6 +1168,15 @@ abstract class HeraldAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case self::FIELD_TASK_STATUS:
|
||||||
|
$status_map = ManiphestTaskStatus::getTaskStatusMap();
|
||||||
|
foreach ($value as $index => $val) {
|
||||||
|
$name = idx($status_map, $val);
|
||||||
|
if ($name) {
|
||||||
|
$value[$index] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case HeraldPreCommitRefAdapter::FIELD_REF_CHANGE:
|
case HeraldPreCommitRefAdapter::FIELD_REF_CHANGE:
|
||||||
$change_map =
|
$change_map =
|
||||||
PhabricatorRepositoryPushLog::getHeraldChangeFlagConditionOptions();
|
PhabricatorRepositoryPushLog::getHeraldChangeFlagConditionOptions();
|
||||||
|
|
|
@ -89,6 +89,7 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
|
||||||
self::FIELD_CONTENT_SOURCE,
|
self::FIELD_CONTENT_SOURCE,
|
||||||
self::FIELD_PROJECTS,
|
self::FIELD_PROJECTS,
|
||||||
self::FIELD_TASK_PRIORITY,
|
self::FIELD_TASK_PRIORITY,
|
||||||
|
self::FIELD_TASK_STATUS,
|
||||||
self::FIELD_IS_NEW_OBJECT,
|
self::FIELD_IS_NEW_OBJECT,
|
||||||
),
|
),
|
||||||
parent::getFields());
|
parent::getFields());
|
||||||
|
@ -145,6 +146,8 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
|
||||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||||
case self::FIELD_TASK_PRIORITY:
|
case self::FIELD_TASK_PRIORITY:
|
||||||
return $this->getTask()->getPriority();
|
return $this->getTask()->getPriority();
|
||||||
|
case self::FIELD_TASK_STATUS:
|
||||||
|
return $this->getTask()->getStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getHeraldField($field);
|
return parent::getHeraldField($field);
|
||||||
|
|
|
@ -358,6 +358,14 @@ final class HeraldRuleController extends HeraldController {
|
||||||
}
|
}
|
||||||
$value = $value_map;
|
$value = $value_map;
|
||||||
break;
|
break;
|
||||||
|
case HeraldAdapter::FIELD_TASK_STATUS:
|
||||||
|
$value_map = array();
|
||||||
|
$status_map = ManiphestTaskStatus::getTaskStatusMap();
|
||||||
|
foreach ($value as $status) {
|
||||||
|
$value_map[$status] = idx($status_map, $status);
|
||||||
|
}
|
||||||
|
$value = $value_map;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$value_map = array();
|
$value_map = array();
|
||||||
|
@ -586,6 +594,7 @@ final class HeraldRuleController extends HeraldController {
|
||||||
'repository' => new DiffusionRepositoryDatasource(),
|
'repository' => new DiffusionRepositoryDatasource(),
|
||||||
'legaldocuments' => new LegalpadDocumentDatasource(),
|
'legaldocuments' => new LegalpadDocumentDatasource(),
|
||||||
'taskpriority' => new ManiphestTaskPriorityDatasource(),
|
'taskpriority' => new ManiphestTaskPriorityDatasource(),
|
||||||
|
'taskstatus' => new ManiphestTaskStatusDatasource(),
|
||||||
'buildplan' => new HarbormasterBuildPlanDatasource(),
|
'buildplan' => new HarbormasterBuildPlanDatasource(),
|
||||||
'arcanistprojects' => new DiffusionArcanistProjectDatasource(),
|
'arcanistprojects' => new DiffusionArcanistProjectDatasource(),
|
||||||
'package' => new PhabricatorOwnersPackageDatasource(),
|
'package' => new PhabricatorOwnersPackageDatasource(),
|
||||||
|
|
|
@ -18,7 +18,7 @@ final class HeraldRule extends HeraldDAO
|
||||||
protected $isDisabled = 0;
|
protected $isDisabled = 0;
|
||||||
protected $triggerObjectPHID;
|
protected $triggerObjectPHID;
|
||||||
|
|
||||||
protected $configVersion = 37;
|
protected $configVersion = 38;
|
||||||
|
|
||||||
// PHIDs for which this rule has been applied
|
// PHIDs for which this rule has been applied
|
||||||
private $ruleApplied = self::ATTACHABLE;
|
private $ruleApplied = self::ATTACHABLE;
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ManiphestTaskStatusDatasource
|
||||||
|
extends PhabricatorTypeaheadDatasource {
|
||||||
|
|
||||||
|
public function getPlaceholderText() {
|
||||||
|
return pht('Type a task status name...');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatasourceApplicationClass() {
|
||||||
|
return 'PhabricatorManiphestApplication';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadResults() {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$raw_query = $this->getRawQuery();
|
||||||
|
|
||||||
|
$results = array();
|
||||||
|
|
||||||
|
$status_map = ManiphestTaskStatus::getTaskStatusMap();
|
||||||
|
foreach ($status_map as $value => $name) {
|
||||||
|
// NOTE: $value is not a PHID but is unique. This'll work.
|
||||||
|
$results[] = id(new PhabricatorTypeaheadResult())
|
||||||
|
->setPHID($value)
|
||||||
|
->setName($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
}
|
|
@ -219,6 +219,7 @@ JX.install('HeraldRuleEditor', {
|
||||||
case 'userorproject':
|
case 'userorproject':
|
||||||
case 'buildplan':
|
case 'buildplan':
|
||||||
case 'taskpriority':
|
case 'taskpriority':
|
||||||
|
case 'taskstatus':
|
||||||
case 'arcanistprojects':
|
case 'arcanistprojects':
|
||||||
case 'legaldocuments':
|
case 'legaldocuments':
|
||||||
var tokenizer = this._newTokenizer(type);
|
var tokenizer = this._newTokenizer(type);
|
||||||
|
|
Loading…
Reference in a new issue