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

Clean up the Diffusion search UI a little bit

Summary:
Ref T156. @vlada recently implemented filename search in Diffusion, this cleans up the UI a little bit:

- Instead of showing one search box with two different buttons, let the submit buttons appear to the right of the text boxes and separate the search modes.
- Clean up the results a little bit (don't show columns which don't exist).

Test Plan: {F107260}

Reviewers: vlada, btrahan, chad

Reviewed By: chad

CC: vlada, chad, aran

Maniphest Tasks: T156

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

+188 -36
+5 -5
resources/celerity/map.php
··· 7 7 return array( 8 8 'names' => 9 9 array( 10 - 'core.pkg.css' => '13b791fd', 10 + 'core.pkg.css' => '882662b1', 11 11 'core.pkg.js' => 'c7854cc5', 12 12 'darkconsole.pkg.js' => 'ca8671ce', 13 13 'differential.pkg.css' => '5a65a762', ··· 25 25 'rsrc/css/aphront/dialog-view.css' => 'dd9db96c', 26 26 'rsrc/css/aphront/error-view.css' => '16cd9949', 27 27 'rsrc/css/aphront/lightbox-attachment.css' => '686f8885', 28 - 'rsrc/css/aphront/list-filter-view.css' => '9f0c29ac', 28 + 'rsrc/css/aphront/list-filter-view.css' => 'ef989c67', 29 29 'rsrc/css/aphront/multi-column.css' => '05bbd016', 30 30 'rsrc/css/aphront/notification.css' => '6901121e', 31 31 'rsrc/css/aphront/pager-view.css' => '2e3539af', ··· 130 130 'rsrc/css/phui/phui-button.css' => '8106a67a', 131 131 'rsrc/css/phui/phui-document.css' => '143b2ac8', 132 132 'rsrc/css/phui/phui-feed-story.css' => '3a59c2cf', 133 - 'rsrc/css/phui/phui-form-view.css' => '3179980c', 133 + 'rsrc/css/phui/phui-form-view.css' => '0efd3326', 134 134 'rsrc/css/phui/phui-form.css' => 'b78ec020', 135 135 'rsrc/css/phui/phui-header-view.css' => '472a6003', 136 136 'rsrc/css/phui/phui-icon.css' => '29e83226', ··· 479 479 'aphront-dark-console-css' => '6378ef3d', 480 480 'aphront-dialog-view-css' => 'dd9db96c', 481 481 'aphront-error-view-css' => '16cd9949', 482 - 'aphront-list-filter-view-css' => '9f0c29ac', 482 + 'aphront-list-filter-view-css' => 'ef989c67', 483 483 'aphront-multi-column-view-css' => '05bbd016', 484 484 'aphront-notes' => '6acadd3f', 485 485 'aphront-pager-view-css' => '2e3539af', ··· 739 739 'phui-document-view-css' => '143b2ac8', 740 740 'phui-feed-story-css' => '3a59c2cf', 741 741 'phui-form-css' => 'b78ec020', 742 - 'phui-form-view-css' => '3179980c', 742 + 'phui-form-view-css' => '0efd3326', 743 743 'phui-header-view-css' => '472a6003', 744 744 'phui-icon-view-css' => '29e83226', 745 745 'phui-info-panel-css' => '27ea50a1',
+2
src/__phutil_library_map__.php
··· 48 48 'AphrontFormSubmitControl' => 'view/form/control/AphrontFormSubmitControl.php', 49 49 'AphrontFormTextAreaControl' => 'view/form/control/AphrontFormTextAreaControl.php', 50 50 'AphrontFormTextControl' => 'view/form/control/AphrontFormTextControl.php', 51 + 'AphrontFormTextWithSubmitControl' => 'view/form/control/AphrontFormTextWithSubmitControl.php', 51 52 'AphrontFormToggleButtonsControl' => 'view/form/control/AphrontFormToggleButtonsControl.php', 52 53 'AphrontFormTokenizerControl' => 'view/form/control/AphrontFormTokenizerControl.php', 53 54 'AphrontFormView' => 'view/form/AphrontFormView.php', ··· 2542 2543 'AphrontFormSubmitControl' => 'AphrontFormControl', 2543 2544 'AphrontFormTextAreaControl' => 'AphrontFormControl', 2544 2545 'AphrontFormTextControl' => 'AphrontFormControl', 2546 + 'AphrontFormTextWithSubmitControl' => 'AphrontFormControl', 2545 2547 'AphrontFormToggleButtonsControl' => 'AphrontFormControl', 2546 2548 'AphrontFormTokenizerControl' => 'AphrontFormControl', 2547 2549 'AphrontFormView' => 'AphrontView',
+20 -13
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 8 8 9 9 protected function renderSearchForm($collapsed) { 10 10 $drequest = $this->getDiffusionRequest(); 11 + 12 + $forms = array(); 11 13 $form = id(new AphrontFormView()) 12 14 ->setUser($this->getRequest()->getUser()) 13 15 ->setMethod('GET'); 14 16 15 17 switch ($drequest->getRepository()->getVersionControlSystem()) { 16 18 case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 17 - $form->appendChild(pht('Search is not available in Subversion.')); 19 + $forms[] = id(clone $form) 20 + ->appendChild(pht('Search is not available in Subversion.')); 18 21 break; 19 - 20 22 default: 21 - $form 23 + $forms[] = id(clone $form) 24 + ->appendChild( 25 + id(new AphrontFormTextWithSubmitControl()) 26 + ->setLabel(pht('File Name')) 27 + ->setSubmitLabel(pht('Search File Names')) 28 + ->setName('find') 29 + ->setValue($this->getRequest()->getStr('find'))); 30 + $forms[] = id(clone $form) 22 31 ->appendChild( 23 - id(new AphrontFormTextControl()) 24 - ->setLabel(pht('Search Here')) 32 + id(new AphrontFormTextWithSubmitControl()) 33 + ->setLabel(pht('Pattern')) 34 + ->setSubmitLabel(pht('Grep File Content')) 25 35 ->setName('grep') 26 - ->setValue($this->getRequest()->getStr('grep')) 27 - ->setCaption(pht('Enter a regular expression.'))) 28 - ->appendChild( 29 - id(new PHUIFormMultiSubmitControl()) 30 - ->addButton('__ls__', pht('Search File Names')) 31 - ->addButton('__grep__', pht('Search File Content'))); 36 + ->setValue($this->getRequest()->getStr('grep'))); 32 37 break; 33 38 } 34 39 40 + 35 41 $filter = new AphrontListFilterView(); 36 - $filter->appendChild($form); 42 + $filter->appendChild($forms); 43 + 37 44 38 45 if ($collapsed) { 39 46 $filter->setCollapsed( 40 47 pht('Show Search'), 41 48 pht('Hide Search'), 42 - pht('Search for file content in this directory.'), 49 + pht('Search for file names or content in this directory.'), 43 50 '#'); 44 51 } 45 52
+3 -2
src/applications/diffusion/controller/DiffusionBrowseMainController.php
··· 9 9 // Figure out if we're browsing a directory, a file, or a search result 10 10 // list. Then delegate to the appropriate controller. 11 11 12 - $search = $request->getStr('grep'); 13 - if (strlen($search)) { 12 + $grep = $request->getStr('grep'); 13 + $find = $request->getStr('find'); 14 + if (strlen($grep) || strlen($find)) { 14 15 $controller = new DiffusionBrowseSearchController($request); 15 16 } else { 16 17 $results = DiffusionBrowseResultSet::newFromConduit(
+75 -16
src/applications/diffusion/controller/DiffusionBrowseSearchController.php
··· 43 43 $drequest = $this->getDiffusionRequest(); 44 44 $repository = $drequest->getRepository(); 45 45 $results = array(); 46 - $no_data = pht('No results found.'); 47 46 48 47 $limit = 100; 49 48 $page = $this->getRequest()->getInt('page', 0); ··· 52 51 $pager->setOffset($page); 53 52 $pager->setURI($this->getRequest()->getRequestURI(), 'page'); 54 53 54 + $search_mode = null; 55 + 55 56 try { 56 - if ($this->getRequest()->getStr('__grep__')) { 57 + if (strlen($this->getRequest()->getStr('grep'))) { 58 + $search_mode = 'grep'; 59 + $query_string = $this->getRequest()->getStr('grep'); 57 60 $results = $this->callConduitWithDiffusionRequest( 58 61 'diffusion.searchquery', 59 62 array( 60 - 'grep' => $this->getRequest()->getStr('grep'), 63 + 'grep' => $query_string, 61 64 'stableCommitName' => $drequest->getStableCommitName(), 62 65 'path' => $drequest->getPath(), 63 66 'limit' => $limit + 1, 64 - 'offset' => $page)); 67 + 'offset' => $page, 68 + )); 65 69 } else { // Filename search. 66 - $results_raw = $this->callConduitWithDiffusionRequest( 70 + $search_mode = 'find'; 71 + $query_string = $this->getRequest()->getStr('find'); 72 + $results = $this->callConduitWithDiffusionRequest( 67 73 'diffusion.querypaths', 68 74 array( 69 - 'pattern' => $this->getRequest()->getStr('grep'), 75 + 'pattern' => $query_string, 70 76 'commit' => $drequest->getStableCommitName(), 71 77 'path' => $drequest->getPath(), 72 78 'limit' => $limit + 1, 73 - 'offset' => $page)); 74 - $results = []; 75 - foreach ($results_raw as $result) { 76 - $results[] = array($result, null, null); 77 - } 79 + 'offset' => $page, 80 + )); 78 81 } 79 82 } catch (ConduitException $ex) { 80 83 $err = $ex->getErrorDescription(); ··· 87 90 88 91 $results = $pager->sliceResults($results); 89 92 93 + if ($search_mode == 'grep') { 94 + $table = $this->renderGrepResults($results); 95 + $header = pht( 96 + 'File content matching "%s" under "%s"', 97 + $query_string, 98 + nonempty($drequest->getPath(), '/')); 99 + } else { 100 + $table = $this->renderFindResults($results); 101 + $header = pht( 102 + 'Paths matching "%s" under "%s"', 103 + $query_string, 104 + nonempty($drequest->getPath(), '/')); 105 + } 106 + 107 + $box = id(new PHUIObjectBoxView()) 108 + ->setHeaderText($header) 109 + ->appendChild($table); 110 + 111 + $pager_box = id(new PHUIBoxView()) 112 + ->addMargin(PHUI::MARGIN_LARGE) 113 + ->appendChild($pager); 114 + 115 + return array($box, $pager_box); 116 + } 117 + 118 + private function renderGrepResults(array $results) { 119 + $drequest = $this->getDiffusionRequest(); 120 + 90 121 require_celerity_resource('syntax-highlighting-css'); 91 122 92 123 // NOTE: This can be wrong because we may find the string inside the ··· 139 170 ->setClassName('remarkup-code') 140 171 ->setHeaders(array(pht('Path'), pht('Line'), pht('String'))) 141 172 ->setColumnClasses(array('', 'n', 'wide')) 142 - ->setNoDataString($no_data); 173 + ->setNoDataString( 174 + pht( 175 + 'The pattern you searched for was not found in the content of any '. 176 + 'files.')); 177 + 178 + return $table; 179 + } 180 + 181 + private function renderFindResults(array $results) { 182 + $drequest = $this->getDiffusionRequest(); 143 183 144 - return id(new AphrontPanelView()) 145 - ->setNoBackground(true) 146 - ->appendChild($table) 147 - ->appendChild($pager); 184 + $rows = array(); 185 + foreach ($results as $result) { 186 + $href = $drequest->generateURI(array( 187 + 'action' => 'browse', 188 + 'path' => $result, 189 + )); 190 + 191 + $readable = Filesystem::readablePath($result, $drequest->getPath()); 192 + 193 + $rows[] = array( 194 + phutil_tag('a', array('href' => $href), $readable), 195 + ); 196 + } 197 + 198 + $table = id(new AphrontTableView($rows)) 199 + ->setHeaders(array(pht('Path'))) 200 + ->setColumnClasses(array('wide')) 201 + ->setNoDataString( 202 + pht( 203 + 'The pattern you searched for did not match the names of any '. 204 + 'files.')); 205 + 206 + return $table; 148 207 } 149 208 150 209 }
+57
src/view/form/control/AphrontFormTextWithSubmitControl.php
··· 1 + <?php 2 + 3 + final class AphrontFormTextWithSubmitControl extends AphrontFormControl { 4 + 5 + private $submitLabel; 6 + 7 + public function setSubmitLabel($submit_label) { 8 + $this->submitLabel = $submit_label; 9 + return $this; 10 + } 11 + 12 + public function getSubmitLabel() { 13 + return $this->submitLabel; 14 + } 15 + 16 + protected function getCustomControlClass() { 17 + return 'aphront-form-control-text-with-submit'; 18 + } 19 + 20 + protected function renderInput() { 21 + return phutil_tag( 22 + 'div', 23 + array( 24 + 'class' => 'text-with-submit-control-outer-bounds', 25 + ), 26 + array( 27 + phutil_tag( 28 + 'div', 29 + array( 30 + 'class' => 'text-with-submit-control-text-bounds', 31 + ), 32 + javelin_tag( 33 + 'input', 34 + array( 35 + 'type' => 'text', 36 + 'class' => 'text-with-submit-control-text', 37 + 'name' => $this->getName(), 38 + 'value' => $this->getValue(), 39 + 'disabled' => $this->getDisabled() ? 'disabled' : null, 40 + 'id' => $this->getID(), 41 + ))), 42 + phutil_tag( 43 + 'div', 44 + array( 45 + 'class' => 'text-with-submit-control-submit-bounds', 46 + ), 47 + javelin_tag( 48 + 'input', 49 + array( 50 + 'type' => 'submit', 51 + 'class' => 'text-with-submit-control-submit grey', 52 + 'value' => coalesce($this->getSubmitLabel(), pht('Submit')) 53 + ))), 54 + )); 55 + } 56 + 57 + }
+8
webroot/rsrc/css/aphront/list-filter-view.css
··· 24 24 padding: 12px 0 6px; 25 25 } 26 26 27 + /* When a list filter view contains two consecuitive forms, lay them out 28 + without much white space in between them so they look more contiugous. At 29 + the time of writing, this is used only in the Diffusion repository search 30 + UI. */ 31 + .aphront-list-filter-view-content form + form .phui-form-view { 32 + margin-top: -18px; 33 + } 34 + 27 35 .aphront-list-filter-view-content .phui-form-view .aphront-form-label { 28 36 width: 12%; 29 37 }
+18
webroot/rsrc/css/phui/phui-form-view.css
··· 432 432 padding: 16px 0 4px; 433 433 margin-bottom: 4px; 434 434 } 435 + 436 + .device-desktop .text-with-submit-control-outer-bounds { 437 + position: relative; 438 + } 439 + 440 + .device-desktop .text-with-submit-control-text-bounds { 441 + position: absolute; 442 + left: 0; 443 + right: 184px; 444 + } 445 + 446 + .device-desktop .text-with-submit-control-submit-bounds { 447 + text-align: right; 448 + } 449 + 450 + .device-desktop .text-with-submit-control-submit { 451 + width: 180px; 452 + }