1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20: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:
epriestley 2014-07-10 16:20:40 -07:00
parent 4e77984644
commit 4759f3f897
4 changed files with 34 additions and 15 deletions

View file

@ -944,6 +944,7 @@ phutil_register_library_map(array(
'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php', 'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php',
'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php', 'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php',
'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php', 'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php',
'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php',
'ManiphestTaskProject' => 'applications/maniphest/storage/ManiphestTaskProject.php', 'ManiphestTaskProject' => 'applications/maniphest/storage/ManiphestTaskProject.php',
'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php', 'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php',
'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php', 'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php',
@ -3724,6 +3725,7 @@ phutil_register_library_map(array(
'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver', 'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver',
'ManiphestTaskOwner' => 'ManiphestConstants', 'ManiphestTaskOwner' => 'ManiphestConstants',
'ManiphestTaskPriority' => 'ManiphestConstants', 'ManiphestTaskPriority' => 'ManiphestConstants',
'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource',
'ManiphestTaskProject' => 'ManiphestDAO', 'ManiphestTaskProject' => 'ManiphestDAO',
'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'ManiphestTaskResultListView' => 'ManiphestView', 'ManiphestTaskResultListView' => 'ManiphestView',

View file

@ -591,6 +591,7 @@ final class HeraldRuleController extends HeraldController {
$sources = array( $sources = array(
'repository' => new DiffusionRepositoryDatasource(), 'repository' => new DiffusionRepositoryDatasource(),
'legaldocuments' => new LegalpadDocumentDatasource(), 'legaldocuments' => new LegalpadDocumentDatasource(),
'taskpriority' => new ManiphestTaskPriorityDatasource(),
); );
$sources = mpull($sources, 'getDatasourceURI'); $sources = mpull($sources, 'getDatasourceURI');
@ -601,7 +602,6 @@ final class HeraldRuleController extends HeraldController {
'project' => '/typeahead/common/projects/', 'project' => '/typeahead/common/projects/',
'userorproject' => '/typeahead/common/accountsorprojects/', 'userorproject' => '/typeahead/common/accountsorprojects/',
'buildplan' => '/typeahead/common/buildplans/', 'buildplan' => '/typeahead/common/buildplans/',
'taskpriority' => '/typeahead/common/taskpriority/',
'arcanistprojects' => '/typeahead/common/arcanistprojects/', 'arcanistprojects' => '/typeahead/common/arcanistprojects/',
); );

View file

@ -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;
}
}

View file

@ -33,7 +33,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
$need_symbols = false; $need_symbols = false;
$need_jump_objects = false; $need_jump_objects = false;
$need_build_plans = false; $need_build_plans = false;
$need_task_priority = false;
switch ($this->type) { switch ($this->type) {
case 'mainsearch': case 'mainsearch':
$need_users = true; $need_users = true;
@ -84,9 +83,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
case 'buildplans': case 'buildplans':
$need_build_plans = true; $need_build_plans = true;
break; break;
case 'taskpriority':
$need_task_priority = true;
break;
} }
$results = array(); $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) { if ($need_projs) {
$projs = id(new PhabricatorProjectQuery()) $projs = id(new PhabricatorProjectQuery())
->setViewer($viewer) ->setViewer($viewer)