mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Modernize "mailable" typeahead datasources
Summary: Ref T4420. Modernize the mailing list datasource, then build a composite "mailable" datasource. Test Plan: - Edited "subscribers" field in Differential revision edit. - Edited "subscribers" field in Differential search. - Edited "add subscribers" field in differential revision view. - Edited "add ccs" field in Diffusion commit view. - Edited "add emails to CC" in a Herald rule. - Edited "add ccs" in maniphest bulk editor. - Edited "add ccs" in maniphest task detail view. - Edited "CC" on maniphest edit view. - Edited "subscribers" on maniphest task earch view. - Edited "CC" on pholio mock edit. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9886
This commit is contained in:
parent
dcc6997793
commit
778c970e31
15 changed files with 79 additions and 43 deletions
|
@ -1768,6 +1768,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMailReceiverTestCase' => 'applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php',
|
||||
'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php',
|
||||
'PhabricatorMailgunConfigOptions' => 'applications/config/option/PhabricatorMailgunConfigOptions.php',
|
||||
'PhabricatorMailingListDatasource' => 'applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php',
|
||||
'PhabricatorMailingListPHIDTypeList' => 'applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php',
|
||||
'PhabricatorMailingListQuery' => 'applications/mailinglists/query/PhabricatorMailingListQuery.php',
|
||||
'PhabricatorMailingListSearchEngine' => 'applications/mailinglists/query/PhabricatorMailingListSearchEngine.php',
|
||||
|
@ -1800,6 +1801,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMetaMTAMailBody' => 'applications/metamta/view/PhabricatorMetaMTAMailBody.php',
|
||||
'PhabricatorMetaMTAMailBodyTestCase' => 'applications/metamta/view/__tests__/PhabricatorMetaMTAMailBodyTestCase.php',
|
||||
'PhabricatorMetaMTAMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php',
|
||||
'PhabricatorMetaMTAMailableDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php',
|
||||
'PhabricatorMetaMTAMailgunReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php',
|
||||
'PhabricatorMetaMTAMailingList' => 'applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php',
|
||||
'PhabricatorMetaMTAMemberQuery' => 'applications/metamta/query/PhabricatorMetaMTAMemberQuery.php',
|
||||
|
@ -4567,6 +4569,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMailManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||
'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorMailgunConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorMailingListDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'PhabricatorMailingListPHIDTypeList' => 'PhabricatorPHIDType',
|
||||
'PhabricatorMailingListQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorMailingListSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
|
@ -4593,6 +4596,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMetaMTAMail' => 'PhabricatorMetaMTADAO',
|
||||
'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorMetaMTAMailTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorMetaMTAMailableDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'PhabricatorMetaMTAMailgunReceiveController' => 'PhabricatorMetaMTAController',
|
||||
'PhabricatorMetaMTAMailingList' => array(
|
||||
0 => 'PhabricatorMetaMTADAO',
|
||||
|
|
|
@ -44,7 +44,7 @@ final class DifferentialSubscribersField
|
|||
public function renderEditControl(array $handles) {
|
||||
return id(new AphrontFormTokenizerControl())
|
||||
->setName($this->getFieldKey())
|
||||
->setDatasource('/typeahead/common/mailable/')
|
||||
->setDatasource(new PhabricatorMetaMTAMailableDatasource())
|
||||
->setValue($handles)
|
||||
->setError($this->getFieldError())
|
||||
->setLabel($this->getFieldName());
|
||||
|
|
|
@ -161,7 +161,7 @@ final class DifferentialRevisionSearchEngine
|
|||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('Subscribers'))
|
||||
->setName('subscribers')
|
||||
->setDatasource('/typeahead/common/allmailable/')
|
||||
->setDatasource(new PhabricatorMetaMTAMailableDatasource())
|
||||
->setValue(array_select_keys($handles, $subscriber_phids)))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
|
|
|
@ -108,6 +108,8 @@ final class DifferentialAddCommentView extends AphrontView {
|
|||
id(new AphrontFormSubmitControl())
|
||||
->setValue(pht('Submit')));
|
||||
|
||||
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||
|
||||
Javelin::initBehavior(
|
||||
'differential-add-reviewers-and-ccs',
|
||||
array(
|
||||
|
@ -126,10 +128,10 @@ final class DifferentialAddCommentView extends AphrontView {
|
|||
),
|
||||
'add-ccs-tokenizer' => array(
|
||||
'actions' => array('add_ccs' => 1),
|
||||
'src' => '/typeahead/common/mailable/',
|
||||
'src' => $mailable_source->getDatasourceURI(),
|
||||
'value' => $this->ccs,
|
||||
'row' => 'add-ccs',
|
||||
'placeholder' => pht('Type a user or mailing list...'),
|
||||
'placeholder' => $mailable_source->getPlaceholderText(),
|
||||
),
|
||||
),
|
||||
'select' => 'comment-action',
|
||||
|
|
|
@ -771,6 +771,8 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
|
||||
require_celerity_resource('phabricator-transaction-view-css');
|
||||
|
||||
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||
|
||||
Javelin::initBehavior(
|
||||
'differential-add-reviewers-and-ccs',
|
||||
array(
|
||||
|
@ -783,9 +785,9 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
),
|
||||
'add-ccs-tokenizer' => array(
|
||||
'actions' => array('add_ccs' => 1),
|
||||
'src' => '/typeahead/common/mailable/',
|
||||
'src' => $mailable_source->getDatasourceURI(),
|
||||
'row' => 'add-ccs',
|
||||
'placeholder' => pht('Type a user or mailing list...'),
|
||||
'placeholder' => $mailable_source->getPlaceholderText(),
|
||||
),
|
||||
),
|
||||
'select' => 'audit-action',
|
||||
|
|
|
@ -597,11 +597,11 @@ final class HeraldRuleController extends HeraldController {
|
|||
'package' => new PhabricatorOwnersPackageDatasource(),
|
||||
'project' => new PhabricatorProjectDatasource(),
|
||||
'user' => new PhabricatorPeopleDatasource(),
|
||||
'email' => new PhabricatorMetaMTAMailableDatasource(),
|
||||
);
|
||||
|
||||
$sources = mpull($sources, 'getDatasourceURI');
|
||||
$sources += array(
|
||||
'email' => '/typeahead/common/mailable/',
|
||||
'userorproject' => '/typeahead/common/accountsorprojects/',
|
||||
);
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorMailingListDatasource
|
||||
extends PhabricatorTypeaheadDatasource {
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type a mailing list name...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorApplicationMailingLists';
|
||||
}
|
||||
|
||||
public function loadResults() {
|
||||
$viewer = $this->getViewer();
|
||||
$raw_query = $this->getRawQuery();
|
||||
|
||||
$results = array();
|
||||
|
||||
$lists = id(new PhabricatorMailingListQuery())
|
||||
->setViewer($viewer)
|
||||
->execute();
|
||||
foreach ($lists as $list) {
|
||||
$results[] = id(new PhabricatorTypeaheadResult())
|
||||
->setName($list->getName())
|
||||
->setURI($list->getURI())
|
||||
->setPHID($list->getPHID());
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
|
@ -62,6 +62,7 @@ final class ManiphestBatchEditController extends ManiphestController {
|
|||
$template = $template->render();
|
||||
|
||||
$projects_source = new PhabricatorProjectDatasource();
|
||||
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||
|
||||
require_celerity_resource('maniphest-batch-editor');
|
||||
Javelin::initBehavior(
|
||||
|
@ -81,8 +82,8 @@ final class ManiphestBatchEditController extends ManiphestController {
|
|||
'limit' => 1,
|
||||
),
|
||||
'cc' => array(
|
||||
'src' => '/typeahead/common/mailable/',
|
||||
'placeholder' => pht('Type a user name...'),
|
||||
'src' => $mailable_source->getDatasourceURI(),
|
||||
'placeholder' => $mailable_source->getPlaceholderText(),
|
||||
)
|
||||
),
|
||||
'input' => 'batch-form-actions',
|
||||
|
|
|
@ -284,6 +284,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
|
||||
$projects_source = new PhabricatorProjectDatasource();
|
||||
$users_source = new PhabricatorPeopleDatasource();
|
||||
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||
|
||||
$tokenizer_map = array(
|
||||
ManiphestTransaction::TYPE_PROJECTS => array(
|
||||
|
@ -300,8 +301,8 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
),
|
||||
ManiphestTransaction::TYPE_CCS => array(
|
||||
'id' => 'cc-tokenizer',
|
||||
'src' => '/typeahead/common/mailable/',
|
||||
'placeholder' => pht('Type a user or mailing list...'),
|
||||
'src' => $mailable_source->getDatasourceURI(),
|
||||
'placeholder' => $mailable_source->getPlaceholderText(),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -613,7 +613,7 @@ final class ManiphestTaskEditController extends ManiphestController {
|
|||
->setName('cc')
|
||||
->setValue($cc_value)
|
||||
->setUser($user)
|
||||
->setDatasource('/typeahead/common/mailable/'));
|
||||
->setDatasource(new PhabricatorMetaMTAMailableDatasource()));
|
||||
|
||||
if ($can_edit_priority) {
|
||||
$form
|
||||
|
|
|
@ -365,7 +365,7 @@ final class ManiphestTaskSearchEngine
|
|||
->setValue($author_handles))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/mailable/')
|
||||
->setDatasource(new PhabricatorMetaMTAMailableDatasource())
|
||||
->setName('subscribers')
|
||||
->setLabel(pht('Subscribers'))
|
||||
->setValue($subscriber_handles))
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorMetaMTAMailableDatasource
|
||||
extends PhabricatorTypeaheadCompositeDatasource {
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type a user, project, or mailing list name...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorApplicationMetaMTA';
|
||||
}
|
||||
|
||||
public function getComponentDatasources() {
|
||||
return array(
|
||||
new PhabricatorPeopleDatasource(),
|
||||
new PhabricatorProjectDatasource(),
|
||||
new PhabricatorMailingListDatasource(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -354,7 +354,7 @@ final class PholioMockEditController extends PholioController {
|
|||
->setName('cc')
|
||||
->setValue($handles)
|
||||
->setUser($user)
|
||||
->setDatasource('/typeahead/common/mailable/'))
|
||||
->setDatasource(new PhabricatorMetaMTAMailableDatasource()))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setUser($user)
|
||||
|
|
|
@ -24,7 +24,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_users = false;
|
||||
$need_agents = false;
|
||||
$need_applications = false;
|
||||
$need_lists = false;
|
||||
$need_projs = false;
|
||||
$need_packages = false;
|
||||
$need_upforgrabs = false;
|
||||
|
@ -48,12 +47,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_projs = true;
|
||||
$need_noproject = true;
|
||||
break;
|
||||
case 'mailable':
|
||||
case 'allmailable':
|
||||
$need_users = true;
|
||||
$need_lists = true;
|
||||
$need_projs = true;
|
||||
break;
|
||||
case 'usersorprojects':
|
||||
case 'accountsorprojects':
|
||||
$need_users = true;
|
||||
|
@ -179,18 +172,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
}
|
||||
}
|
||||
|
||||
if ($need_lists) {
|
||||
$lists = id(new PhabricatorMailingListQuery())
|
||||
->setViewer($viewer)
|
||||
->execute();
|
||||
foreach ($lists as $list) {
|
||||
$results[] = id(new PhabricatorTypeaheadResult())
|
||||
->setName($list->getName())
|
||||
->setURI($list->getURI())
|
||||
->setPHID($list->getPHID());
|
||||
}
|
||||
}
|
||||
|
||||
if ($need_projs) {
|
||||
$projs = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
|
|
|
@ -95,19 +95,9 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
|
|||
$request = $matches[1];
|
||||
|
||||
$map = array(
|
||||
'users' => pht('Type a user name...'),
|
||||
'authors' => pht('Type a user name...'),
|
||||
'usersorprojects' => pht('Type a user or project name...'),
|
||||
'searchowner' => pht('Type a user name...'),
|
||||
'accounts' => pht('Type a user name...'),
|
||||
'mailable' => pht('Type a user, project, or mailing list...'),
|
||||
'allmailable' => pht('Type a user, project, or mailing list...'),
|
||||
'searchproject' => pht('Type a project name...'),
|
||||
'projects' => pht('Type a project name...'),
|
||||
'repositories' => pht('Type a repository name...'),
|
||||
'packages' => pht('Type a package name...'),
|
||||
'macros' => pht('Type a macro name...'),
|
||||
'arcanistproject' => pht('Type an arc 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