1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 13:52:40 +01:00

Always pass handles to tokenizers, not <phid -> name> maps

Summary: Ref T1279. Prerequisite for adding icons or other type information to tokenizers, since we don't currently have enough information to prefill them when rendering things from the server side. By passing handles in, the tokenizer can extract type information.

Test Plan:
- Searched by user in Audit.
- Sent Conpherence from profile page.
- Tried to send an empty conpherence.
- Searched Countdown by user.
- Edited CCs in Differential.
- Edited reviewers in Differential.
- Edited a commit's projects.
- Searched lint by owner.
- Searched feed by owner/project.
- Searched files by owner.
- Searched Herald by owner.
- Searched Legalpad by owner.
- Searched Macro by owner.
- Filtered Maniphest reports by project.
- Edited CCs in Maniphest.
- Searched Owners by owner.
- Edited an Owners package.
- Searched Paste by owner.
- Searched activity logs by owner.
- Searched for mocks by owner.
- Edited a mock's CCs.
- Searched Ponder by owner.
- Searched projects by owner.
- Edited a Releeph project's pushers.
- Searched Releeph by requestor.
- Edited "Uses Symbols" for an Arcanist project.
- Edited all tokenizers in main search.
- Searched Slowvote by user.

Reviewers: chad, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1279

Differential Revision: https://secure.phabricator.com/D7248
This commit is contained in:
epriestley 2013-10-07 12:51:24 -07:00
parent 2abbd51868
commit 0598600476
28 changed files with 66 additions and 119 deletions

View file

