mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-15 05:44:55 +01:00
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
This commit is contained in:
parent
5cc3bbf721
commit
4c4fcb0bd1
4 changed files with 98 additions and 122 deletions
|
@ -2150,7 +2150,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'javelin-behavior-phabricator-search-typeahead' =>
|
||||
array(
|
||||
'uri' => '/res/439de76f/rsrc/js/core/behavior-search-typeahead.js',
|
||||
'uri' => '/res/409d9567/rsrc/js/core/behavior-search-typeahead.js',
|
||||
'type' => 'js',
|
||||
'requires' =>
|
||||
array(
|
||||
|
@ -2744,7 +2744,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'javelin-typeahead-ondemand-source' =>
|
||||
array(
|
||||
'uri' => '/res/4e5add88/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js',
|
||||
'uri' => '/res/92286a21/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js',
|
||||
'type' => 'js',
|
||||
'requires' =>
|
||||
array(
|
||||
|
@ -4242,7 +4242,7 @@ celerity_register_resource_map(array(
|
|||
'uri' => '/res/pkg/4bd2b460/core.pkg.css',
|
||||
'type' => 'css',
|
||||
),
|
||||
'75ccea43' =>
|
||||
'606f7152' =>
|
||||
array(
|
||||
'name' => 'core.pkg.js',
|
||||
'symbols' =>
|
||||
|
@ -4285,7 +4285,7 @@ celerity_register_resource_map(array(
|
|||
35 => 'phabricator-hovercard',
|
||||
36 => 'javelin-behavior-phabricator-hovercards',
|
||||
),
|
||||
'uri' => '/res/pkg/75ccea43/core.pkg.js',
|
||||
'uri' => '/res/pkg/606f7152/core.pkg.js',
|
||||
'type' => 'js',
|
||||
),
|
||||
'4ccfeb47' =>
|
||||
|
@ -4372,7 +4372,7 @@ celerity_register_resource_map(array(
|
|||
'uri' => '/res/pkg/96909266/diffusion.pkg.js',
|
||||
'type' => 'js',
|
||||
),
|
||||
'a9f14d76' =>
|
||||
'2dbbb7d1' =>
|
||||
array(
|
||||
'name' => 'javelin.pkg.js',
|
||||
'symbols' =>
|
||||
|
@ -4398,7 +4398,7 @@ celerity_register_resource_map(array(
|
|||
18 => 'javelin-tokenizer',
|
||||
19 => 'javelin-history',
|
||||
),
|
||||
'uri' => '/res/pkg/a9f14d76/javelin.pkg.js',
|
||||
'uri' => '/res/pkg/2dbbb7d1/javelin.pkg.js',
|
||||
'type' => 'js',
|
||||
),
|
||||
'06bacb9a' =>
|
||||
|
@ -4455,16 +4455,16 @@ celerity_register_resource_map(array(
|
|||
'diffusion-icons-css' => 'c8ce2d88',
|
||||
'global-drag-and-drop-css' => '4bd2b460',
|
||||
'inline-comment-summary-css' => 'dd27a69b',
|
||||
'javelin-aphlict' => '75ccea43',
|
||||
'javelin-behavior' => 'a9f14d76',
|
||||
'javelin-behavior-aphlict-dropdown' => '75ccea43',
|
||||
'javelin-behavior-aphlict-listen' => '75ccea43',
|
||||
'javelin-behavior-aphront-basic-tokenizer' => '75ccea43',
|
||||
'javelin-aphlict' => '606f7152',
|
||||
'javelin-behavior' => '2dbbb7d1',
|
||||
'javelin-behavior-aphlict-dropdown' => '606f7152',
|
||||
'javelin-behavior-aphlict-listen' => '606f7152',
|
||||
'javelin-behavior-aphront-basic-tokenizer' => '606f7152',
|
||||
'javelin-behavior-aphront-drag-and-drop-textarea' => '48040be9',
|
||||
'javelin-behavior-aphront-form-disable-on-submit' => '75ccea43',
|
||||
'javelin-behavior-aphront-form-disable-on-submit' => '606f7152',
|
||||
'javelin-behavior-audit-preview' => '96909266',
|
||||
'javelin-behavior-dark-console' => '4ccfeb47',
|
||||
'javelin-behavior-device' => '75ccea43',
|
||||
'javelin-behavior-device' => '606f7152',
|
||||
'javelin-behavior-differential-accept-with-errors' => '48040be9',
|
||||
'javelin-behavior-differential-add-reviewers-and-ccs' => '48040be9',
|
||||
'javelin-behavior-differential-comment-jump' => '48040be9',
|
||||
|
@ -4480,82 +4480,82 @@ celerity_register_resource_map(array(
|
|||
'javelin-behavior-diffusion-commit-graph' => '96909266',
|
||||
'javelin-behavior-diffusion-pull-lastmodified' => '96909266',
|
||||
'javelin-behavior-error-log' => '4ccfeb47',
|
||||
'javelin-behavior-global-drag-and-drop' => '75ccea43',
|
||||
'javelin-behavior-history-install' => '75ccea43',
|
||||
'javelin-behavior-konami' => '75ccea43',
|
||||
'javelin-behavior-lightbox-attachments' => '75ccea43',
|
||||
'javelin-behavior-global-drag-and-drop' => '606f7152',
|
||||
'javelin-behavior-history-install' => '606f7152',
|
||||
'javelin-behavior-konami' => '606f7152',
|
||||
'javelin-behavior-lightbox-attachments' => '606f7152',
|
||||
'javelin-behavior-load-blame' => '48040be9',
|
||||
'javelin-behavior-maniphest-batch-selector' => '98f64f07',
|
||||
'javelin-behavior-maniphest-subpriority-editor' => '98f64f07',
|
||||
'javelin-behavior-maniphest-transaction-controls' => '98f64f07',
|
||||
'javelin-behavior-maniphest-transaction-expand' => '98f64f07',
|
||||
'javelin-behavior-maniphest-transaction-preview' => '98f64f07',
|
||||
'javelin-behavior-phabricator-active-nav' => '75ccea43',
|
||||
'javelin-behavior-phabricator-autofocus' => '75ccea43',
|
||||
'javelin-behavior-phabricator-gesture' => '75ccea43',
|
||||
'javelin-behavior-phabricator-hovercards' => '75ccea43',
|
||||
'javelin-behavior-phabricator-keyboard-shortcuts' => '75ccea43',
|
||||
'javelin-behavior-phabricator-nav' => '75ccea43',
|
||||
'javelin-behavior-phabricator-active-nav' => '606f7152',
|
||||
'javelin-behavior-phabricator-autofocus' => '606f7152',
|
||||
'javelin-behavior-phabricator-gesture' => '606f7152',
|
||||
'javelin-behavior-phabricator-hovercards' => '606f7152',
|
||||
'javelin-behavior-phabricator-keyboard-shortcuts' => '606f7152',
|
||||
'javelin-behavior-phabricator-nav' => '606f7152',
|
||||
'javelin-behavior-phabricator-object-selector' => '48040be9',
|
||||
'javelin-behavior-phabricator-oncopy' => '75ccea43',
|
||||
'javelin-behavior-phabricator-remarkup-assist' => '75ccea43',
|
||||
'javelin-behavior-phabricator-reveal-content' => '75ccea43',
|
||||
'javelin-behavior-phabricator-search-typeahead' => '75ccea43',
|
||||
'javelin-behavior-phabricator-tooltips' => '75ccea43',
|
||||
'javelin-behavior-phabricator-watch-anchor' => '75ccea43',
|
||||
'javelin-behavior-refresh-csrf' => '75ccea43',
|
||||
'javelin-behavior-phabricator-oncopy' => '606f7152',
|
||||
'javelin-behavior-phabricator-remarkup-assist' => '606f7152',
|
||||
'javelin-behavior-phabricator-reveal-content' => '606f7152',
|
||||
'javelin-behavior-phabricator-search-typeahead' => '606f7152',
|
||||
'javelin-behavior-phabricator-tooltips' => '606f7152',
|
||||
'javelin-behavior-phabricator-watch-anchor' => '606f7152',
|
||||
'javelin-behavior-refresh-csrf' => '606f7152',
|
||||
'javelin-behavior-repository-crossreference' => '48040be9',
|
||||
'javelin-behavior-toggle-class' => '75ccea43',
|
||||
'javelin-behavior-workflow' => '75ccea43',
|
||||
'javelin-dom' => 'a9f14d76',
|
||||
'javelin-event' => 'a9f14d76',
|
||||
'javelin-history' => 'a9f14d76',
|
||||
'javelin-install' => 'a9f14d76',
|
||||
'javelin-json' => 'a9f14d76',
|
||||
'javelin-mask' => 'a9f14d76',
|
||||
'javelin-request' => 'a9f14d76',
|
||||
'javelin-resource' => 'a9f14d76',
|
||||
'javelin-stratcom' => 'a9f14d76',
|
||||
'javelin-tokenizer' => 'a9f14d76',
|
||||
'javelin-typeahead' => 'a9f14d76',
|
||||
'javelin-typeahead-normalizer' => 'a9f14d76',
|
||||
'javelin-typeahead-ondemand-source' => 'a9f14d76',
|
||||
'javelin-typeahead-preloaded-source' => 'a9f14d76',
|
||||
'javelin-typeahead-source' => 'a9f14d76',
|
||||
'javelin-uri' => 'a9f14d76',
|
||||
'javelin-util' => 'a9f14d76',
|
||||
'javelin-vector' => 'a9f14d76',
|
||||
'javelin-workflow' => 'a9f14d76',
|
||||
'javelin-behavior-toggle-class' => '606f7152',
|
||||
'javelin-behavior-workflow' => '606f7152',
|
||||
'javelin-dom' => '2dbbb7d1',
|
||||
'javelin-event' => '2dbbb7d1',
|
||||
'javelin-history' => '2dbbb7d1',
|
||||
'javelin-install' => '2dbbb7d1',
|
||||
'javelin-json' => '2dbbb7d1',
|
||||
'javelin-mask' => '2dbbb7d1',
|
||||
'javelin-request' => '2dbbb7d1',
|
||||
'javelin-resource' => '2dbbb7d1',
|
||||
'javelin-stratcom' => '2dbbb7d1',
|
||||
'javelin-tokenizer' => '2dbbb7d1',
|
||||
'javelin-typeahead' => '2dbbb7d1',
|
||||
'javelin-typeahead-normalizer' => '2dbbb7d1',
|
||||
'javelin-typeahead-ondemand-source' => '2dbbb7d1',
|
||||
'javelin-typeahead-preloaded-source' => '2dbbb7d1',
|
||||
'javelin-typeahead-source' => '2dbbb7d1',
|
||||
'javelin-uri' => '2dbbb7d1',
|
||||
'javelin-util' => '2dbbb7d1',
|
||||
'javelin-vector' => '2dbbb7d1',
|
||||
'javelin-workflow' => '2dbbb7d1',
|
||||
'lightbox-attachment-css' => '4bd2b460',
|
||||
'maniphest-task-summary-css' => '06bacb9a',
|
||||
'maniphest-transaction-detail-css' => '06bacb9a',
|
||||
'phabricator-action-list-view-css' => '4bd2b460',
|
||||
'phabricator-application-launch-view-css' => '4bd2b460',
|
||||
'phabricator-busy' => '75ccea43',
|
||||
'phabricator-busy' => '606f7152',
|
||||
'phabricator-content-source-view-css' => 'dd27a69b',
|
||||
'phabricator-core-css' => '4bd2b460',
|
||||
'phabricator-crumbs-view-css' => '4bd2b460',
|
||||
'phabricator-drag-and-drop-file-upload' => '48040be9',
|
||||
'phabricator-dropdown-menu' => '75ccea43',
|
||||
'phabricator-file-upload' => '75ccea43',
|
||||
'phabricator-dropdown-menu' => '606f7152',
|
||||
'phabricator-file-upload' => '606f7152',
|
||||
'phabricator-filetree-view-css' => '4bd2b460',
|
||||
'phabricator-flag-css' => '4bd2b460',
|
||||
'phabricator-form-view-css' => '4bd2b460',
|
||||
'phabricator-header-view-css' => '4bd2b460',
|
||||
'phabricator-hovercard' => '75ccea43',
|
||||
'phabricator-hovercard' => '606f7152',
|
||||
'phabricator-jump-nav' => '4bd2b460',
|
||||
'phabricator-keyboard-shortcut' => '75ccea43',
|
||||
'phabricator-keyboard-shortcut-manager' => '75ccea43',
|
||||
'phabricator-keyboard-shortcut' => '606f7152',
|
||||
'phabricator-keyboard-shortcut-manager' => '606f7152',
|
||||
'phabricator-main-menu-view' => '4bd2b460',
|
||||
'phabricator-menu-item' => '75ccea43',
|
||||
'phabricator-menu-item' => '606f7152',
|
||||
'phabricator-nav-view-css' => '4bd2b460',
|
||||
'phabricator-notification' => '75ccea43',
|
||||
'phabricator-notification' => '606f7152',
|
||||
'phabricator-notification-css' => '4bd2b460',
|
||||
'phabricator-notification-menu-css' => '4bd2b460',
|
||||
'phabricator-object-item-list-view-css' => '4bd2b460',
|
||||
'phabricator-object-selector-css' => 'dd27a69b',
|
||||
'phabricator-phtize' => '75ccea43',
|
||||
'phabricator-prefab' => '75ccea43',
|
||||
'phabricator-phtize' => '606f7152',
|
||||
'phabricator-prefab' => '606f7152',
|
||||
'phabricator-project-tag-css' => '06bacb9a',
|
||||
'phabricator-property-list-view-css' => '4bd2b460',
|
||||
'phabricator-remarkup-css' => '4bd2b460',
|
||||
|
@ -4563,8 +4563,8 @@ celerity_register_resource_map(array(
|
|||
'phabricator-side-menu-view-css' => '4bd2b460',
|
||||
'phabricator-standard-page-view' => '4bd2b460',
|
||||
'phabricator-tag-view-css' => '4bd2b460',
|
||||
'phabricator-textareautils' => '75ccea43',
|
||||
'phabricator-tooltip' => '75ccea43',
|
||||
'phabricator-textareautils' => '606f7152',
|
||||
'phabricator-tooltip' => '606f7152',
|
||||
'phabricator-transaction-view-css' => '4bd2b460',
|
||||
'phabricator-zindex-css' => '4bd2b460',
|
||||
'phui-button-css' => '4bd2b460',
|
||||
|
|
|
@ -14,6 +14,7 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
$query = $request->getStr('q');
|
||||
$raw_query = $request->getStr('raw');
|
||||
|
||||
$need_rich_data = false;
|
||||
|
||||
|
@ -304,55 +305,23 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
}
|
||||
|
||||
if ($need_jump_objects) {
|
||||
$response = PhabricatorJumpNavHandler::jumpPostResponse($query);
|
||||
|
||||
if ($response) {
|
||||
$is_task = array();
|
||||
$is_revision = array();
|
||||
|
||||
preg_match('/T[0-9]+/', $response->getURI(), $is_task);
|
||||
preg_match('/D[0-9]+/', $response->getURI(), $is_revision);
|
||||
|
||||
if ($is_task) {
|
||||
for ($i = 0; $i < count($is_task); $i++) {
|
||||
$is_task[$i] = substr($is_task[$i], 1); // Remove leading 'T'.
|
||||
}
|
||||
$tasks = id(new ManiphestTaskQuery())
|
||||
->setViewer($viewer)
|
||||
->withTaskIDs($is_task)
|
||||
->execute();
|
||||
|
||||
if ($tasks) {
|
||||
foreach ($tasks as $task) {
|
||||
$results[] = id(new PhabricatorTypeaheadResult())
|
||||
->setName('T'.$task->getID())
|
||||
->setDisplayType("Task")
|
||||
->setURI('/T'.$task->getID())
|
||||
->setPHID($task->getPHID())
|
||||
->setPriorityType('jump');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_revision) {
|
||||
for ($i = 0; $i < count($is_revision); $i++) {
|
||||
$is_revision[$i] = substr($is_revision[$i], 1);
|
||||
}
|
||||
$revisions = id(new DifferentialRevisionQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs($is_revision)
|
||||
->execute();
|
||||
|
||||
if ($revisions) {
|
||||
foreach ($revisions as $revision) {
|
||||
$results[] = id(new PhabricatorTypeaheadResult())
|
||||
->setName('D'.$revision->getID())
|
||||
->setDisplayType("Revision")
|
||||
->setURI('/D'.$revision->getID())
|
||||
->setPHID($revision->getPHID())
|
||||
->setPriorityType('jump');
|
||||
}
|
||||
}
|
||||
$objects = id(new PhabricatorObjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withNames(array($raw_query))
|
||||
->execute();
|
||||
if ($objects) {
|
||||
$handles = id(new PhabricatorHandleQuery())
|
||||
->setViewer($viewer)
|
||||
->withPHIDs(mpull($objects, 'getPHID'))
|
||||
->execute();
|
||||
$handle = head($handles);
|
||||
if ($handle) {
|
||||
$results[] = id(new PhabricatorTypeaheadResult())
|
||||
->setName($handle->getFullName())
|
||||
->setDisplayType($handle->getTypeName())
|
||||
->setURI($handle->getURI())
|
||||
->setPHID($handle->getPHID())
|
||||
->setPriorityType('jump');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,22 +41,22 @@ JX.install('TypeaheadOnDemandSource', {
|
|||
lastChange : null,
|
||||
haveData : null,
|
||||
|
||||
didChange : function(value) {
|
||||
didChange : function(raw_value) {
|
||||
this.lastChange = JX.now();
|
||||
value = this.normalize(value);
|
||||
var value = this.normalize(raw_value);
|
||||
|
||||
if (this.haveData[value]) {
|
||||
this.matchResults(value);
|
||||
} else {
|
||||
this.waitForResults();
|
||||
setTimeout(
|
||||
JX.bind(this, this.sendRequest, this.lastChange, value),
|
||||
JX.bind(this, this.sendRequest, this.lastChange, value, raw_value),
|
||||
this.getQueryDelay()
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
sendRequest : function(when, value) {
|
||||
sendRequest : function(when, value, raw_value) {
|
||||
if (when != this.lastChange) {
|
||||
return;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ JX.install('TypeaheadOnDemandSource', {
|
|||
this.uri,
|
||||
JX.bind(this, this.ondata, this.lastChange, value));
|
||||
r.setMethod('GET');
|
||||
r.setData(JX.copy(this.getAuxiliaryData(), {q : value}));
|
||||
r.setData(JX.copy(this.getAuxiliaryData(), {q : value, raw: raw_value}));
|
||||
r.send();
|
||||
},
|
||||
|
||||
|
|
|
@ -89,19 +89,26 @@ JX.behavior('phabricator-search-typeahead', function(config) {
|
|||
});
|
||||
|
||||
// If we have more results than fit, limit each type of result to 3, so
|
||||
// we show 3 applications, then 3 users, etc.
|
||||
// we show 3 applications, then 3 users, etc. For jump items, we show only
|
||||
// one result.
|
||||
var type_count = 0;
|
||||
var current_type = null;
|
||||
for (ii = 0; ii < list.length; ii++) {
|
||||
if (list.length <= config.limit) {
|
||||
break;
|
||||
}
|
||||
if (list[ii].type != current_type) {
|
||||
current_type = list[ii].type;
|
||||
type_count = 1;
|
||||
} else {
|
||||
type_count++;
|
||||
if (type_count > 3) {
|
||||
|
||||
// Skip this item if:
|
||||
// - it's a jump nav item, and we already have at least one jump
|
||||
// nav item; or
|
||||
// - we have more items than will fit in the typeahead, and this
|
||||
// is the 4..Nth result of its type.
|
||||
|
||||
var skip = ((current_type == 'jump') && (type_count > 1)) ||
|
||||
((list.length > config.limit) && (type_count > 3));
|
||||
if (skip) {
|
||||
list.splice(ii, 1);
|
||||
ii--;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue