1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Modernize "build plans" typeahead datasource

Summary: Ref T4420. Modernize build plans.

Test Plan:
  - Used build plan typeahead in Harbormaster.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4420

Differential Revision: https://secure.phabricator.com/D9878
This commit is contained in:
epriestley 2014-07-10 16:20:58 -07:00
parent 4759f3f897
commit dba4865681
5 changed files with 42 additions and 18 deletions

View file

@ -729,6 +729,7 @@ phutil_register_library_map(array(
'HarbormasterBuildMessage' => 'applications/harbormaster/storage/HarbormasterBuildMessage.php', 'HarbormasterBuildMessage' => 'applications/harbormaster/storage/HarbormasterBuildMessage.php',
'HarbormasterBuildMessageQuery' => 'applications/harbormaster/query/HarbormasterBuildMessageQuery.php', 'HarbormasterBuildMessageQuery' => 'applications/harbormaster/query/HarbormasterBuildMessageQuery.php',
'HarbormasterBuildPlan' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php', 'HarbormasterBuildPlan' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php',
'HarbormasterBuildPlanDatasource' => 'applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php',
'HarbormasterBuildPlanEditor' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditor.php', 'HarbormasterBuildPlanEditor' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditor.php',
'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php', 'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php',
'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php', 'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php',
@ -3470,6 +3471,7 @@ phutil_register_library_map(array(
1 => 'PhabricatorPolicyInterface', 1 => 'PhabricatorPolicyInterface',
2 => 'PhabricatorSubscribableInterface', 2 => 'PhabricatorSubscribableInterface',
), ),
'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource',
'HarbormasterBuildPlanEditor' => 'PhabricatorApplicationTransactionEditor', 'HarbormasterBuildPlanEditor' => 'PhabricatorApplicationTransactionEditor',
'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine', 'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine',

View file

@ -12,6 +12,10 @@ final class HarbormasterPHIDTypeBuildPlan extends PhabricatorPHIDType {
return pht('Build Plan'); return pht('Build Plan');
} }
public function getTypeIcon() {
return 'fa-cubes';
}
public function newObject() { public function newObject() {
return new HarbormasterBuildPlan(); return new HarbormasterBuildPlan();
} }
@ -31,8 +35,9 @@ final class HarbormasterPHIDTypeBuildPlan extends PhabricatorPHIDType {
foreach ($handles as $phid => $handle) { foreach ($handles as $phid => $handle) {
$build_plan = $objects[$phid]; $build_plan = $objects[$phid];
$handles[$phid]->setName($build_plan->getName()); $id = $build_plan->getID();
$handles[$phid]->setURI('/harbormaster/plan/'.$build_plan->getID()); $handles[$phid]->setName(pht('Plan %d %s', $id, $build_plan->getName()));
$handles[$phid]->setURI('/harbormaster/plan/'.$id.'/');
} }
} }

View file

@ -0,0 +1,32 @@
<?php
final class HarbormasterBuildPlanDatasource
extends PhabricatorTypeaheadDatasource {
public function getPlaceholderText() {
return pht('Type a build plan name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorApplicationHarbormaster';
}
public function loadResults() {
$viewer = $this->getViewer();
$raw_query = $this->getRawQuery();
$results = array();
$plans = id(new HarbormasterBuildPlanQuery())
->setViewer($viewer)
->execute();
foreach ($plans as $plan) {
$results[] = id(new PhabricatorTypeaheadResult())
->setName($plan->getName())
->setPHID($plan->getPHID());
}
return $results;
}
}

View file

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

View file

@ -32,7 +32,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
$need_noproject = false; $need_noproject = false;
$need_symbols = false; $need_symbols = false;
$need_jump_objects = false; $need_jump_objects = false;
$need_build_plans = false;
switch ($this->type) { switch ($this->type) {
case 'mainsearch': case 'mainsearch':
$need_users = true; $need_users = true;
@ -80,9 +79,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
case 'arcanistprojects': case 'arcanistprojects':
$need_arcanist_projects = true; $need_arcanist_projects = true;
break; break;
case 'buildplans':
$need_build_plans = true;
break;
} }
$results = array(); $results = array();
@ -210,17 +206,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
} }
} }
if ($need_build_plans) {
$plans = id(new HarbormasterBuildPlanQuery())
->setViewer($viewer)
->execute();
foreach ($plans as $plan) {
$results[] = id(new PhabricatorTypeaheadResult())
->setName($plan->getName())
->setPHID($plan->getPHID());
}
}
if ($need_projs) { if ($need_projs) {
$projs = id(new PhabricatorProjectQuery()) $projs = id(new PhabricatorProjectQuery())
->setViewer($viewer) ->setViewer($viewer)