mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-19 03:01:11 +01:00
Modernize "user, project or package" typeahead datasource
Summary: Ref T4420. Call this "auditor" since that's what it is. Test Plan: - Edited auditors in auditor search. - Edited auditors in "add auditors" in Diffusion. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9888
This commit is contained in:
parent
ca5a2641a6
commit
cab442fe8c
6 changed files with 28 additions and 23 deletions
|
@ -465,6 +465,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialUnitTestResult' => 'applications/differential/constants/DifferentialUnitTestResult.php',
|
||||
'DifferentialViewPolicyField' => 'applications/differential/customfield/DifferentialViewPolicyField.php',
|
||||
'DiffusionArcanistProjectDatasource' => 'applications/diffusion/typeahead/DiffusionArcanistProjectDatasource.php',
|
||||
'DiffusionAuditorDatasource' => 'applications/diffusion/typeahead/DiffusionAuditorDatasource.php',
|
||||
'DiffusionBranchTableController' => 'applications/diffusion/controller/DiffusionBranchTableController.php',
|
||||
'DiffusionBranchTableView' => 'applications/diffusion/view/DiffusionBranchTableView.php',
|
||||
'DiffusionBrowseController' => 'applications/diffusion/controller/DiffusionBrowseController.php',
|
||||
|
@ -3186,6 +3187,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialUnitField' => 'DifferentialCustomField',
|
||||
'DifferentialViewPolicyField' => 'DifferentialCoreCustomField',
|
||||
'DiffusionArcanistProjectDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'DiffusionAuditorDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'DiffusionBranchTableController' => 'DiffusionController',
|
||||
'DiffusionBranchTableView' => 'DiffusionView',
|
||||
'DiffusionBrowseController' => 'DiffusionController',
|
||||
|
|
|
@ -85,7 +85,7 @@ final class PhabricatorCommitSearchEngine
|
|||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/usersprojectsorpackages/')
|
||||
->setDatasource(new DiffusionAuditorDatasource())
|
||||
->setName('auditorPHIDs')
|
||||
->setLabel(pht('Auditors'))
|
||||
->setValue(array_select_keys($handles, $auditor_phids)))
|
||||
|
|
|
@ -772,6 +772,7 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
require_celerity_resource('phabricator-transaction-view-css');
|
||||
|
||||
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||
$auditor_source = new DiffusionAuditorDatasource();
|
||||
|
||||
Javelin::initBehavior(
|
||||
'differential-add-reviewers-and-ccs',
|
||||
|
@ -779,9 +780,9 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
'dynamic' => array(
|
||||
'add-auditors-tokenizer' => array(
|
||||
'actions' => array('add_auditors' => 1),
|
||||
'src' => '/typeahead/common/usersprojectsorpackages/',
|
||||
'src' => $auditor_source->getDatasourceURI(),
|
||||
'row' => 'add-auditors',
|
||||
'placeholder' => pht('Type a user, project, or package name...'),
|
||||
'placeholder' => $auditor_source->getPlaceholderText(),
|
||||
),
|
||||
'add-ccs-tokenizer' => array(
|
||||
'actions' => array('add_ccs' => 1),
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionAuditorDatasource
|
||||
extends PhabricatorTypeaheadCompositeDatasource {
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type a user, project or package name...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorApplicationDiffusion';
|
||||
}
|
||||
|
||||
public function getComponentDatasources() {
|
||||
return array(
|
||||
new PhabricatorPeopleDatasource(),
|
||||
new PhabricatorProjectDatasource(),
|
||||
new PhabricatorOwnersPackageDatasource(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,10 +22,8 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_rich_data = false;
|
||||
|
||||
$need_users = false;
|
||||
$need_agents = false;
|
||||
$need_applications = false;
|
||||
$need_projs = false;
|
||||
$need_packages = false;
|
||||
$need_upforgrabs = false;
|
||||
$need_noproject = false;
|
||||
$need_symbols = false;
|
||||
|
@ -47,11 +45,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_projs = true;
|
||||
$need_noproject = true;
|
||||
break;
|
||||
case 'usersprojectsorpackages':
|
||||
$need_users = true;
|
||||
$need_projs = true;
|
||||
$need_packages = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
@ -193,17 +186,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
}
|
||||
}
|
||||
|
||||
if ($need_packages) {
|
||||
$packages = id(new PhabricatorOwnersPackage())->loadAll();
|
||||
foreach ($packages as $package) {
|
||||
$results[] = id(new PhabricatorTypeaheadResult())
|
||||
->setIcon('fa-list-alt bluegrey')
|
||||
->setName($package->getName())
|
||||
->setURI('/owners/package/'.$package->getID().'/')
|
||||
->setPHID($package->getPHID());
|
||||
}
|
||||
}
|
||||
|
||||
if ($need_applications) {
|
||||
$applications = PhabricatorApplication::getAllInstalledApplications();
|
||||
foreach ($applications as $application) {
|
||||
|
|
|
@ -97,8 +97,6 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
|
|||
$map = array(
|
||||
'searchowner' => pht('Type a user name...'),
|
||||
'searchproject' => pht('Type a project name...'),
|
||||
'usersprojectsorpackages' =>
|
||||
pht('Type a user, project, or package name...'),
|
||||
);
|
||||
|
||||
return idx($map, $request);
|
||||
|
|
Loading…
Reference in a new issue