Skip to content

Commit 4c4fcb0

Browse files
author
epriestley
committedJul 29, 2013
Use ApplicationPHIDs to power object name typehaead results
Summary: Ref T2715. When you type "T12", etc., into the search box, use ApplicationPHIDs to try to find an object name match. Test Plan: Typed "T12", "rP", "Q11", etc. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6618
1 parent 5cc3bbf commit 4c4fcb0

File tree

4 files changed

+98
-122
lines changed

4 files changed

+98
-122
lines changed
 

‎src/__celerity_resource_map__.php

+63-63
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@
21502150
),
21512151
'javelin-behavior-phabricator-search-typeahead' =>
21522152
array(
2153-
'uri' => '/res/439de76f/rsrc/js/core/behavior-search-typeahead.js',
2153+
'uri' => '/res/409d9567/rsrc/js/core/behavior-search-typeahead.js',
21542154
'type' => 'js',
21552155
'requires' =>
21562156
array(
@@ -2744,7 +2744,7 @@
27442744
),
27452745
'javelin-typeahead-ondemand-source' =>
27462746
array(
2747-
'uri' => '/res/4e5add88/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js',
2747+
'uri' => '/res/92286a21/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js',
27482748
'type' => 'js',
27492749
'requires' =>
27502750
array(
@@ -4242,7 +4242,7 @@
42424242
'uri' => '/res/pkg/4bd2b460/core.pkg.css',
42434243
'type' => 'css',
42444244
),
4245-
'75ccea43' =>
4245+
'606f7152' =>
42464246
array(
42474247
'name' => 'core.pkg.js',
42484248
'symbols' =>
@@ -4285,7 +4285,7 @@
42854285
35 => 'phabricator-hovercard',
42864286
36 => 'javelin-behavior-phabricator-hovercards',
42874287
),
4288-
'uri' => '/res/pkg/75ccea43/core.pkg.js',
4288+
'uri' => '/res/pkg/606f7152/core.pkg.js',
42894289
'type' => 'js',
42904290
),
42914291
'4ccfeb47' =>
@@ -4372,7 +4372,7 @@
43724372
'uri' => '/res/pkg/96909266/diffusion.pkg.js',
43734373
'type' => 'js',
43744374
),
4375-
'a9f14d76' =>
4375+
'2dbbb7d1' =>
43764376
array(
43774377
'name' => 'javelin.pkg.js',
43784378
'symbols' =>
@@ -4398,7 +4398,7 @@
43984398
18 => 'javelin-tokenizer',
43994399
19 => 'javelin-history',
44004400
),
4401-
'uri' => '/res/pkg/a9f14d76/javelin.pkg.js',
4401+
'uri' => '/res/pkg/2dbbb7d1/javelin.pkg.js',
44024402
'type' => 'js',
44034403
),
44044404
'06bacb9a' =>
@@ -4455,16 +4455,16 @@
44554455
'diffusion-icons-css' => 'c8ce2d88',
44564456
'global-drag-and-drop-css' => '4bd2b460',
44574457
'inline-comment-summary-css' => 'dd27a69b',
4458-
'javelin-aphlict' => '75ccea43',
4459-
'javelin-behavior' => 'a9f14d76',
4460-
'javelin-behavior-aphlict-dropdown' => '75ccea43',
4461-
'javelin-behavior-aphlict-listen' => '75ccea43',
4462-
'javelin-behavior-aphront-basic-tokenizer' => '75ccea43',
4458+
'javelin-aphlict' => '606f7152',
4459+
'javelin-behavior' => '2dbbb7d1',
4460+
'javelin-behavior-aphlict-dropdown' => '606f7152',
4461+
'javelin-behavior-aphlict-listen' => '606f7152',
4462+
'javelin-behavior-aphront-basic-tokenizer' => '606f7152',
44634463
'javelin-behavior-aphront-drag-and-drop-textarea' => '48040be9',
4464-
'javelin-behavior-aphront-form-disable-on-submit' => '75ccea43',
4464+
'javelin-behavior-aphront-form-disable-on-submit' => '606f7152',
44654465
'javelin-behavior-audit-preview' => '96909266',
44664466
'javelin-behavior-dark-console' => '4ccfeb47',
4467-
'javelin-behavior-device' => '75ccea43',
4467+
'javelin-behavior-device' => '606f7152',
44684468
'javelin-behavior-differential-accept-with-errors' => '48040be9',
44694469
'javelin-behavior-differential-add-reviewers-and-ccs' => '48040be9',
44704470
'javelin-behavior-differential-comment-jump' => '48040be9',
@@ -4480,91 +4480,91 @@
44804480
'javelin-behavior-diffusion-commit-graph' => '96909266',
44814481
'javelin-behavior-diffusion-pull-lastmodified' => '96909266',
44824482
'javelin-behavior-error-log' => '4ccfeb47',
4483-
'javelin-behavior-global-drag-and-drop' => '75ccea43',
4484-
'javelin-behavior-history-install' => '75ccea43',
4485-
'javelin-behavior-konami' => '75ccea43',
4486-
'javelin-behavior-lightbox-attachments' => '75ccea43',
4483+
'javelin-behavior-global-drag-and-drop' => '606f7152',
4484+
'javelin-behavior-history-install' => '606f7152',
4485+
'javelin-behavior-konami' => '606f7152',
4486+
'javelin-behavior-lightbox-attachments' => '606f7152',
44874487
'javelin-behavior-load-blame' => '48040be9',
44884488
'javelin-behavior-maniphest-batch-selector' => '98f64f07',
44894489
'javelin-behavior-maniphest-subpriority-editor' => '98f64f07',
44904490
'javelin-behavior-maniphest-transaction-controls' => '98f64f07',
44914491
'javelin-behavior-maniphest-transaction-expand' => '98f64f07',
44924492
'javelin-behavior-maniphest-transaction-preview' => '98f64f07',
4493-
'javelin-behavior-phabricator-active-nav' => '75ccea43',
4494-
'javelin-behavior-phabricator-autofocus' => '75ccea43',
4495-
'javelin-behavior-phabricator-gesture' => '75ccea43',
4496-
'javelin-behavior-phabricator-hovercards' => '75ccea43',
4497-
'javelin-behavior-phabricator-keyboard-shortcuts' => '75ccea43',
4498-
'javelin-behavior-phabricator-nav' => '75ccea43',
4493+
'javelin-behavior-phabricator-active-nav' => '606f7152',
4494+
'javelin-behavior-phabricator-autofocus' => '606f7152',
4495+
'javelin-behavior-phabricator-gesture' => '606f7152',
4496+
'javelin-behavior-phabricator-hovercards' => '606f7152',
4497+
'javelin-behavior-phabricator-keyboard-shortcuts' => '606f7152',
4498+
'javelin-behavior-phabricator-nav' => '606f7152',
44994499
'javelin-behavior-phabricator-object-selector' => '48040be9',
4500-
'javelin-behavior-phabricator-oncopy' => '75ccea43',
4501-
'javelin-behavior-phabricator-remarkup-assist' => '75ccea43',
4502-
'javelin-behavior-phabricator-reveal-content' => '75ccea43',
4503-
'javelin-behavior-phabricator-search-typeahead' => '75ccea43',
4504-
'javelin-behavior-phabricator-tooltips' => '75ccea43',
4505-
'javelin-behavior-phabricator-watch-anchor' => '75ccea43',
4506-
'javelin-behavior-refresh-csrf' => '75ccea43',
4500+
'javelin-behavior-phabricator-oncopy' => '606f7152',
4501+
'javelin-behavior-phabricator-remarkup-assist' => '606f7152',
4502+
'javelin-behavior-phabricator-reveal-content' => '606f7152',
4503+
'javelin-behavior-phabricator-search-typeahead' => '606f7152',
4504+
'javelin-behavior-phabricator-tooltips' => '606f7152',
4505+
'javelin-behavior-phabricator-watch-anchor' => '606f7152',
4506+
'javelin-behavior-refresh-csrf' => '606f7152',
45074507
'javelin-behavior-repository-crossreference' => '48040be9',
4508-
'javelin-behavior-toggle-class' => '75ccea43',
4509-
'javelin-behavior-workflow' => '75ccea43',
4510-
'javelin-dom' => 'a9f14d76',
4511-
'javelin-event' => 'a9f14d76',
4512-
'javelin-history' => 'a9f14d76',
4513-
'javelin-install' => 'a9f14d76',
4514-
'javelin-json' => 'a9f14d76',
4515-
'javelin-mask' => 'a9f14d76',
4516-
'javelin-request' => 'a9f14d76',
4517-
'javelin-resource' => 'a9f14d76',
4518-
'javelin-stratcom' => 'a9f14d76',
4519-
'javelin-tokenizer' => 'a9f14d76',
4520-
'javelin-typeahead' => 'a9f14d76',
4521-
'javelin-typeahead-normalizer' => 'a9f14d76',
4522-
'javelin-typeahead-ondemand-source' => 'a9f14d76',
4523-
'javelin-typeahead-preloaded-source' => 'a9f14d76',
4524-
'javelin-typeahead-source' => 'a9f14d76',
4525-
'javelin-uri' => 'a9f14d76',
4526-
'javelin-util' => 'a9f14d76',
4527-
'javelin-vector' => 'a9f14d76',
4528-
'javelin-workflow' => 'a9f14d76',
4508+
'javelin-behavior-toggle-class' => '606f7152',
4509+
'javelin-behavior-workflow' => '606f7152',
4510+
'javelin-dom' => '2dbbb7d1',
4511+
'javelin-event' => '2dbbb7d1',
4512+
'javelin-history' => '2dbbb7d1',
4513+
'javelin-install' => '2dbbb7d1',
4514+
'javelin-json' => '2dbbb7d1',
4515+
'javelin-mask' => '2dbbb7d1',
4516+
'javelin-request' => '2dbbb7d1',
4517+
'javelin-resource' => '2dbbb7d1',
4518+
'javelin-stratcom' => '2dbbb7d1',
4519+
'javelin-tokenizer' => '2dbbb7d1',
4520+
'javelin-typeahead' => '2dbbb7d1',
4521+
'javelin-typeahead-normalizer' => '2dbbb7d1',
4522+
'javelin-typeahead-ondemand-source' => '2dbbb7d1',
4523+
'javelin-typeahead-preloaded-source' => '2dbbb7d1',
4524+
'javelin-typeahead-source' => '2dbbb7d1',
4525+
'javelin-uri' => '2dbbb7d1',
4526+
'javelin-util' => '2dbbb7d1',
4527+
'javelin-vector' => '2dbbb7d1',
4528+
'javelin-workflow' => '2dbbb7d1',
45294529
'lightbox-attachment-css' => '4bd2b460',
45304530
'maniphest-task-summary-css' => '06bacb9a',
45314531
'maniphest-transaction-detail-css' => '06bacb9a',
45324532
'phabricator-action-list-view-css' => '4bd2b460',
45334533
'phabricator-application-launch-view-css' => '4bd2b460',
4534-
'phabricator-busy' => '75ccea43',
4534+
'phabricator-busy' => '606f7152',
45354535
'phabricator-content-source-view-css' => 'dd27a69b',
45364536
'phabricator-core-css' => '4bd2b460',
45374537
'phabricator-crumbs-view-css' => '4bd2b460',
45384538
'phabricator-drag-and-drop-file-upload' => '48040be9',
4539-
'phabricator-dropdown-menu' => '75ccea43',
4540-
'phabricator-file-upload' => '75ccea43',
4539+
'phabricator-dropdown-menu' => '606f7152',
4540+
'phabricator-file-upload' => '606f7152',
45414541
'phabricator-filetree-view-css' => '4bd2b460',
45424542
'phabricator-flag-css' => '4bd2b460',
45434543
'phabricator-form-view-css' => '4bd2b460',
45444544
'phabricator-header-view-css' => '4bd2b460',
4545-
'phabricator-hovercard' => '75ccea43',
4545+
'phabricator-hovercard' => '606f7152',
45464546
'phabricator-jump-nav' => '4bd2b460',
4547-
'phabricator-keyboard-shortcut' => '75ccea43',
4548-
'phabricator-keyboard-shortcut-manager' => '75ccea43',
4547+
'phabricator-keyboard-shortcut' => '606f7152',
4548+
'phabricator-keyboard-shortcut-manager' => '606f7152',
45494549
'phabricator-main-menu-view' => '4bd2b460',
4550-
'phabricator-menu-item' => '75ccea43',
4550+
'phabricator-menu-item' => '606f7152',
45514551
'phabricator-nav-view-css' => '4bd2b460',
4552-
'phabricator-notification' => '75ccea43',
4552+
'phabricator-notification' => '606f7152',
45534553
'phabricator-notification-css' => '4bd2b460',
45544554
'phabricator-notification-menu-css' => '4bd2b460',
45554555
'phabricator-object-item-list-view-css' => '4bd2b460',
45564556
'phabricator-object-selector-css' => 'dd27a69b',
4557-
'phabricator-phtize' => '75ccea43',
4558-
'phabricator-prefab' => '75ccea43',
4557+
'phabricator-phtize' => '606f7152',
4558+
'phabricator-prefab' => '606f7152',
45594559
'phabricator-project-tag-css' => '06bacb9a',
45604560
'phabricator-property-list-view-css' => '4bd2b460',
45614561
'phabricator-remarkup-css' => '4bd2b460',
45624562
'phabricator-shaped-request' => '48040be9',
45634563
'phabricator-side-menu-view-css' => '4bd2b460',
45644564
'phabricator-standard-page-view' => '4bd2b460',
45654565
'phabricator-tag-view-css' => '4bd2b460',
4566-
'phabricator-textareautils' => '75ccea43',
4567-
'phabricator-tooltip' => '75ccea43',
4566+
'phabricator-textareautils' => '606f7152',
4567+
'phabricator-tooltip' => '606f7152',
45684568
'phabricator-transaction-view-css' => '4bd2b460',
45694569
'phabricator-zindex-css' => '4bd2b460',
45704570
'phui-button-css' => '4bd2b460',

