mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +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',
|
'PhabricatorMailReceiverTestCase' => 'applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php',
|
||||||
'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php',
|
'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php',
|
||||||
'PhabricatorMailgunConfigOptions' => 'applications/config/option/PhabricatorMailgunConfigOptions.php',
|
'PhabricatorMailgunConfigOptions' => 'applications/config/option/PhabricatorMailgunConfigOptions.php',
|
||||||
|
'PhabricatorMailingListDatasource' => 'applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php',
|
||||||
'PhabricatorMailingListPHIDTypeList' => 'applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php',
|
'PhabricatorMailingListPHIDTypeList' => 'applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php',
|
||||||
'PhabricatorMailingListQuery' => 'applications/mailinglists/query/PhabricatorMailingListQuery.php',
|
'PhabricatorMailingListQuery' => 'applications/mailinglists/query/PhabricatorMailingListQuery.php',
|
||||||
'PhabricatorMailingListSearchEngine' => 'applications/mailinglists/query/PhabricatorMailingListSearchEngine.php',
|
'PhabricatorMailingListSearchEngine' => 'applications/mailinglists/query/PhabricatorMailingListSearchEngine.php',
|
||||||
|
@ -1800,6 +1801,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMetaMTAMailBody' => 'applications/metamta/view/PhabricatorMetaMTAMailBody.php',
|
'PhabricatorMetaMTAMailBody' => 'applications/metamta/view/PhabricatorMetaMTAMailBody.php',
|
||||||
'PhabricatorMetaMTAMailBodyTestCase' => 'applications/metamta/view/__tests__/PhabricatorMetaMTAMailBodyTestCase.php',
|
'PhabricatorMetaMTAMailBodyTestCase' => 'applications/metamta/view/__tests__/PhabricatorMetaMTAMailBodyTestCase.php',
|
||||||
'PhabricatorMetaMTAMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php',
|
'PhabricatorMetaMTAMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php',
|
||||||
|
'PhabricatorMetaMTAMailableDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php',
|
||||||
'PhabricatorMetaMTAMailgunReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php',
|
'PhabricatorMetaMTAMailgunReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php',
|
||||||
'PhabricatorMetaMTAMailingList' => 'applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php',
|
'PhabricatorMetaMTAMailingList' => 'applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php',
|
||||||
'PhabricatorMetaMTAMemberQuery' => 'applications/metamta/query/PhabricatorMetaMTAMemberQuery.php',
|
'PhabricatorMetaMTAMemberQuery' => 'applications/metamta/query/PhabricatorMetaMTAMemberQuery.php',
|
||||||
|
@ -4567,6 +4569,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMailManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
'PhabricatorMailManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||||
'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase',
|
'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorMailgunConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorMailgunConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
|
'PhabricatorMailingListDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'PhabricatorMailingListPHIDTypeList' => 'PhabricatorPHIDType',
|
'PhabricatorMailingListPHIDTypeList' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorMailingListQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhabricatorMailingListQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhabricatorMailingListSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'PhabricatorMailingListSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
|
@ -4593,6 +4596,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMetaMTAMail' => 'PhabricatorMetaMTADAO',
|
'PhabricatorMetaMTAMail' => 'PhabricatorMetaMTADAO',
|
||||||
'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase',
|
'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorMetaMTAMailTestCase' => 'PhabricatorTestCase',
|
'PhabricatorMetaMTAMailTestCase' => 'PhabricatorTestCase',
|
||||||
|
'PhabricatorMetaMTAMailableDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||||
'PhabricatorMetaMTAMailgunReceiveController' => 'PhabricatorMetaMTAController',
|
'PhabricatorMetaMTAMailgunReceiveController' => 'PhabricatorMetaMTAController',
|
||||||
'PhabricatorMetaMTAMailingList' => array(
|
'PhabricatorMetaMTAMailingList' => array(
|
||||||
0 => 'PhabricatorMetaMTADAO',
|
0 => 'PhabricatorMetaMTADAO',
|
||||||
|
|
|
@ -44,7 +44,7 @@ final class DifferentialSubscribersField
|
||||||
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/mailable/')
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource())
|
||||||
->setValue($handles)
|
->setValue($handles)
|
||||||
->setError($this->getFieldError())
|
->setError($this->getFieldError())
|
||||||
->setLabel($this->getFieldName());
|
->setLabel($this->getFieldName());
|
||||||
|
|
|
@ -161,7 +161,7 @@ final class DifferentialRevisionSearchEngine
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setLabel(pht('Subscribers'))
|
->setLabel(pht('Subscribers'))
|
||||||
->setName('subscribers')
|
->setName('subscribers')
|
||||||
->setDatasource('/typeahead/common/allmailable/')
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource())
|
||||||
->setValue(array_select_keys($handles, $subscriber_phids)))
|
->setValue(array_select_keys($handles, $subscriber_phids)))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
|
|
|
@ -108,6 +108,8 @@ final class DifferentialAddCommentView extends AphrontView {
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->setValue(pht('Submit')));
|
->setValue(pht('Submit')));
|
||||||
|
|
||||||
|
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||||
|
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
'differential-add-reviewers-and-ccs',
|
'differential-add-reviewers-and-ccs',
|
||||||
array(
|
array(
|
||||||
|
@ -126,10 +128,10 @@ final class DifferentialAddCommentView extends AphrontView {
|
||||||
),
|
),
|
||||||
'add-ccs-tokenizer' => array(
|
'add-ccs-tokenizer' => array(
|
||||||
'actions' => array('add_ccs' => 1),
|
'actions' => array('add_ccs' => 1),
|
||||||
'src' => '/typeahead/common/mailable/',
|
'src' => $mailable_source->getDatasourceURI(),
|
||||||
'value' => $this->ccs,
|
'value' => $this->ccs,
|
||||||
'row' => 'add-ccs',
|
'row' => 'add-ccs',
|
||||||
'placeholder' => pht('Type a user or mailing list...'),
|
'placeholder' => $mailable_source->getPlaceholderText(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'select' => 'comment-action',
|
'select' => 'comment-action',
|
||||||
|
|
|
@ -771,6 +771,8 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
|
|
||||||
require_celerity_resource('phabricator-transaction-view-css');
|
require_celerity_resource('phabricator-transaction-view-css');
|
||||||
|
|
||||||
|
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||||
|
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
'differential-add-reviewers-and-ccs',
|
'differential-add-reviewers-and-ccs',
|
||||||
array(
|
array(
|
||||||
|
@ -783,9 +785,9 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
),
|
),
|
||||||
'add-ccs-tokenizer' => array(
|
'add-ccs-tokenizer' => array(
|
||||||
'actions' => array('add_ccs' => 1),
|
'actions' => array('add_ccs' => 1),
|
||||||
'src' => '/typeahead/common/mailable/',
|
'src' => $mailable_source->getDatasourceURI(),
|
||||||
'row' => 'add-ccs',
|
'row' => 'add-ccs',
|
||||||
'placeholder' => pht('Type a user or mailing list...'),
|
'placeholder' => $mailable_source->getPlaceholderText(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'select' => 'audit-action',
|
'select' => 'audit-action',
|
||||||
|
|
|
@ -597,11 +597,11 @@ final class HeraldRuleController extends HeraldController {
|
||||||
'package' => new PhabricatorOwnersPackageDatasource(),
|
'package' => new PhabricatorOwnersPackageDatasource(),
|
||||||
'project' => new PhabricatorProjectDatasource(),
|
'project' => new PhabricatorProjectDatasource(),
|
||||||
'user' => new PhabricatorPeopleDatasource(),
|
'user' => new PhabricatorPeopleDatasource(),
|
||||||
|
'email' => new PhabricatorMetaMTAMailableDatasource(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$sources = mpull($sources, 'getDatasourceURI');
|
$sources = mpull($sources, 'getDatasourceURI');
|
||||||
$sources += array(
|
$sources += array(
|
||||||
'email' => '/typeahead/common/mailable/',
|
|
||||||
'userorproject' => '/typeahead/common/accountsorprojects/',
|
'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();
|
$template = $template->render();
|
||||||
|
|
||||||
$projects_source = new PhabricatorProjectDatasource();
|
$projects_source = new PhabricatorProjectDatasource();
|
||||||
|
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||||
|
|
||||||
require_celerity_resource('maniphest-batch-editor');
|
require_celerity_resource('maniphest-batch-editor');
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
|
@ -81,8 +82,8 @@ final class ManiphestBatchEditController extends ManiphestController {
|
||||||
'limit' => 1,
|
'limit' => 1,
|
||||||
),
|
),
|
||||||
'cc' => array(
|
'cc' => array(
|
||||||
'src' => '/typeahead/common/mailable/',
|
'src' => $mailable_source->getDatasourceURI(),
|
||||||
'placeholder' => pht('Type a user name...'),
|
'placeholder' => $mailable_source->getPlaceholderText(),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'input' => 'batch-form-actions',
|
'input' => 'batch-form-actions',
|
||||||
|
|
|
@ -284,6 +284,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
||||||
|
|
||||||
$projects_source = new PhabricatorProjectDatasource();
|
$projects_source = new PhabricatorProjectDatasource();
|
||||||
$users_source = new PhabricatorPeopleDatasource();
|
$users_source = new PhabricatorPeopleDatasource();
|
||||||
|
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
|
||||||
|
|
||||||
$tokenizer_map = array(
|
$tokenizer_map = array(
|
||||||
ManiphestTransaction::TYPE_PROJECTS => array(
|
ManiphestTransaction::TYPE_PROJECTS => array(
|
||||||
|
@ -300,8 +301,8 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
||||||
),
|
),
|
||||||
ManiphestTransaction::TYPE_CCS => array(
|
ManiphestTransaction::TYPE_CCS => array(
|
||||||
'id' => 'cc-tokenizer',
|
'id' => 'cc-tokenizer',
|
||||||
'src' => '/typeahead/common/mailable/',
|
'src' => $mailable_source->getDatasourceURI(),
|
||||||
'placeholder' => pht('Type a user or mailing list...'),
|
'placeholder' => $mailable_source->getPlaceholderText(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -613,7 +613,7 @@ final class ManiphestTaskEditController extends ManiphestController {
|
||||||
->setName('cc')
|
->setName('cc')
|
||||||
->setValue($cc_value)
|
->setValue($cc_value)
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setDatasource('/typeahead/common/mailable/'));
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource()));
|
||||||
|
|
||||||
if ($can_edit_priority) {
|
if ($can_edit_priority) {
|
||||||
$form
|
$form
|
||||||
|
|
|
@ -365,7 +365,7 @@ final class ManiphestTaskSearchEngine
|
||||||
->setValue($author_handles))
|
->setValue($author_handles))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setDatasource('/typeahead/common/mailable/')
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource())
|
||||||
->setName('subscribers')
|
->setName('subscribers')
|
||||||
->setLabel(pht('Subscribers'))
|
->setLabel(pht('Subscribers'))
|
||||||
->setValue($subscriber_handles))
|
->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')
|
->setName('cc')
|
||||||
->setValue($handles)
|
->setValue($handles)
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setDatasource('/typeahead/common/mailable/'))
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource()))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormPolicyControl())
|
id(new AphrontFormPolicyControl())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
|
|
@ -24,7 +24,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
||||||
$need_users = false;
|
$need_users = false;
|
||||||
$need_agents = false;
|
$need_agents = false;
|
||||||
$need_applications = false;
|
$need_applications = false;
|
||||||
$need_lists = false;
|
|
||||||
$need_projs = false;
|
$need_projs = false;
|
||||||
$need_packages = false;
|
$need_packages = false;
|
||||||
$need_upforgrabs = false;
|
$need_upforgrabs = false;
|
||||||
|
@ -48,12 +47,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
||||||
$need_projs = true;
|
$need_projs = true;
|
||||||
$need_noproject = true;
|
$need_noproject = true;
|
||||||
break;
|
break;
|
||||||
case 'mailable':
|
|
||||||
case 'allmailable':
|
|
||||||
$need_users = true;
|
|
||||||
$need_lists = true;
|
|
||||||
$need_projs = true;
|
|
||||||
break;
|
|
||||||
case 'usersorprojects':
|
case 'usersorprojects':
|
||||||
case 'accountsorprojects':
|
case 'accountsorprojects':
|
||||||
$need_users = true;
|
$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) {
|
if ($need_projs) {
|
||||||
$projs = id(new PhabricatorProjectQuery())
|
$projs = id(new PhabricatorProjectQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
|
|
@ -95,19 +95,9 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
|
||||||
$request = $matches[1];
|
$request = $matches[1];
|
||||||
|
|
||||||
$map = array(
|
$map = array(
|
||||||
'users' => pht('Type a user name...'),
|
|
||||||
'authors' => pht('Type a user name...'),
|
|
||||||
'usersorprojects' => pht('Type a user or project name...'),
|
'usersorprojects' => pht('Type a user or project name...'),
|
||||||
'searchowner' => pht('Type a user 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...'),
|
'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...'),
|
'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