mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +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:
parent
4759f3f897
commit
dba4865681
5 changed files with 42 additions and 18 deletions
|
@ -729,6 +729,7 @@ phutil_register_library_map(array(
|
|||
'HarbormasterBuildMessage' => 'applications/harbormaster/storage/HarbormasterBuildMessage.php',
|
||||
'HarbormasterBuildMessageQuery' => 'applications/harbormaster/query/HarbormasterBuildMessageQuery.php',
|
||||
'HarbormasterBuildPlan' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php',
|
||||
'HarbormasterBuildPlanDatasource' => 'applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php',
|
||||
'HarbormasterBuildPlanEditor' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditor.php',
|
||||
'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php',
|
||||
'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php',
|
||||
|
@ -3470,6 +3471,7 @@ phutil_register_library_map(array(
|
|||
1 => 'PhabricatorPolicyInterface',
|
||||
2 => 'PhabricatorSubscribableInterface',
|
||||
),
|
||||
'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'HarbormasterBuildPlanEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
|
|
|
@ -12,6 +12,10 @@ final class HarbormasterPHIDTypeBuildPlan extends PhabricatorPHIDType {
|
|||
return pht('Build Plan');
|
||||
}
|
||||
|
||||
public function getTypeIcon() {
|
||||
return 'fa-cubes';
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
return new HarbormasterBuildPlan();
|
||||
}
|
||||
|
@ -31,8 +35,9 @@ final class HarbormasterPHIDTypeBuildPlan extends PhabricatorPHIDType {
|
|||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$build_plan = $objects[$phid];
|
||||
$handles[$phid]->setName($build_plan->getName());
|
||||
$handles[$phid]->setURI('/harbormaster/plan/'.$build_plan->getID());
|
||||
$id = $build_plan->getID();
|
||||
$handles[$phid]->setName(pht('Plan %d %s', $id, $build_plan->getName()));
|
||||
$handles[$phid]->setURI('/harbormaster/plan/'.$id.'/');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -592,6 +592,7 @@ final class HeraldRuleController extends HeraldController {
|
|||
'repository' => new DiffusionRepositoryDatasource(),
|
||||
'legaldocuments' => new LegalpadDocumentDatasource(),
|
||||
'taskpriority' => new ManiphestTaskPriorityDatasource(),
|
||||
'buildplan' => new HarbormasterBuildPlanDatasource(),
|
||||
);
|
||||
|
||||
$sources = mpull($sources, 'getDatasourceURI');
|
||||
|
@ -601,7 +602,6 @@ final class HeraldRuleController extends HeraldController {
|
|||
'package' => '/typeahead/common/packages/',
|
||||
'project' => '/typeahead/common/projects/',
|
||||
'userorproject' => '/typeahead/common/accountsorprojects/',
|
||||
'buildplan' => '/typeahead/common/buildplans/',
|
||||
'arcanistprojects' => '/typeahead/common/arcanistprojects/',
|
||||
);
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_noproject = false;
|
||||
$need_symbols = false;
|
||||
$need_jump_objects = false;
|
||||
$need_build_plans = false;
|
||||
switch ($this->type) {
|
||||
case 'mainsearch':
|
||||
$need_users = true;
|
||||
|
@ -80,9 +79,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
case 'arcanistprojects':
|
||||
$need_arcanist_projects = true;
|
||||
break;
|
||||
case 'buildplans':
|
||||
$need_build_plans = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$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) {
|
||||
$projs = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
|
|
Loading…
Reference in a new issue