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

Modernize "arcanist project" datasource

Summary: Ref T4420. Do arc projects.

Test Plan:
  - Used Herald typeahead.
  - Used Repositories typehaead.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4420

Differential Revision: https://secure.phabricator.com/D9879
This commit is contained in:
epriestley 2014-07-10 16:21:10 -07:00
parent dba4865681
commit e9dbe747ff
5 changed files with 34 additions and 15 deletions

View file

@ -459,6 +459,7 @@ phutil_register_library_map(array(
'DifferentialUnitStatus' => 'applications/differential/constants/DifferentialUnitStatus.php',
'DifferentialUnitTestResult' => 'applications/differential/constants/DifferentialUnitTestResult.php',
'DifferentialViewPolicyField' => 'applications/differential/customfield/DifferentialViewPolicyField.php',
'DiffusionArcanistProjectDatasource' => 'applications/diffusion/typeahead/DiffusionArcanistProjectDatasource.php',
'DiffusionBranchTableController' => 'applications/diffusion/controller/DiffusionBranchTableController.php',
'DiffusionBranchTableView' => 'applications/diffusion/view/DiffusionBranchTableView.php',
'DiffusionBrowseController' => 'applications/diffusion/controller/DiffusionBrowseController.php',
@ -3175,6 +3176,7 @@ phutil_register_library_map(array(
'DifferentialTransactionView' => 'PhabricatorApplicationTransactionView',
'DifferentialUnitField' => 'DifferentialCustomField',
'DifferentialViewPolicyField' => 'DifferentialCoreCustomField',
'DiffusionArcanistProjectDatasource' => 'PhabricatorTypeaheadDatasource',
'DiffusionBranchTableController' => 'DiffusionController',
'DiffusionBranchTableView' => 'DiffusionView',
'DiffusionBrowseController' => 'DiffusionController',

View file

@ -0,0 +1,30 @@
<?php
final class DiffusionArcanistProjectDatasource
extends PhabricatorTypeaheadDatasource {
public function getPlaceholderText() {
return pht('Type an arcanist project name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorApplicationDiffusion';
}
public function loadResults() {
$viewer = $this->getViewer();
$raw_query = $this->getRawQuery();
$results = array();
$arcprojs = id(new PhabricatorRepositoryArcanistProject())->loadAll();
foreach ($arcprojs as $proj) {
$results[] = id(new PhabricatorTypeaheadResult())
->setName($proj->getName())
->setPHID($proj->getPHID());
}
return $results;
}
}

View file

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

View file

@ -95,7 +95,7 @@ final class PhabricatorRepositoryArcanistProjectEditController
id(new AphrontFormTokenizerControl())
->setLabel('Uses Symbols From')
->setName('symbolIndexProjects')
->setDatasource('/typeahead/common/arcanistprojects/')
->setDatasource(new DiffusionArcanistProjectDatasource())
->setValue($uses))
->appendChild(
id(new AphrontFormSubmitControl())

View file

@ -28,7 +28,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
$need_projs = false;
$need_packages = false;
$need_upforgrabs = false;
$need_arcanist_projects = false;
$need_noproject = false;
$need_symbols = false;
$need_jump_objects = false;
@ -76,9 +75,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
case 'packages':
$need_packages = true;
break;
case 'arcanistprojects':
$need_arcanist_projects = true;
break;
}
$results = array();
@ -243,15 +239,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
}
}
if ($need_arcanist_projects) {
$arcprojs = id(new PhabricatorRepositoryArcanistProject())->loadAll();
foreach ($arcprojs as $proj) {
$results[] = id(new PhabricatorTypeaheadResult())
->setName($proj->getName())
->setPHID($proj->getPHID());
}
}
if ($need_applications) {
$applications = PhabricatorApplication::getAllInstalledApplications();
foreach ($applications as $application) {