@ -139,9 +139,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$tok_value = null;
if ($handle) {
$tok_value = array(
$handle->getPHID() => $handle->getFullName(),
);
$tok_value = array($handle);
}
$form->appendChild(

View file

@ -11,15 +11,12 @@ final class ConpherenceNewController extends ConpherenceController {
$title = pht('New Message');
$participants = array();
$participant_prefill = null;
$message = '';
$e_participants = null;
$e_message = null;
// this comes from ajax requests from all over. should be a single phid.
$participant_prefill = $request->getStr('participant');
if ($participant_prefill) {
$participants[] = $participant_prefill;
}
if ($request->isFormPost()) {
$participants = $request->getArr('participants');
@ -47,15 +44,20 @@ final class ConpherenceNewController extends ConpherenceController {
return id(new AphrontRedirectResponse())
->setURI($uri);
}
} else {
$participant_prefill = $request->getStr('participant');
if ($participant_prefill) {
$participants[] = $participant_prefill;
}
}
$participant_handles = array();
if ($participants) {
$handles = id(new PhabricatorHandleQuery())
$participant_handles = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs($participants)
->execute();
$participant_handles = mpull($handles, 'getFullName', 'getPHID');
}
$submit_uri = $this->getApplicationURI('new/');
@ -64,7 +66,7 @@ final class ConpherenceNewController extends ConpherenceController {
// TODO - we can get a better cancel_uri once we get better at crazy
// ajax jonx T2086
if ($participant_prefill) {
$handle = $handles[$participant_prefill];
$handle = $participant_handles[$participant_prefill];
$cancel_uri = $handle->getURI();
}

View file

@ -33,11 +33,10 @@ final class PhabricatorCountdownSearchEngine
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorHandleQuery())
$author_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
$upcoming = $saved_query->getParameter('upcoming');
@ -47,7 +46,7 @@ final class PhabricatorCountdownSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_tokens))
->setValue($author_handles))
->appendChild(
id(new AphrontFormCheckboxControl())
->addCheckbox(

View file

@ -50,7 +50,7 @@ final class DifferentialCCsFieldSpecification
public function renderEditControl() {
$cc_map = array();
foreach ($this->ccs as $phid) {
$cc_map[$phid] = $this->getHandle($phid)->getFullName();
$cc_map[] = $this->getHandle($phid);
}
return id(new AphrontFormTokenizerControl())
->setLabel('CC')

View file

@ -89,7 +89,7 @@ final class DifferentialReviewersFieldSpecification
public function renderEditControl() {
$reviewer_map = array();
foreach ($this->reviewers as $phid) {
$reviewer_map[$phid] = $this->getHandle($phid)->getFullName();
$reviewer_map[] = $this->getHandle($phid);
}
return id(new AphrontFormTokenizerControl())
->setLabel(pht('Reviewers'))

View file

@ -27,7 +27,7 @@ final class DiffusionCommitEditController extends DiffusionController {
$commit_phid,
$edge_type);
$handles = $this->loadViewerHandles($current_proj_phids);
$proj_t_values = mpull($handles, 'getFullName', 'getPHID');
$proj_t_values = $handles;
if ($request->isFormPost()) {
$proj_phids = $request->getArr('projects');

View file

@ -21,18 +21,14 @@ final class DiffusionLintController extends DiffusionController {
$owners = array();
if (!$drequest) {
if (!$request->getArr('owner')) {
if ($user->isLoggedIn()) {
$owners[$user->getPHID()] = $user->getFullName();
}
$owners = array($user->getPHID());
} else {
$phids = $request->getArr('owner');
$phid = reset($phids);
$handles = $this->loadViewerHandles(array($phid));
$owners[$phid] = $handles[$phid]->getFullName();
$owners = array(head($request->getArr('owner')));
}
$owner_handles = $this->loadViewerHandles($owners);
}
$codes = $this->loadLintCodes(array_keys($owners));
$codes = $this->loadLintCodes($owners);
if ($codes && !$drequest) {
// TODO: Build some real Query classes for this stuff.
@ -125,7 +121,7 @@ final class DiffusionLintController extends DiffusionController {
->setLimit(1)
->setName('owner')
->setLabel(pht('Owner'))
->setValue($owners))
->setValue($owner_handles))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Filter'));

View file

@ -66,9 +66,8 @@ final class PhabricatorFeedSearchEngine
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$tokens = mpull($handles, 'getFullName', 'getPHID');
$user_tokens = array_select_keys($tokens, $user_phids);
$proj_tokens = array_select_keys($tokens, $proj_phids);
$user_handles = array_select_keys($handles, $user_phids);
$proj_handles = array_select_keys($handles, $proj_phids);
$viewer_projects = $saved_query->getParameter('viewerProjects');
@ -78,13 +77,13 @@ final class PhabricatorFeedSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('users')
->setLabel(pht('Include Users'))
->setValue($user_tokens))
->setValue($user_handles))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/projects/')
->setName('projectPHIDs')
->setLabel(pht('Include Projects'))
->setValue($proj_tokens))
->setValue($proj_handles))
->appendChild(
id(new AphrontFormCheckboxControl())
->addCheckbox(

View file

@ -46,11 +46,10 @@ final class PhabricatorFileSearchEngine
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorHandleQuery())
$author_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
$explicit = $saved_query->getParameter('explicit');
@ -60,7 +59,7 @@ final class PhabricatorFileSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_tokens))
->setValue($author_handles))
->appendChild(
id(new AphrontFormCheckboxControl())
->addCheckbox(

View file

@ -52,11 +52,10 @@ final class HeraldRuleSearchEngine
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorHandleQuery())
$author_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
$content_type = $saved_query->getParameter('contentType');
$rule_type = $saved_query->getParameter('ruleType');
@ -67,7 +66,7 @@ final class HeraldRuleSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_tokens))
->setValue($author_handles))
->appendChild(
id(new AphrontFormSelectControl())
->setName('contentType')

View file

@ -53,7 +53,6 @@ final class LegalpadDocumentSearchEngine
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$tokens = mpull($handles, 'getFullName', 'getPHID');
$form
->appendChild(
@ -61,13 +60,13 @@ final class LegalpadDocumentSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('creators')
->setLabel(pht('Creators'))
->setValue(array_select_keys($tokens, $creator_phids)))
->setValue(array_select_keys($handles, $creator_phids)))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/users/')
->setName('contributors')
->setLabel(pht('Contributors'))
->setValue(array_select_keys($tokens, $contributor_phids)));
->setValue(array_select_keys($handles, $contributor_phids)));
$this->buildDateRange(
$form,

View file

@ -66,11 +66,10 @@ final class PhabricatorMacroSearchEngine
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorHandleQuery())
$author_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
$status = $saved_query->getParameter('status');
$names = implode(', ', $saved_query->getParameter('names', array()));
@ -89,7 +88,7 @@ final class PhabricatorMacroSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_tokens))
->setValue($author_handles))
->appendChild(
id(new AphrontFormTextControl())
->setName('nameLike')

View file

@ -265,9 +265,7 @@ final class ManiphestReportController extends ManiphestController {
$tokens = array();
if ($handle) {
$tokens = array(
$handle->getPHID() => $handle->getFullName(),
);
$tokens = array($handle);
}
$filter = $this->renderReportFilters($tokens, $has_window = false);
@ -635,9 +633,7 @@ final class ManiphestReportController extends ManiphestController {
$tokens = array();
if ($project_handle) {
$tokens = array(
$project_handle->getPHID() => $project_handle->getFullName(),
);
$tokens = array($project_handle);
}
$filter = $this->renderReportFilters($tokens, $has_window = true);

View file

@ -343,8 +343,6 @@ final class ManiphestTaskEditController extends ManiphestController {
$handles = $this->loadViewerHandles($phids);
$tvalues = mpull($handles, 'getFullName', 'getPHID');
$error_view = null;
if ($errors) {
$error_view = new AphrontErrorView();
@ -355,21 +353,19 @@ final class ManiphestTaskEditController extends ManiphestController {
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
if ($task->getOwnerPHID()) {
$assigned_value = array(
$task->getOwnerPHID() => $handles[$task->getOwnerPHID()]->getFullName(),
);
$assigned_value = array($handles[$task->getOwnerPHID()]);
} else {
$assigned_value = array();
}
if ($task->getCCPHIDs()) {
$cc_value = array_select_keys($tvalues, $task->getCCPHIDs());
$cc_value = array_select_keys($handles, $task->getCCPHIDs());
} else {
$cc_value = array();
}
if ($task->getProjectPHIDs()) {
$projects_value = array_select_keys($tvalues, $task->getProjectPHIDs());
$projects_value = array_select_keys($handles, $task->getProjectPHIDs());
} else {
$projects_value = array();
}

View file

@ -123,15 +123,12 @@ final class PhabricatorOwnersEditController
$primary = $package->getPrimaryOwnerPHID();
if ($primary && isset($handles[$primary])) {
$token_primary_owner = array(
$primary => $handles[$primary]->getFullName(),
);
$handle_primary_owner = array($handles[$primary]);
} else {
$token_primary_owner = array();
$handle_primary_owner = array();
}
$token_all_owners = array_select_keys($handles, $owners);
$token_all_owners = mpull($token_all_owners, 'getFullName');
$handles_all_owners = array_select_keys($handles, $owners);
if ($package->getID()) {
$title = pht('Edit Package');
@ -195,14 +192,14 @@ final class PhabricatorOwnersEditController
->setLabel(pht('Primary Owner'))
->setName('primary')
->setLimit(1)
->setValue($token_primary_owner)
->setValue($handle_primary_owner)
->setError($e_primary))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/usersorprojects/')
->setLabel(pht('Owners'))
->setName('owners')
->setValue($token_all_owners))
->setValue($handles_all_owners))
->appendChild(
id(new AphrontFormSelectControl())
->setName('auditing')

View file

@ -153,9 +153,7 @@ final class PhabricatorOwnersListController
$phids = $request->getArr('owner');
$phid = reset($phids);
$handles = $this->loadViewerHandles(array($phid));
$owners_search_value = array(
$phid => $handles[$phid]->getFullName(),
);
$owners_search_value = array($handles[$phid]);
}
$callsigns = array('' => pht('(Any Repository)'));

View file

@ -48,11 +48,10 @@ final class PhabricatorPasteSearchEngine
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorHandleQuery())
$author_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
$languages = $saved_query->getParameter('languages', array());
$no_language = false;
@ -70,7 +69,7 @@ final class PhabricatorPasteSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_tokens))
->setValue($author_handles))
->appendChild(
id(new AphrontFormTextControl())
->setName('languages')

View file

@ -22,16 +22,12 @@ final class PhabricatorPeopleLogsController
$handles = $this->loadViewerHandles($phids);
if ($filter_user) {
$filter_user = reset($filter_user);
$user_value = array(
$filter_user => $handles[$filter_user]->getFullName(),
);
$user_value = array($handles[$filter_user]);
}
if ($filter_actor) {
$filter_actor = reset($filter_actor);
$actor_value = array(
$filter_actor => $handles[$filter_actor]->getFullName(),
);
$actor_value = array($handles[$filter_actor]);
}
}

