mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 20:10:55 +01:00
Modernize "task priority" datasource
Summary: Ref T4420. Test Plan: - Used typeahead in Herald rules. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9877
This commit is contained in:
parent
4e77984644
commit
4759f3f897
4 changed files with 34 additions and 15 deletions
|
@ -944,6 +944,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php',
|
||||
'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php',
|
||||
'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php',
|
||||
'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php',
|
||||
'ManiphestTaskProject' => 'applications/maniphest/storage/ManiphestTaskProject.php',
|
||||
'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php',
|
||||
'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php',
|
||||
|
@ -3724,6 +3725,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'ManiphestTaskOwner' => 'ManiphestConstants',
|
||||
'ManiphestTaskPriority' => 'ManiphestConstants',
|
||||
'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'ManiphestTaskProject' => 'ManiphestDAO',
|
||||
'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'ManiphestTaskResultListView' => 'ManiphestView',
|
||||
|
|
|
@ -591,6 +591,7 @@ final class HeraldRuleController extends HeraldController {
|
|||
$sources = array(
|
||||
'repository' => new DiffusionRepositoryDatasource(),
|
||||
'legaldocuments' => new LegalpadDocumentDatasource(),
|
||||
'taskpriority' => new ManiphestTaskPriorityDatasource(),
|
||||
);
|
||||
|
||||
$sources = mpull($sources, 'getDatasourceURI');
|
||||
|
@ -601,7 +602,6 @@ final class HeraldRuleController extends HeraldController {
|
|||
'project' => '/typeahead/common/projects/',
|
||||
'userorproject' => '/typeahead/common/accountsorprojects/',
|
||||
'buildplan' => '/typeahead/common/buildplans/',
|
||||
'taskpriority' => '/typeahead/common/taskpriority/',
|
||||
'arcanistprojects' => '/typeahead/common/arcanistprojects/',
|
||||
);
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
final class ManiphestTaskPriorityDatasource
|
||||
extends PhabricatorTypeaheadDatasource {
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type a task priority name...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorApplicationManiphest';
|
||||
}
|
||||
|
||||
public function loadResults() {
|
||||
$viewer = $this->getViewer();
|
||||
$raw_query = $this->getRawQuery();
|
||||
|
||||
$results = array();
|
||||
|
||||
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
|
||||
foreach ($priority_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;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,7 +33,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_symbols = false;
|
||||
$need_jump_objects = false;
|
||||
$need_build_plans = false;
|
||||
$need_task_priority = false;
|
||||
switch ($this->type) {
|
||||
case 'mainsearch':
|
||||
$need_users = true;
|
||||
|
@ -84,9 +83,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
case 'buildplans':
|
||||
$need_build_plans = true;
|
||||
break;
|
||||
case 'taskpriority':
|
||||
$need_task_priority = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
@ -225,16 +221,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
}
|
||||
}
|
||||
|
||||
if ($need_task_priority) {
|
||||
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
|
||||
foreach ($priority_map as $value => $name) {
|
||||
// NOTE: $value is not a phid but is unique. This'll work.
|
||||
$results[] = id(new PhabricatorTypeaheadResult())
|
||||
->setPHID($value)
|
||||
->setName($name);
|
||||
}
|
||||
}
|
||||
|
||||
if ($need_projs) {
|
||||
$projs = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
|
|
Loading…
Reference in a new issue