mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
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
This commit is contained in:
parent
81d385ff41
commit
20a3ee24f9
7 changed files with 177 additions and 34 deletions
|
@ -836,6 +836,7 @@ phutil_register_library_map(array(
|
|||
'HeraldTranscriptGarbageCollector' => 'applications/herald/garbagecollector/HeraldTranscriptGarbageCollector.php',
|
||||
'HeraldTranscriptListController' => 'applications/herald/controller/HeraldTranscriptListController.php',
|
||||
'HeraldTranscriptQuery' => 'applications/herald/query/HeraldTranscriptQuery.php',
|
||||
'HeraldTranscriptSearchEngine' => 'applications/herald/query/HeraldTranscriptSearchEngine.php',
|
||||
'HeraldTranscriptTestCase' => 'applications/herald/storage/__tests__/HeraldTranscriptTestCase.php',
|
||||
'Javelin' => 'infrastructure/javelin/Javelin.php',
|
||||
'JavelinReactorExample' => 'applications/uiexample/examples/JavelinReactorExample.php',
|
||||
|
@ -3455,8 +3456,13 @@ phutil_register_library_map(array(
|
|||
),
|
||||
'HeraldTranscriptController' => 'HeraldController',
|
||||
'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||
'HeraldTranscriptListController' => 'HeraldController',
|
||||
'HeraldTranscriptListController' =>
|
||||
array(
|
||||
0 => 'HeraldController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'HeraldTranscriptQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'HeraldTranscriptSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'HeraldTranscriptTestCase' => 'PhabricatorTestCase',
|
||||
'JavelinReactorExample' => 'PhabricatorUIExample',
|
||||
'JavelinUIExample' => 'PhabricatorUIExample',
|
||||
|
|
|
@ -47,10 +47,13 @@ final class PhabricatorApplicationHerald extends PhabricatorApplication {
|
|||
'HeraldDisableController',
|
||||
'history/(?:(?P<id>[1-9]\d*)/)?' => 'HeraldRuleEditHistoryController',
|
||||
'test/' => 'HeraldTestConsoleController',
|
||||
'transcript/' => 'HeraldTranscriptListController',
|
||||
'transcript/(?P<id>[1-9]\d*)/(?:(?P<filter>\w+)/)?'
|
||||
'transcript/' => array(
|
||||
'' => 'HeraldTranscriptListController',
|
||||
'(?:query/(?P<queryKey>[^/]+)/)?' => 'HeraldTranscriptListController',
|
||||
'(?P<id>[1-9]\d*)/(?:(?P<filter>\w+)/)?'
|
||||
=> 'HeraldTranscriptController',
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,14 +96,16 @@ final class HeraldTestConsoleController extends HeraldController {
|
|||
->setFormErrors($errors)
|
||||
->setForm($form);
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->selectFilter('test');
|
||||
$nav->appendChild($box);
|
||||
|
||||
$crumbs = id($this->buildApplicationCrumbs())
|
||||
->addTextCrumb(
|
||||
pht('Transcripts'),
|
||||
$this->getApplicationURI('/transcript/'))
|
||||
->addTextCrumb(pht('Test Console'));
|
||||
$nav->setCrumbs($crumbs);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$box,
|
||||
$nav,
|
||||
array(
|
||||
'title' => pht('Test Console'),
|
||||
'device' => true,
|
||||
|
|
|
@ -1,19 +1,59 @@
|
|||
<?php
|
||||
|
||||
final class HeraldTranscriptListController extends HeraldController {
|
||||
final class HeraldTranscriptListController extends HeraldController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
public function buildSideNavView($for_app = false) {
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||
|
||||
if ($for_app) {
|
||||
$nav->addFilter('new', pht('Create Rule'));
|
||||
}
|
||||
|
||||
id(new HeraldTranscriptSearchEngine())
|
||||
->setViewer($user)
|
||||
->addNavigationItems($nav->getMenu());
|
||||
|
||||
$nav->selectFilter(null);
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
public function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
$crumbs->addTextCrumb(
|
||||
pht('Transcripts'),
|
||||
$this->getApplicationURI('transcript/'));
|
||||
return $crumbs;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->queryKey = idx($data, 'queryKey');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$controller = id(new PhabricatorApplicationSearchController($request))
|
||||
->setQueryKey($this->queryKey)
|
||||
->setSearchEngine(new HeraldTranscriptSearchEngine())
|
||||
->setNavigation($this->buildSideNavView());
|
||||
|
||||
$pager = new AphrontCursorPagerView();
|
||||
$pager->readFromRequest($request);
|
||||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
$transcripts = id(new HeraldTranscriptQuery())
|
||||
->setViewer($user)
|
||||
->needPartialRecords(true)
|
||||
->executeWithCursorPager($pager);
|
||||
|
||||
public function renderResultsList(
|
||||
array $transcripts,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($transcripts, 'HeraldTranscript');
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
// Render the table.
|
||||
$handles = array();
|
||||
|
@ -25,8 +65,8 @@ final class HeraldTranscriptListController extends HeraldController {
|
|||
$rows = array();
|
||||
foreach ($transcripts as $xscript) {
|
||||
$rows[] = array(
|
||||
phabricator_date($xscript->getTime(), $user),
|
||||
phabricator_time($xscript->getTime(), $user),
|
||||
phabricator_date($xscript->getTime(), $viewer),
|
||||
phabricator_time($xscript->getTime(), $viewer),
|
||||
$handles[$xscript->getObjectPHID()]->renderLink(),
|
||||
$xscript->getDryRun() ? pht('Yes') : '',
|
||||
number_format((int)(1000 * $xscript->getDuration())).' ms',
|
||||
|
@ -64,23 +104,10 @@ final class HeraldTranscriptListController extends HeraldController {
|
|||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader(pht('Herald Transcripts'));
|
||||
$panel->appendChild($table);
|
||||
$panel->appendChild($pager);
|
||||
$panel->setNoBackground();
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->selectFilter('transcript');
|
||||
$nav->appendChild($panel);
|
||||
return $panel;
|
||||
|
||||
$crumbs = id($this->buildApplicationCrumbs())
|
||||
->addTextCrumb(pht('Transcripts'));
|
||||
$nav->setCrumbs($crumbs);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
array(
|
||||
'title' => pht('Herald Transcripts'),
|
||||
'device' => true,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ final class HeraldTranscriptQuery
|
|||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||
|
||||
private $ids;
|
||||
private $objectPHIDs;
|
||||
private $needPartialRecords;
|
||||
|
||||
public function withIDs(array $ids) {
|
||||
|
@ -11,6 +12,11 @@ final class HeraldTranscriptQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withObjectPHIDs(array $phids) {
|
||||
$this->objectPHIDs = $phids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needPartialRecords($need_partial) {
|
||||
$this->needPartialRecords = $need_partial;
|
||||
return $this;
|
||||
|
@ -89,6 +95,13 @@ final class HeraldTranscriptQuery
|
|||
$this->ids);
|
||||
}
|
||||
|
||||
if ($this->objectPHIDs) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'objectPHID in (%Ls)',
|
||||
$this->objectPHIDs);
|
||||
}
|
||||
|
||||
$where[] = $this->buildPagingClause($conn_r);
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
final class HeraldTranscriptSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
|
||||
$object_monograms = $request->getStrList('objectMonograms');
|
||||
$saved->setParameter('objectMonograms', $object_monograms);
|
||||
|
||||
$ids = $request->getStrList('ids');
|
||||
foreach ($ids as $key => $id) {
|
||||
if (!$id || !is_numeric($id)) {
|
||||
unset($ids[$key]);
|
||||
} else {
|
||||
$ids[$key] = $id;
|
||||
}
|
||||
}
|
||||
$saved->setParameter('ids', $ids);
|
||||
|
||||
return $saved;
|
||||
}
|
||||
|
||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
||||
$query = id(new HeraldTranscriptQuery());
|
||||
|
||||
$object_monograms = $saved->getParameter('objectMonograms');
|
||||
if ($object_monograms) {
|
||||
$objects = id(new PhabricatorObjectQuery())
|
||||
->setViewer($this->requireViewer())
|
||||
->withNames($object_monograms)
|
||||
->execute();
|
||||
$query->withObjectPHIDs(mpull($objects, 'getPHID'));
|
||||
}
|
||||
|
||||
$ids = $saved->getParameter('ids');
|
||||
if ($ids) {
|
||||
$query->withIDs($ids);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function buildSearchForm(
|
||||
AphrontFormView $form,
|
||||
PhabricatorSavedQuery $saved) {
|
||||
|
||||
$object_monograms = $saved->getParameter('objectMonograms', array());
|
||||
$ids = $saved->getParameter('ids', array());
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('objectMonograms')
|
||||
->setLabel(pht('Object Monograms'))
|
||||
->setValue(implode(', ', $object_monograms)))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('ids')
|
||||
->setLabel(pht('Transcript IDs'))
|
||||
->setValue(implode(', ', $ids)));
|
||||
}
|
||||
|
||||
protected function getURI($path) {
|
||||
return '/herald/transcript/'.$path;
|
||||
}
|
||||
|
||||
public function getBuiltinQueryNames() {
|
||||
$names = array();
|
||||
|
||||
$names['all'] = pht('All');
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromBuiltin($query_key) {
|
||||
|
||||
$query = $this->newSavedQuery();
|
||||
$query->setQueryKey($query_key);
|
||||
|
||||
$viewer_phid = $this->requireViewer()->getPHID();
|
||||
|
||||
switch ($query_key) {
|
||||
case 'all':
|
||||
return $query;
|
||||
}
|
||||
|
||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
}
|
|
@ -281,7 +281,7 @@ final class PhabricatorApplicationSearchController
|
|||
|
||||
$crumbs = $parent
|
||||
->buildApplicationCrumbs()
|
||||
->addTextCrumb(pht("Search"));
|
||||
->addTextCrumb($title);
|
||||
|
||||
$nav->setCrumbs($crumbs);
|
||||
|
||||
|
|
Loading…
Reference in a new issue