@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.

Update the search scope selector after Quicksand navigation

Summary:
Fixes T7900.

- Update the hidden form input so the current application is searched.
- Update the menu icon.
- Update the button icon, if "Search Current Application" is selected.

Test Plan:
- Navigated between applications with Quicksand.
- Observed button icon update.
- Observed menu icon update.
- Observed results being scoped to the correct application.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7900

Differential Revision: https://secure.phabricator.com/D12540

+96 -36
+18 -18
resources/celerity/map.php
··· 8 8 return array( 9 9 'names' => array( 10 10 'core.pkg.css' => '9a9b59ca', 11 - 'core.pkg.js' => '493cc6e6', 11 + 'core.pkg.js' => '6f7446de', 12 12 'darkconsole.pkg.js' => '8ab24e01', 13 13 'differential.pkg.css' => '3500921f', 14 14 'differential.pkg.js' => '890046d3', ··· 468 468 'rsrc/js/core/behavior-file-tree.js' => '88236f00', 469 469 'rsrc/js/core/behavior-form.js' => '5c54cbf3', 470 470 'rsrc/js/core/behavior-gesture.js' => '3ab51e2c', 471 - 'rsrc/js/core/behavior-global-drag-and-drop.js' => '3f6075ff', 471 + 'rsrc/js/core/behavior-global-drag-and-drop.js' => 'c203e6ee', 472 472 'rsrc/js/core/behavior-high-security-warning.js' => 'a464fe03', 473 473 'rsrc/js/core/behavior-history-install.js' => '7ee2b591', 474 474 'rsrc/js/core/behavior-hovercard.js' => 'f36e01af', ··· 486 486 'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e', 487 487 'rsrc/js/core/behavior-reveal-content.js' => '60821bc7', 488 488 'rsrc/js/core/behavior-scrollbar.js' => '834a1173', 489 - 'rsrc/js/core/behavior-search-typeahead.js' => 'c5172d25', 489 + 'rsrc/js/core/behavior-search-typeahead.js' => '048330fa', 490 490 'rsrc/js/core/behavior-select-on-click.js' => '4e3e79a6', 491 491 'rsrc/js/core/behavior-toggle-class.js' => 'e566f52c', 492 492 'rsrc/js/core/behavior-tokenizer.js' => 'b3a4b884', ··· 593 593 'javelin-behavior-durable-column' => '657c2b50', 594 594 'javelin-behavior-error-log' => '6882e80a', 595 595 'javelin-behavior-fancy-datepicker' => 'c51ae228', 596 - 'javelin-behavior-global-drag-and-drop' => '3f6075ff', 596 + 'javelin-behavior-global-drag-and-drop' => 'c203e6ee', 597 597 'javelin-behavior-herald-rule-editor' => '7ebaeed3', 598 598 'javelin-behavior-high-security-warning' => 'a464fe03', 599 599 'javelin-behavior-history-install' => '7ee2b591', ··· 628 628 'javelin-behavior-phabricator-oncopy' => '2926fff2', 629 629 'javelin-behavior-phabricator-remarkup-assist' => 'e32d14ab', 630 630 'javelin-behavior-phabricator-reveal-content' => '60821bc7', 631 - 'javelin-behavior-phabricator-search-typeahead' => 'c5172d25', 631 + 'javelin-behavior-phabricator-search-typeahead' => '048330fa', 632 632 'javelin-behavior-phabricator-show-older-transactions' => 'dbbf48b6', 633 633 'javelin-behavior-phabricator-tooltips' => '3ee3408b', 634 634 'javelin-behavior-phabricator-transaction-comment-form' => '9f7309fb', ··· 845 845 '029a133d' => array( 846 846 'aphront-dialog-view-css', 847 847 ), 848 + '048330fa' => array( 849 + 'javelin-behavior', 850 + 'javelin-typeahead-ondemand-source', 851 + 'javelin-typeahead', 852 + 'javelin-dom', 853 + 'javelin-uri', 854 + 'javelin-util', 855 + 'javelin-stratcom', 856 + 'phabricator-prefab', 857 + ), 848 858 '05270951' => array( 849 859 'javelin-util', 850 860 'javelin-magical-init', ··· 1087 1097 'javelin-behavior', 1088 1098 'javelin-dom', 1089 1099 'phortune-credit-card-form', 1090 - ), 1091 - '3f6075ff' => array( 1092 - 'javelin-behavior', 1093 - 'javelin-dom', 1094 - 'javelin-uri', 1095 - 'javelin-mask', 1096 - 'phabricator-drag-and-drop-file-upload', 1097 1100 ), 1098 1101 '40a6a403' => array( 1099 1102 'javelin-install', ··· 1755 1758 'javelin-dom', 1756 1759 'javelin-vector', 1757 1760 ), 1758 - 'c5172d25' => array( 1761 + 'c203e6ee' => array( 1759 1762 'javelin-behavior', 1760 - 'javelin-typeahead-ondemand-source', 1761 - 'javelin-typeahead', 1762 1763 'javelin-dom', 1763 1764 'javelin-uri', 1764 - 'javelin-util', 1765 - 'javelin-stratcom', 1766 - 'phabricator-prefab', 1765 + 'javelin-mask', 1766 + 'phabricator-drag-and-drop-file-upload', 1767 1767 ), 1768 1768 'c51ae228' => array( 1769 1769 'javelin-behavior',
+15
src/view/page/PhabricatorStandardPageView.php
··· 649 649 $upload_enabled = $controller->isGlobalDragAndDropUploadEnabled(); 650 650 } 651 651 652 + $application_class = null; 653 + $application_search_icon = null; 654 + $controller = $this->getController(); 655 + if ($controller) { 656 + $application = $controller->getCurrentApplication(); 657 + if ($application) { 658 + $application_class = get_class($application); 659 + if ($application->getApplicationSearchDocumentTypes()) { 660 + $application_search_icon = $application->getFontIcon(); 661 + } 662 + } 663 + } 664 + 652 665 return array( 653 666 'title' => $this->getTitle(), 654 667 'aphlictDropdownData' => array( ··· 659 672 'aphlictDropdowns' => $rendered_dropdowns, 660 673 'hisecWarningConfig' => $hisec_warning_config, 661 674 'consoleConfig' => $console_config, 675 + 'applicationClass' => $application_class, 676 + 'applicationSearchIcon' => $application_search_icon, 662 677 ) + $this->buildAphlictListenConfigData(); 663 678 } 664 679
+18 -8
src/view/page/menu/PhabricatorMainMenuSearchView.php
··· 2 2 3 3 final class PhabricatorMainMenuSearchView extends AphrontView { 4 4 5 + const DEFAULT_APPLICATION_ICON = 'fa-dot-circle-o'; 6 + 5 7 private $id; 6 8 private $application; 7 9 ··· 27 29 $target_id = celerity_generate_unique_node_id(); 28 30 $search_id = $this->getID(); 29 31 $button_id = celerity_generate_unique_node_id(); 32 + $selector_id = celerity_generate_unique_node_id(); 33 + $application_id = celerity_generate_unique_node_id(); 30 34 31 35 $input = phutil_tag( 32 36 'input', ··· 51 55 Javelin::initBehavior( 52 56 'phabricator-search-typeahead', 53 57 array( 54 - 'id' => $target_id, 55 - 'input' => $search_id, 56 - 'button' => $button_id, 57 - 'src' => $search_datasource->getDatasourceURI(), 58 - 'limit' => 10, 58 + 'id' => $target_id, 59 + 'input' => $search_id, 60 + 'button' => $button_id, 61 + 'selectorID' => $selector_id, 62 + 'applicationID' => $application_id, 63 + 'defaultApplicationIcon' => self::DEFAULT_APPLICATION_ICON, 64 + 'appScope' => PhabricatorSearchController::SCOPE_CURRENT_APPLICATION, 65 + 'src' => $search_datasource->getDatasourceURI(), 66 + 'limit' => 10, 59 67 'placeholder' => pht('Search'), 60 68 'scopeUpdateURI' => '/settings/adjust/?key='.$scope_key, 61 69 )); ··· 75 83 ), 76 84 pht('Search')); 77 85 78 - $selector = $this->buildModeSelector(); 86 + $selector = $this->buildModeSelector($selector_id, $application_id); 79 87 80 88 $form = phabricator_form( 81 89 $user, ··· 100 108 return $form; 101 109 } 102 110 103 - private function buildModeSelector() { 111 + private function buildModeSelector($selector_id, $application_id) { 104 112 $viewer = $this->getUser(); 105 113 106 114 $items = array(); ··· 115 123 ); 116 124 117 125 $application_value = null; 118 - $application_icon = 'fa-dot-circle-o'; 126 + $application_icon = self::DEFAULT_APPLICATION_ICON; 119 127 $application = $this->getApplication(); 120 128 if ($application) { 121 129 $application_value = get_class($application); ··· 183 191 } 184 192 185 193 $selector = id(new PHUIButtonView()) 194 + ->setID($selector_id) 186 195 ->addClass('phabricator-main-menu-search-dropdown') 187 196 ->addSigil('global-search-dropdown') 188 197 ->setMetadata( ··· 210 219 'input', 211 220 array( 212 221 'type' => 'hidden', 222 + 'id' => $application_id, 213 223 'sigil' => 'global-search-dropdown-app', 214 224 'name' => 'search:application', 215 225 'value' => $application_value,
-2
webroot/rsrc/js/core/behavior-global-drag-and-drop.js
··· 98 98 'quicksand-redraw', 99 99 null, 100 100 function (e) { 101 - e.kill(); 102 - 103 101 var data = e.getData(); 104 102 var toggle = data.newResponse.globalDragAndDrop; 105 103 statics.enabled = toggle;
+45 -8
webroot/rsrc/js/core/behavior-search-typeahead.js
··· 144 144 typeahead.updatePlaceHolder(); 145 145 }); 146 146 147 - // TODO: Quicksand needs to update the application search input as we change 148 - // applications; we should register a listener. 149 - // TODO: Quicksand also needs to update the application search icon on the 150 - // button itself and in the menu. 147 + 148 + // When the user navigates between applications, we need to update the 149 + // input in the document, the icon on the button, and the icon in the 150 + // menu. 151 + JX.Stratcom.listen( 152 + 'quicksand-redraw', 153 + null, 154 + function(e) { 155 + var r = e.getData().newResponse; 156 + updateCurrentApplication(r.applicationClass, r.applicationSearchIcon); 157 + }); 158 + 159 + var current_app_icon; 160 + function updateCurrentApplication(app_class, app_icon) { 161 + current_app_icon = app_icon || config.defaultApplicationIcon; 162 + 163 + // Update the icon on the button. 164 + var button = JX.$(config.selectorID); 165 + var data = JX.Stratcom.getData(button); 166 + if (data.value == config.appScope) { 167 + updateIcon(button, data, current_app_icon); 168 + } 169 + 170 + // Set the hidden input to the new value. 171 + JX.$(config.applicationID).value = app_class; 172 + } 173 + 174 + function updateIcon(button, data, new_icon) { 175 + var icon = JX.DOM.find(button, 'span', 'global-search-dropdown-icon'); 176 + JX.DOM.alterClass(icon, data.icon, false); 177 + data.icon = new_icon; 178 + JX.DOM.alterClass(icon, data.icon, true); 179 + } 151 180 152 181 // Implement the scope selector menu for the global search. 153 182 JX.Stratcom.listen('click', 'global-search-dropdown', function(e) { ··· 165 194 } 166 195 167 196 // Swap out the icon. 168 - var icon = JX.DOM.find(button, 'span', 'global-search-dropdown-icon'); 169 - JX.DOM.alterClass(icon, data.icon, false); 170 - data.icon = spec.icon; 171 - JX.DOM.alterClass(icon, data.icon, true); 197 + updateIcon(button, data, spec.icon); 172 198 173 199 // Update the value. 174 200 data.value = spec.value; ··· 192 218 193 219 for (var ii = 0; ii < data.items.length; ii++) { 194 220 var spec = data.items[ii]; 221 + 222 + // If this is the "Search Current Application" item and we've 223 + // navigated to a page which sent us new information about the 224 + // icon, update the icon so the menu reflects the icon for the 225 + // current application. 226 + if (spec.value == config.appScope) { 227 + if (current_app_icon !== undefined) { 228 + spec.icon = current_app_icon; 229 + } 230 + } 231 + 195 232 var item = new JX.PHUIXActionView() 196 233 .setName(spec.name) 197 234 .setIcon(spec.icon);