‎src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php

+18-49
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function processRequest() {
1414
$request = $this->getRequest();
1515
$viewer = $request->getUser();
1616
$query = $request->getStr('q');
17+
$raw_query = $request->getStr('raw');
1718

1819
$need_rich_data = false;
1920

@@ -304,55 +305,23 @@ public function processRequest() {
304305
}
305306

306307
if ($need_jump_objects) {
307-
$response = PhabricatorJumpNavHandler::jumpPostResponse($query);
308-
309-
if ($response) {
310-
$is_task = array();
311-
$is_revision = array();
312-
313-
preg_match('/T[0-9]+/', $response->getURI(), $is_task);
314-
preg_match('/D[0-9]+/', $response->getURI(), $is_revision);
315-
316-
if ($is_task) {
317-
for ($i = 0; $i < count($is_task); $i++) {
318-
$is_task[$i] = substr($is_task[$i], 1); // Remove leading 'T'.
319-
}
320-
$tasks = id(new ManiphestTaskQuery())
321-
->setViewer($viewer)
322-
->withTaskIDs($is_task)
323-
->execute();
324-
325-
if ($tasks) {
326-
foreach ($tasks as $task) {
327-
$results[] = id(new PhabricatorTypeaheadResult())
328-
->setName('T'.$task->getID())
329-
->setDisplayType("Task")
330-
->setURI('/T'.$task->getID())
331-
->setPHID($task->getPHID())
332-
->setPriorityType('jump');
333-
}
334-
}
335-
}
336-
337-
if ($is_revision) {
338-
for ($i = 0; $i < count($is_revision); $i++) {
339-
$is_revision[$i] = substr($is_revision[$i], 1);
340-
}
341-
$revisions = id(new DifferentialRevisionQuery())
342-
->setViewer($viewer)
343-
->withIDs($is_revision)
344-
->execute();
345-
346-
if ($revisions) {
347-
foreach ($revisions as $revision) {
348-
$results[] = id(new PhabricatorTypeaheadResult())
349-
->setName('D'.$revision->getID())
350-
->setDisplayType("Revision")
351-
->setURI('/D'.$revision->getID())
352-
->setPHID($revision->getPHID())
353-
->setPriorityType('jump');
354-
}
355-
}
308+
$objects = id(new PhabricatorObjectQuery())
309+
->setViewer($viewer)
310+
->withNames(array($raw_query))
311+
->execute();
312+
if ($objects) {
313+
$handles = id(new PhabricatorHandleQuery())
314+
->setViewer($viewer)
315+
->withPHIDs(mpull($objects, 'getPHID'))
316+
->execute();
317+
$handle = head($handles);
318+
if ($handle) {
319+
$results[] = id(new PhabricatorTypeaheadResult())
320+
->setName($handle->getFullName())
321+
->setDisplayType($handle->getTypeName())
322+
->setURI($handle->getURI())
323+
->setPHID($handle->getPHID())
324+
->setPriorityType('jump');
356325
}
357326
}
358327
}

‎webroot/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,30 @@ JX.install('TypeaheadOnDemandSource', {
4141
lastChange : null,
4242
haveData : null,
4343

44-
didChange : function(value) {
44+
didChange : function(raw_value) {
4545
this.lastChange = JX.now();
46-
value = this.normalize(value);
46+
var value = this.normalize(raw_value);
4747

4848
if (this.haveData[value]) {
4949
this.matchResults(value);
5050
} else {
5151
this.waitForResults();
5252
setTimeout(
53-
JX.bind(this, this.sendRequest, this.lastChange, value),
53+
JX.bind(this, this.sendRequest, this.lastChange, value, raw_value),
5454
this.getQueryDelay()
5555
);
5656
}
5757
},
5858

59-
sendRequest : function(when, value) {
59+
sendRequest : function(when, value, raw_value) {
6060
if (when != this.lastChange) {
6161
return;
6262
}
6363
var r = new JX.Request(
6464
this.uri,
6565
JX.bind(this, this.ondata, this.lastChange, value));
6666
r.setMethod('GET');
67-
r.setData(JX.copy(this.getAuxiliaryData(), {q : value}));
67+
r.setData(JX.copy(this.getAuxiliaryData(), {q : value, raw: raw_value}));
6868
r.send();
6969
},
7070

‎webroot/rsrc/js/core/behavior-search-typeahead.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,26 @@ JX.behavior('phabricator-search-typeahead', function(config) {
8989
});
9090

9191
// If we have more results than fit, limit each type of result to 3, so
92-
// we show 3 applications, then 3 users, etc.
92+
// we show 3 applications, then 3 users, etc. For jump items, we show only
93+
// one result.
9394
var type_count = 0;
9495
var current_type = null;
9596
for (ii = 0; ii < list.length; ii++) {
96-
if (list.length <= config.limit) {
97-
break;
98-
}
9997
if (list[ii].type != current_type) {
10098
current_type = list[ii].type;
10199
type_count = 1;
102100
} else {
103101
type_count++;
104-
if (type_count > 3) {
102+
103+
// Skip this item if:
104+
// - it's a jump nav item, and we already have at least one jump
105+
// nav item; or
106+
// - we have more items than will fit in the typeahead, and this
107+
// is the 4..Nth result of its type.
108+
109+
var skip = ((current_type == 'jump') && (type_count > 1)) ||
110+
((list.length > config.limit) && (type_count > 3));
111+
if (skip) {
105112
list.splice(ii, 1);
106113
ii--;
107114
}

0 commit comments

Comments
 (0)
Failed to load comments.