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

Herald - add application search for transcripts

Summary: this diff also makes the "test console" appear with the main search nav *and* updates application search to use the page title as the crumb rather than just search. Fixes T4399.

Test Plan: queried for transcript ids - success! queried for TX and MX - success! saved the TX and MX query and it worked again!

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4399

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

+177 -34
+7 -1
src/__phutil_library_map__.php
··· 836 836 'HeraldTranscriptGarbageCollector' => 'applications/herald/garbagecollector/HeraldTranscriptGarbageCollector.php', 837 837 'HeraldTranscriptListController' => 'applications/herald/controller/HeraldTranscriptListController.php', 838 838 'HeraldTranscriptQuery' => 'applications/herald/query/HeraldTranscriptQuery.php', 839 + 'HeraldTranscriptSearchEngine' => 'applications/herald/query/HeraldTranscriptSearchEngine.php', 839 840 'HeraldTranscriptTestCase' => 'applications/herald/storage/__tests__/HeraldTranscriptTestCase.php', 840 841 'Javelin' => 'infrastructure/javelin/Javelin.php', 841 842 'JavelinReactorExample' => 'applications/uiexample/examples/JavelinReactorExample.php', ··· 3455 3456 ), 3456 3457 'HeraldTranscriptController' => 'HeraldController', 3457 3458 'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector', 3458 - 'HeraldTranscriptListController' => 'HeraldController', 3459 + 'HeraldTranscriptListController' => 3460 + array( 3461 + 0 => 'HeraldController', 3462 + 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 3463 + ), 3459 3464 'HeraldTranscriptQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3465 + 'HeraldTranscriptSearchEngine' => 'PhabricatorApplicationSearchEngine', 3460 3466 'HeraldTranscriptTestCase' => 'PhabricatorTestCase', 3461 3467 'JavelinReactorExample' => 'PhabricatorUIExample', 3462 3468 'JavelinUIExample' => 'PhabricatorUIExample',
+6 -3
src/applications/herald/application/PhabricatorApplicationHerald.php
··· 47 47 'HeraldDisableController', 48 48 'history/(?:(?P<id>[1-9]\d*)/)?' => 'HeraldRuleEditHistoryController', 49 49 'test/' => 'HeraldTestConsoleController', 50 - 'transcript/' => 'HeraldTranscriptListController', 51 - 'transcript/(?P<id>[1-9]\d*)/(?:(?P<filter>\w+)/)?' 50 + 'transcript/' => array( 51 + '' => 'HeraldTranscriptListController', 52 + '(?:query/(?P<queryKey>[^/]+)/)?' => 'HeraldTranscriptListController', 53 + '(?P<id>[1-9]\d*)/(?:(?P<filter>\w+)/)?' 52 54 => 'HeraldTranscriptController', 53 - ), 55 + ) 56 + ) 54 57 ); 55 58 } 56 59
+6 -4
src/applications/herald/controller/HeraldTestConsoleController.php
··· 96 96 ->setFormErrors($errors) 97 97 ->setForm($form); 98 98 99 + $nav = $this->buildSideNavView(); 100 + $nav->selectFilter('test'); 101 + $nav->appendChild($box); 102 + 99 103 $crumbs = id($this->buildApplicationCrumbs()) 100 - ->addTextCrumb( 101 - pht('Transcripts'), 102 - $this->getApplicationURI('/transcript/')) 103 104 ->addTextCrumb(pht('Test Console')); 105 + $nav->setCrumbs($crumbs); 104 106 105 107 return $this->buildApplicationPage( 106 - $box, 108 + $nav, 107 109 array( 108 110 'title' => pht('Test Console'), 109 111 'device' => true,
+52 -25
src/applications/herald/controller/HeraldTranscriptListController.php
··· 1 1 <?php 2 2 3 - final class HeraldTranscriptListController extends HeraldController { 3 + final class HeraldTranscriptListController extends HeraldController 4 + implements PhabricatorApplicationSearchResultsControllerInterface { 5 + 6 + private $queryKey; 7 + 8 + public function buildSideNavView($for_app = false) { 9 + $user = $this->getRequest()->getUser(); 10 + 11 + $nav = new AphrontSideNavFilterView(); 12 + $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); 13 + 14 + if ($for_app) { 15 + $nav->addFilter('new', pht('Create Rule')); 16 + } 17 + 18 + id(new HeraldTranscriptSearchEngine()) 19 + ->setViewer($user) 20 + ->addNavigationItems($nav->getMenu()); 21 + 22 + $nav->selectFilter(null); 23 + 24 + return $nav; 25 + } 26 + 27 + public function buildApplicationCrumbs() { 28 + $crumbs = parent::buildApplicationCrumbs(); 29 + 30 + $crumbs->addTextCrumb( 31 + pht('Transcripts'), 32 + $this->getApplicationURI('transcript/')); 33 + return $crumbs; 34 + } 35 + 36 + public function willProcessRequest(array $data) { 37 + $this->queryKey = idx($data, 'queryKey'); 38 + } 4 39 5 40 public function processRequest() { 41 + $request = $this->getRequest(); 42 + $controller = id(new PhabricatorApplicationSearchController($request)) 43 + ->setQueryKey($this->queryKey) 44 + ->setSearchEngine(new HeraldTranscriptSearchEngine()) 45 + ->setNavigation($this->buildSideNavView()); 6 46 7 - $request = $this->getRequest(); 8 - $user = $request->getUser(); 47 + return $this->delegateToController($controller); 48 + } 9 49 10 - $pager = new AphrontCursorPagerView(); 11 - $pager->readFromRequest($request); 50 + 51 + public function renderResultsList( 52 + array $transcripts, 53 + PhabricatorSavedQuery $query) { 54 + assert_instances_of($transcripts, 'HeraldTranscript'); 12 55 13 - $transcripts = id(new HeraldTranscriptQuery()) 14 - ->setViewer($user) 15 - ->needPartialRecords(true) 16 - ->executeWithCursorPager($pager); 56 + $viewer = $this->getRequest()->getUser(); 17 57 18 58 // Render the table. 19 59 $handles = array(); ··· 25 65 $rows = array(); 26 66 foreach ($transcripts as $xscript) { 27 67 $rows[] = array( 28 - phabricator_date($xscript->getTime(), $user), 29 - phabricator_time($xscript->getTime(), $user), 68 + phabricator_date($xscript->getTime(), $viewer), 69 + phabricator_time($xscript->getTime(), $viewer), 30 70 $handles[$xscript->getObjectPHID()]->renderLink(), 31 71 $xscript->getDryRun() ? pht('Yes') : '', 32 72 number_format((int)(1000 * $xscript->getDuration())).' ms', ··· 64 104 $panel = new AphrontPanelView(); 65 105 $panel->setHeader(pht('Herald Transcripts')); 66 106 $panel->appendChild($table); 67 - $panel->appendChild($pager); 68 107 $panel->setNoBackground(); 69 108 70 - $nav = $this->buildSideNavView(); 71 - $nav->selectFilter('transcript'); 72 - $nav->appendChild($panel); 109 + return $panel; 73 110 74 - $crumbs = id($this->buildApplicationCrumbs()) 75 - ->addTextCrumb(pht('Transcripts')); 76 - $nav->setCrumbs($crumbs); 77 - 78 - return $this->buildApplicationPage( 79 - $nav, 80 - array( 81 - 'title' => pht('Herald Transcripts'), 82 - 'device' => true, 83 - )); 84 111 } 85 112 86 113 }
+13
src/applications/herald/query/HeraldTranscriptQuery.php
··· 4 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 5 6 6 private $ids; 7 + private $objectPHIDs; 7 8 private $needPartialRecords; 8 9 9 10 public function withIDs(array $ids) { 10 11 $this->ids = $ids; 12 + return $this; 13 + } 14 + 15 + public function withObjectPHIDs(array $phids) { 16 + $this->objectPHIDs = $phids; 11 17 return $this; 12 18 } 13 19 ··· 87 93 $conn_r, 88 94 'id IN (%Ld)', 89 95 $this->ids); 96 + } 97 + 98 + if ($this->objectPHIDs) { 99 + $where[] = qsprintf( 100 + $conn_r, 101 + 'objectPHID in (%Ls)', 102 + $this->objectPHIDs); 90 103 } 91 104 92 105 $where[] = $this->buildPagingClause($conn_r);
+92
src/applications/herald/query/HeraldTranscriptSearchEngine.php
··· 1 + <?php 2 + 3 + final class HeraldTranscriptSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function buildSavedQueryFromRequest(AphrontRequest $request) { 7 + $saved = new PhabricatorSavedQuery(); 8 + 9 + $object_monograms = $request->getStrList('objectMonograms'); 10 + $saved->setParameter('objectMonograms', $object_monograms); 11 + 12 + $ids = $request->getStrList('ids'); 13 + foreach ($ids as $key => $id) { 14 + if (!$id || !is_numeric($id)) { 15 + unset($ids[$key]); 16 + } else { 17 + $ids[$key] = $id; 18 + } 19 + } 20 + $saved->setParameter('ids', $ids); 21 + 22 + return $saved; 23 + } 24 + 25 + public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 26 + $query = id(new HeraldTranscriptQuery()); 27 + 28 + $object_monograms = $saved->getParameter('objectMonograms'); 29 + if ($object_monograms) { 30 + $objects = id(new PhabricatorObjectQuery()) 31 + ->setViewer($this->requireViewer()) 32 + ->withNames($object_monograms) 33 + ->execute(); 34 + $query->withObjectPHIDs(mpull($objects, 'getPHID')); 35 + } 36 + 37 + $ids = $saved->getParameter('ids'); 38 + if ($ids) { 39 + $query->withIDs($ids); 40 + } 41 + 42 + return $query; 43 + } 44 + 45 + public function buildSearchForm( 46 + AphrontFormView $form, 47 + PhabricatorSavedQuery $saved) { 48 + 49 + $object_monograms = $saved->getParameter('objectMonograms', array()); 50 + $ids = $saved->getParameter('ids', array()); 51 + 52 + $form 53 + ->appendChild( 54 + id(new AphrontFormTextControl()) 55 + ->setName('objectMonograms') 56 + ->setLabel(pht('Object Monograms')) 57 + ->setValue(implode(', ', $object_monograms))) 58 + ->appendChild( 59 + id(new AphrontFormTextControl()) 60 + ->setName('ids') 61 + ->setLabel(pht('Transcript IDs')) 62 + ->setValue(implode(', ', $ids))); 63 + } 64 + 65 + protected function getURI($path) { 66 + return '/herald/transcript/'.$path; 67 + } 68 + 69 + public function getBuiltinQueryNames() { 70 + $names = array(); 71 + 72 + $names['all'] = pht('All'); 73 + 74 + return $names; 75 + } 76 + 77 + public function buildSavedQueryFromBuiltin($query_key) { 78 + 79 + $query = $this->newSavedQuery(); 80 + $query->setQueryKey($query_key); 81 + 82 + $viewer_phid = $this->requireViewer()->getPHID(); 83 + 84 + switch ($query_key) { 85 + case 'all': 86 + return $query; 87 + } 88 + 89 + return parent::buildSavedQueryFromBuiltin($query_key); 90 + } 91 + 92 + }
+1 -1
src/applications/search/controller/PhabricatorApplicationSearchController.php
··· 281 281 282 282 $crumbs = $parent 283 283 ->buildApplicationCrumbs() 284 - ->addTextCrumb(pht("Search")); 284 + ->addTextCrumb($title); 285 285 286 286 $nav->setCrumbs($crumbs); 287 287