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

Modernize "user or project" typeahead datasources

Summary: Ref T4420. These are used for some stuff like "reviewer".

Test Plan:
- Edited "reviewers" in differential edit.
- Edited "reviewers" in differential search.
- Edited "reviewers" in Differential "add reviewers..." action on detail page.
- Edited a "reviewers" field in a herald rule.
- Edited "owner" in owners search.
- Edited "primary owner", "owners" on owners edit.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4420

Differential Revision: https://secure.phabricator.com/D9887
This commit is contained in:
epriestley 2014-07-17 15:45:07 -07:00
parent 778c970e31
commit ca5a2641a6
10 changed files with 28 additions and 17 deletions

View file

@ -2011,6 +2011,7 @@ phutil_register_library_map(array(
'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php',
'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php',
'PhabricatorProjectObjectHasProjectEdgeType' => 'applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php',
'PhabricatorProjectOrUserDatasource' => 'applications/project/typeahead/PhabricatorProjectOrUserDatasource.php',
'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php',
'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php',
'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php',
@ -4827,6 +4828,7 @@ phutil_register_library_map(array(
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
'PhabricatorProjectNameCollisionException' => 'Exception',
'PhabricatorProjectObjectHasProjectEdgeType' => 'PhabricatorEdgeType',
'PhabricatorProjectOrUserDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType',
'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType',
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',

View file

@ -69,7 +69,7 @@ final class DifferentialReviewersField
public function renderEditControl(array $handles) {
return id(new AphrontFormTokenizerControl())
->setName($this->getFieldKey())
->setDatasource('/typeahead/common/usersorprojects/')
->setDatasource(new PhabricatorProjectOrUserDatasource())
->setValue($handles)
->setError($this->getFieldError())
->setLabel($this->getFieldName());

View file

@ -155,7 +155,7 @@ final class DifferentialRevisionSearchEngine
id(new AphrontFormTokenizerControl())
->setLabel(pht('Reviewers'))
->setName('reviewers')
->setDatasource('/typeahead/common/accountsorprojects/')
->setDatasource(new PhabricatorProjectOrUserDatasource())
->setValue(array_select_keys($handles, $reviewer_phids)))
->appendChild(
id(new AphrontFormTokenizerControl())

View file

@ -109,6 +109,7 @@ final class DifferentialAddCommentView extends AphrontView {
->setValue(pht('Submit')));
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
$reviewer_source = new PhabricatorProjectOrUserDatasource();
Javelin::initBehavior(
'differential-add-reviewers-and-ccs',
@ -120,11 +121,11 @@ final class DifferentialAddCommentView extends AphrontView {
'add_reviewers' => 1,
'resign' => 1,
),
'src' => '/typeahead/common/usersorprojects/',
'src' => $reviewer_source->getDatasourceURI(),
'value' => $this->reviewers,
'row' => 'add-reviewers',
'labels' => $add_reviewers_labels,
'placeholder' => pht('Type a user or project name...'),
'placeholder' => $reviewer_source->getPlaceholderText(),
),
'add-ccs-tokenizer' => array(
'actions' => array('add_ccs' => 1),

View file

@ -598,12 +598,10 @@ final class HeraldRuleController extends HeraldController {
'project' => new PhabricatorProjectDatasource(),
'user' => new PhabricatorPeopleDatasource(),
'email' => new PhabricatorMetaMTAMailableDatasource(),
'userorproject' => new PhabricatorProjectOrUserDatasource(),
);
$sources = mpull($sources, 'getDatasourceURI');
$sources += array(
'userorproject' => '/typeahead/common/accountsorprojects/',
);
return array(
'source' => $sources,

View file

@ -181,7 +181,7 @@ final class PhabricatorOwnersEditController
->setError($e_name))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/usersorprojects/')
->setDatasource(new PhabricatorProjectOrUserDatasource())
->setLabel(pht('Primary Owner'))
->setName('primary')
->setLimit(1)
@ -189,7 +189,7 @@ final class PhabricatorOwnersEditController
->setError($e_primary))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/usersorprojects/')
->setDatasource(new PhabricatorProjectOrUserDatasource())
->setLabel(pht('Owners'))
->setName('owners')
->setValue($handles_all_owners))

View file

@ -177,7 +177,7 @@ final class PhabricatorOwnersListController
->setValue($request->getStr('name')))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/usersorprojects/')
->setDatasource(new PhabricatorProjectOrUserDatasource())
->setLimit(1)
->setName('owner')
->setLabel(pht('Owner'))

View file

@ -0,0 +1,17 @@
<?php
final class PhabricatorProjectOrUserDatasource
extends PhabricatorTypeaheadCompositeDatasource {
public function getPlaceholderText() {
return pht('Type a user or project name...');
}
public function getComponentDatasources() {
return array(
new PhabricatorPeopleDatasource(),
new PhabricatorProjectDatasource(),
);
}
}

View file

@ -47,11 +47,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
$need_projs = true;
$need_noproject = true;
break;
case 'usersorprojects':
case 'accountsorprojects':
$need_users = true;
$need_projs = true;
break;
case 'usersprojectsorpackages':
$need_users = true;
$need_projs = true;

View file

@ -95,10 +95,8 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
$request = $matches[1];
$map = array(
'usersorprojects' => pht('Type a user or project name...'),
'searchowner' => pht('Type a user name...'),
'searchproject' => pht('Type a project name...'),
'accountsorprojects' => pht('Type a user or project name...'),
'usersprojectsorpackages' =>
pht('Type a user, project, or package name...'),
);