mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 21:32:43 +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',
|
'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php',
|
||||||
'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php',
|
'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php',
|
||||||
'PhabricatorProjectObjectHasProjectEdgeType' => 'applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php',
|
'PhabricatorProjectObjectHasProjectEdgeType' => 'applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php',
|
||||||
|
'PhabricatorProjectOrUserDatasource' => 'applications/project/typeahead/PhabricatorProjectOrUserDatasource.php',
|
||||||
'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php',
|
'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php',
|
||||||
'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php',
|
'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php',
|
||||||
'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php',
|
'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php',
|
||||||
|
@ -4827,6 +4828,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
|
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
|
||||||
'PhabricatorProjectNameCollisionException' => 'Exception',
|
'PhabricatorProjectNameCollisionException' => 'Exception',
|
||||||
'PhabricatorProjectObjectHasProjectEdgeType' => 'PhabricatorEdgeType',
|
'PhabricatorProjectObjectHasProjectEdgeType' => 'PhabricatorEdgeType',
|
||||||
|
'PhabricatorProjectOrUserDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||||
'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType',
|
'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType',
|
'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',
|
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',
|
||||||
|
|
|
@ -69,7 +69,7 @@ final class DifferentialReviewersField
|
||||||
public function renderEditControl(array $handles) {
|
public function renderEditControl(array $handles) {
|
||||||
return id(new AphrontFormTokenizerControl())
|
return id(new AphrontFormTokenizerControl())
|
||||||
->setName($this->getFieldKey())
|
->setName($this->getFieldKey())
|
||||||
->setDatasource('/typeahead/common/usersorprojects/')
|
->setDatasource(new PhabricatorProjectOrUserDatasource())
|
||||||
->setValue($handles)
|
->setValue($handles)
|
||||||
->setError($this->getFieldError())
|
->setError($this->getFieldError())
|
||||||
->setLabel($this->getFieldName());
|
->setLabel($this->getFieldName());
|
||||||
|
|
|
@ -155,7 +155,7 @@ final class DifferentialRevisionSearchEngine
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setLabel(pht('Reviewers'))
|
->setLabel(pht('Reviewers'))
|
||||||
->setName('reviewers')
|
->setName('reviewers')
|
||||||
->setDatasource('/typeahead/common/accountsorprojects/')
|
->setDatasource(new PhabricatorProjectOrUserDatasource())
|
||||||
->setValue(array_select_keys($handles, $reviewer_phids)))
|
->setValue(array_select_keys($handles, $reviewer_phids)))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
|
|
|
@ -109,6 +109,7 @@ final class DifferentialAddCommentView extends AphrontView {
|
||||||
->setValue(pht('Submit')));
|
->setValue(pht('Submit')));
|
||||||
|
|
||||||
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||||
|
$reviewer_source = new PhabricatorProjectOrUserDatasource();
|
||||||
|
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
'differential-add-reviewers-and-ccs',
|
'differential-add-reviewers-and-ccs',
|
||||||
|
@ -120,11 +121,11 @@ final class DifferentialAddCommentView extends AphrontView {
|
||||||
'add_reviewers' => 1,
|
'add_reviewers' => 1,
|
||||||
'resign' => 1,
|
'resign' => 1,
|
||||||
),
|
),
|
||||||
'src' => '/typeahead/common/usersorprojects/',
|
'src' => $reviewer_source->getDatasourceURI(),
|
||||||
'value' => $this->reviewers,
|
'value' => $this->reviewers,
|
||||||
'row' => 'add-reviewers',
|
'row' => 'add-reviewers',
|
||||||
'labels' => $add_reviewers_labels,
|
'labels' => $add_reviewers_labels,
|
||||||
'placeholder' => pht('Type a user or project name...'),
|
'placeholder' => $reviewer_source->getPlaceholderText(),
|
||||||
),
|
),
|
||||||
'add-ccs-tokenizer' => array(
|
'add-ccs-tokenizer' => array(
|
||||||
'actions' => array('add_ccs' => 1),
|
'actions' => array('add_ccs' => 1),
|
||||||
|
|
|
@ -598,12 +598,10 @@ final class HeraldRuleController extends HeraldController {
|
||||||
'project' => new PhabricatorProjectDatasource(),
|
'project' => new PhabricatorProjectDatasource(),
|
||||||
'user' => new PhabricatorPeopleDatasource(),
|
'user' => new PhabricatorPeopleDatasource(),
|
||||||
'email' => new PhabricatorMetaMTAMailableDatasource(),
|
'email' => new PhabricatorMetaMTAMailableDatasource(),
|
||||||
|
'userorproject' => new PhabricatorProjectOrUserDatasource(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$sources = mpull($sources, 'getDatasourceURI');
|
$sources = mpull($sources, 'getDatasourceURI');
|
||||||
$sources += array(
|
|
||||||
'userorproject' => '/typeahead/common/accountsorprojects/',
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'source' => $sources,
|
'source' => $sources,
|
||||||
|
|
|
@ -181,7 +181,7 @@ final class PhabricatorOwnersEditController
|
||||||
->setError($e_name))
|
->setError($e_name))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setDatasource('/typeahead/common/usersorprojects/')
|
->setDatasource(new PhabricatorProjectOrUserDatasource())
|
||||||
->setLabel(pht('Primary Owner'))
|
->setLabel(pht('Primary Owner'))
|
||||||
->setName('primary')
|
->setName('primary')
|
||||||
->setLimit(1)
|
->setLimit(1)
|
||||||
|
@ -189,7 +189,7 @@ final class PhabricatorOwnersEditController
|
||||||
->setError($e_primary))
|
->setError($e_primary))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setDatasource('/typeahead/common/usersorprojects/')
|
->setDatasource(new PhabricatorProjectOrUserDatasource())
|
||||||
->setLabel(pht('Owners'))
|
->setLabel(pht('Owners'))
|
||||||
->setName('owners')
|
->setName('owners')
|
||||||
->setValue($handles_all_owners))
|
->setValue($handles_all_owners))
|
||||||
|
|
|
@ -177,7 +177,7 @@ final class PhabricatorOwnersListController
|
||||||
->setValue($request->getStr('name')))
|
->setValue($request->getStr('name')))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setDatasource('/typeahead/common/usersorprojects/')
|
->setDatasource(new PhabricatorProjectOrUserDatasource())
|
||||||
->setLimit(1)
|
->setLimit(1)
|
||||||
->setName('owner')
|
->setName('owner')
|
||||||
->setLabel(pht('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_projs = true;
|
||||||
$need_noproject = true;
|
$need_noproject = true;
|
||||||
break;
|
break;
|
||||||
case 'usersorprojects':
|
|
||||||
case 'accountsorprojects':
|
|
||||||
$need_users = true;
|
|
||||||
$need_projs = true;
|
|
||||||
break;
|
|
||||||
case 'usersprojectsorpackages':
|
case 'usersprojectsorpackages':
|
||||||
$need_users = true;
|
$need_users = true;
|
||||||
$need_projs = true;
|
$need_projs = true;
|
||||||
|
|
|
@ -95,10 +95,8 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
|
||||||
$request = $matches[1];
|
$request = $matches[1];
|
||||||
|
|
||||||
$map = array(
|
$map = array(
|
||||||
'usersorprojects' => pht('Type a user or project name...'),
|
|
||||||
'searchowner' => pht('Type a user name...'),
|
'searchowner' => pht('Type a user name...'),
|
||||||
'searchproject' => pht('Type a project name...'),
|
'searchproject' => pht('Type a project name...'),
|
||||||
'accountsorprojects' => pht('Type a user or project name...'),
|
|
||||||
'usersprojectsorpackages' =>
|
'usersprojectsorpackages' =>
|
||||||
pht('Type a user, project, or package name...'),
|
pht('Type a user, project, or package name...'),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue