mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +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:
parent
778c970e31
commit
ca5a2641a6
10 changed files with 28 additions and 17 deletions
|
@ -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',
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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...'),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue