@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+98 -122
+63 -63
src/__celerity_resource_map__.php
··· 2150 2150 ), 2151 2151 'javelin-behavior-phabricator-search-typeahead' => 2152 2152 array( 2153 - 'uri' => '/res/439de76f/rsrc/js/core/behavior-search-typeahead.js', 2153 + 'uri' => '/res/409d9567/rsrc/js/core/behavior-search-typeahead.js', 2154 2154 'type' => 'js', 2155 2155 'requires' => 2156 2156 array( ··· 2744 2744 ), 2745 2745 'javelin-typeahead-ondemand-source' => 2746 2746 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', 2748 2748 'type' => 'js', 2749 2749 'requires' => 2750 2750 array( ··· 4242 4242 'uri' => '/res/pkg/4bd2b460/core.pkg.css', 4243 4243 'type' => 'css', 4244 4244 ), 4245 - '75ccea43' => 4245 + '606f7152' => 4246 4246 array( 4247 4247 'name' => 'core.pkg.js', 4248 4248 'symbols' => ··· 4285 4285 35 => 'phabricator-hovercard', 4286 4286 36 => 'javelin-behavior-phabricator-hovercards', 4287 4287 ), 4288 - 'uri' => '/res/pkg/75ccea43/core.pkg.js', 4288 + 'uri' => '/res/pkg/606f7152/core.pkg.js', 4289 4289 'type' => 'js', 4290 4290 ), 4291 4291 '4ccfeb47' => ··· 4372 4372 'uri' => '/res/pkg/96909266/diffusion.pkg.js', 4373 4373 'type' => 'js', 4374 4374 ), 4375 - 'a9f14d76' => 4375 + '2dbbb7d1' => 4376 4376 array( 4377 4377 'name' => 'javelin.pkg.js', 4378 4378 'symbols' => ··· 4398 4398 18 => 'javelin-tokenizer', 4399 4399 19 => 'javelin-history', 4400 4400 ), 4401 - 'uri' => '/res/pkg/a9f14d76/javelin.pkg.js', 4401 + 'uri' => '/res/pkg/2dbbb7d1/javelin.pkg.js', 4402 4402 'type' => 'js', 4403 4403 ), 4404 4404 '06bacb9a' => ··· 4455 4455 'diffusion-icons-css' => 'c8ce2d88', 4456 4456 'global-drag-and-drop-css' => '4bd2b460', 4457 4457 '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', 4463 4463 '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', 4465 4465 'javelin-behavior-audit-preview' => '96909266', 4466 4466 'javelin-behavior-dark-console' => '4ccfeb47', 4467 - 'javelin-behavior-device' => '75ccea43', 4467 + 'javelin-behavior-device' => '606f7152', 4468 4468 'javelin-behavior-differential-accept-with-errors' => '48040be9', 4469 4469 'javelin-behavior-differential-add-reviewers-and-ccs' => '48040be9', 4470 4470 'javelin-behavior-differential-comment-jump' => '48040be9', ··· 4480 4480 'javelin-behavior-diffusion-commit-graph' => '96909266', 4481 4481 'javelin-behavior-diffusion-pull-lastmodified' => '96909266', 4482 4482 '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', 4487 4487 'javelin-behavior-load-blame' => '48040be9', 4488 4488 'javelin-behavior-maniphest-batch-selector' => '98f64f07', 4489 4489 'javelin-behavior-maniphest-subpriority-editor' => '98f64f07', 4490 4490 'javelin-behavior-maniphest-transaction-controls' => '98f64f07', 4491 4491 'javelin-behavior-maniphest-transaction-expand' => '98f64f07', 4492 4492 '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', 4499 4499 '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', 4507 4507 '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', 4529 4529 'lightbox-attachment-css' => '4bd2b460', 4530 4530 'maniphest-task-summary-css' => '06bacb9a', 4531 4531 'maniphest-transaction-detail-css' => '06bacb9a', 4532 4532 'phabricator-action-list-view-css' => '4bd2b460', 4533 4533 'phabricator-application-launch-view-css' => '4bd2b460', 4534 - 'phabricator-busy' => '75ccea43', 4534 + 'phabricator-busy' => '606f7152', 4535 4535 'phabricator-content-source-view-css' => 'dd27a69b', 4536 4536 'phabricator-core-css' => '4bd2b460', 4537 4537 'phabricator-crumbs-view-css' => '4bd2b460', 4538 4538 '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', 4541 4541 'phabricator-filetree-view-css' => '4bd2b460', 4542 4542 'phabricator-flag-css' => '4bd2b460', 4543 4543 'phabricator-form-view-css' => '4bd2b460', 4544 4544 'phabricator-header-view-css' => '4bd2b460', 4545 - 'phabricator-hovercard' => '75ccea43', 4545 + 'phabricator-hovercard' => '606f7152', 4546 4546 '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', 4549 4549 'phabricator-main-menu-view' => '4bd2b460', 4550 - 'phabricator-menu-item' => '75ccea43', 4550 + 'phabricator-menu-item' => '606f7152', 4551 4551 'phabricator-nav-view-css' => '4bd2b460', 4552 - 'phabricator-notification' => '75ccea43', 4552 + 'phabricator-notification' => '606f7152', 4553 4553 'phabricator-notification-css' => '4bd2b460', 4554 4554 'phabricator-notification-menu-css' => '4bd2b460', 4555 4555 'phabricator-object-item-list-view-css' => '4bd2b460', 4556 4556 'phabricator-object-selector-css' => 'dd27a69b', 4557 - 'phabricator-phtize' => '75ccea43', 4558 - 'phabricator-prefab' => '75ccea43', 4557 + 'phabricator-phtize' => '606f7152', 4558 + 'phabricator-prefab' => '606f7152', 4559 4559 'phabricator-project-tag-css' => '06bacb9a', 4560 4560 'phabricator-property-list-view-css' => '4bd2b460', 4561 4561 'phabricator-remarkup-css' => '4bd2b460', ··· 4563 4563 'phabricator-side-menu-view-css' => '4bd2b460', 4564 4564 'phabricator-standard-page-view' => '4bd2b460', 4565 4565 'phabricator-tag-view-css' => '4bd2b460', 4566 - 'phabricator-textareautils' => '75ccea43', 4567 - 'phabricator-tooltip' => '75ccea43', 4566 + 'phabricator-textareautils' => '606f7152', 4567 + 'phabricator-tooltip' => '606f7152', 4568 4568 'phabricator-transaction-view-css' => '4bd2b460', 4569 4569 'phabricator-zindex-css' => '4bd2b460', 4570 4570 'phui-button-css' => '4bd2b460',
+18 -49
src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
··· 14 14 $request = $this->getRequest(); 15 15 $viewer = $request->getUser(); 16 16 $query = $request->getStr('q'); 17 + $raw_query = $request->getStr('raw'); 17 18 18 19 $need_rich_data = false; 19 20 ··· 304 305 } 305 306 306 307 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'); 356 325 } 357 326 } 358 327 }
+5 -5
webroot/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js
··· 41 41 lastChange : null, 42 42 haveData : null, 43 43 44 - didChange : function(value) { 44 + didChange : function(raw_value) { 45 45 this.lastChange = JX.now(); 46 - value = this.normalize(value); 46 + var value = this.normalize(raw_value); 47 47 48 48 if (this.haveData[value]) { 49 49 this.matchResults(value); 50 50 } else { 51 51 this.waitForResults(); 52 52 setTimeout( 53 - JX.bind(this, this.sendRequest, this.lastChange, value), 53 + JX.bind(this, this.sendRequest, this.lastChange, value, raw_value), 54 54 this.getQueryDelay() 55 55 ); 56 56 } 57 57 }, 58 58 59 - sendRequest : function(when, value) { 59 + sendRequest : function(when, value, raw_value) { 60 60 if (when != this.lastChange) { 61 61 return; 62 62 } ··· 64 64 this.uri, 65 65 JX.bind(this, this.ondata, this.lastChange, value)); 66 66 r.setMethod('GET'); 67 - r.setData(JX.copy(this.getAuxiliaryData(), {q : value})); 67 + r.setData(JX.copy(this.getAuxiliaryData(), {q : value, raw: raw_value})); 68 68 r.send(); 69 69 }, 70 70
+12 -5
webroot/rsrc/js/core/behavior-search-typeahead.js
··· 89 89 }); 90 90 91 91 // 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. 93 94 var type_count = 0; 94 95 var current_type = null; 95 96 for (ii = 0; ii < list.length; ii++) { 96 - if (list.length <= config.limit) { 97 - break; 98 - } 99 97 if (list[ii].type != current_type) { 100 98 current_type = list[ii].type; 101 99 type_count = 1; 102 100 } else { 103 101 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) { 105 112 list.splice(ii, 1); 106 113 ii--; 107 114 }