View file

@ -230,8 +230,6 @@ final class PholioMockEditController extends PholioController {
->withPHIDs($v_cc)
->execute();
$cc_tokens = mpull($handles, 'getFullName', 'getPHID');
$image_elements = array();
foreach ($mock_images as $mock_image) {
$image_elements[] = id(new PholioUploadedImageView())
@ -303,7 +301,7 @@ final class PholioMockEditController extends PholioController {
id(new AphrontFormTokenizerControl())
->setLabel(pht('CC'))
->setName('cc')
->setValue($cc_tokens)
->setValue($handles)
->setUser($user)
->setDatasource('/typeahead/common/mailable/'))
->appendChild(

View file

@ -27,11 +27,10 @@ final class PholioMockSearchEngine
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorHandleQuery())
$author_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
$form
->appendChild(
@ -39,8 +38,7 @@ final class PholioMockSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_tokens));
->setValue($author_handles));
}
protected function getURI($path) {

View file

@ -61,10 +61,6 @@ final class PonderQuestionSearchEngine
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$tokens = mpull($handles, 'getFullName', 'getPHID');
$author_tokens = array_select_keys($tokens, $author_phids);
$answerer_tokens = array_select_keys($tokens, $answerer_phids);
$form
->appendChild(
@ -72,13 +68,13 @@ final class PonderQuestionSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_tokens))
->setValue(array_select_keys($handles, $author_phids)))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/users/')
->setName('answerers')
->setLabel(pht('Answered By'))
->setValue($answerer_tokens))
->setValue(array_select_keys($handles, $answerer_phids)))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Status'))

View file

@ -36,11 +36,10 @@ final class PhabricatorProjectSearchEngine
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('memberPHIDs', array());
$handles = id(new PhabricatorHandleQuery())
$member_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$member_tokens = mpull($handles, 'getFullName', 'getPHID');
$status = $saved_query->getParameter('status');
@ -50,7 +49,7 @@ final class PhabricatorProjectSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('members')
->setLabel(pht('Members'))
->setValue($member_tokens))
->setValue($member_handles))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Status'))

View file

@ -135,10 +135,7 @@ final class ReleephProjectEditController extends ReleephProjectController {
->withPHIDs($pusher_phids)
->execute();
$pusher_tokens = array();
foreach ($pusher_phids as $phid) {
$pusher_tokens[$phid] = $handles[$phid]->getFullName();
}
$pusher_handles = array_select_keys($handles, $pusher_phids);
$basic_inset = id(new AphrontFormInsetView())
->setTitle(pht('Basics'))
@ -209,7 +206,7 @@ final class ReleephProjectEditController extends ReleephProjectController {
->setLabel(pht('Pushers'))
->setName('pushers')
->setDatasource('/typeahead/common/users/')
->setValue($pusher_tokens));
->setValue($pusher_handles));
$commit_author_inset = $this->buildCommitAuthorInset($commit_author);

View file

@ -60,11 +60,10 @@ final class ReleephRequestSearchEngine
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('requestorPHIDs', array());
$handles = id(new PhabricatorHandleQuery())
$requestor_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$requestor_tokens = mpull($handles, 'getFullName', 'getPHID');
$form
->appendChild(
@ -84,7 +83,7 @@ final class ReleephRequestSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('requestors')
->setLabel(pht('Requestors'))
->setValue($requestor_tokens));
->setValue($requestor_handles));
}
protected function getURI($path) {

View file

@ -59,10 +59,10 @@ final class PhabricatorRepositoryArcanistProjectEditController
}
if ($project->getSymbolIndexProjects()) {
$uses = id(new PhabricatorRepositoryArcanistProject())->loadAllWhere(
'phid in (%Ls)',
$project->getSymbolIndexProjects());
$uses = mpull($uses, 'getName', 'getPHID');
$uses = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs($project->getSymbolIndexProjects())
->execute();
} else {
$uses = array();
}

View file

@ -128,22 +128,18 @@ final class PhabricatorSearchController
$author_value = array_select_keys(
$handles,
$query->getParameter('author', array()));
$author_value = mpull($author_value, 'getFullName', 'getPHID');
$owner_value = array_select_keys(
$handles,
$query->getParameter('owner', array()));
$owner_value = mpull($owner_value, 'getFullName', 'getPHID');
$subscribers_value = array_select_keys(
$handles,
$query->getParameter('subscribers', array()));
$subscribers_value = mpull($subscribers_value, 'getFullName', 'getPHID');
$project_value = array_select_keys(
$handles,
$query->getParameter('project', array()));
$project_value = mpull($project_value, 'getFullName', 'getPHID');
$search_form = new AphrontFormView();
$search_form

View file

@ -29,11 +29,10 @@ final class PhabricatorSlowvoteSearchEngine
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorHandleQuery())
$author_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
$voted = $saved_query->getParameter('voted', false);
@ -43,7 +42,7 @@ final class PhabricatorSlowvoteSearchEngine
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_tokens))
->setValue($author_handles))
->appendChild(
id(new AphrontFormCheckboxControl())
->addCheckbox(

View file

@ -35,15 +35,8 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
$name = $this->getName();
$values = nonempty($this->getValue(), array());
// TODO: Convert tokenizers to always take raw handles. For now, we
// accept either a list of handles or a `map<phid, string>`.
try {
assert_instances_of($values, 'PhabricatorObjectHandle');
$values = mpull($values, 'getFullName', 'getPHID');
} catch (InvalidArgumentException $ex) {
// Ignore this, just use the values as provided.
}
assert_instances_of($values, 'PhabricatorObjectHandle');
$values = mpull($values, 'getFullName', 'getPHID');
if ($this->getID()) {
$id = $this->getID();