2011-03-25 05:32:26 +01:00
|
|
|
<?php
|
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
final class HeraldTranscriptListController extends HeraldController
|
|
|
|
implements PhabricatorApplicationSearchResultsControllerInterface {
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
private $queryKey;
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
public function buildSideNavView($for_app = false) {
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
if ($for_app) {
|
|
|
|
$nav->addFilter('new', pht('Create Rule'));
|
|
|
|
}
|
2011-04-07 23:24:54 +02:00
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
id(new HeraldTranscriptSearchEngine())
|
2013-10-05 00:17:18 +02:00
|
|
|
->setViewer($user)
|
2014-02-21 21:51:25 +01:00
|
|
|
->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();
|
|
|
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
|
|
|
->setQueryKey($this->queryKey)
|
|
|
|
->setSearchEngine(new HeraldTranscriptSearchEngine())
|
|
|
|
->setNavigation($this->buildSideNavView());
|
|
|
|
|
|
|
|
return $this->delegateToController($controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function renderResultsList(
|
|
|
|
array $transcripts,
|
|
|
|
PhabricatorSavedQuery $query) {
|
|
|
|
assert_instances_of($transcripts, 'HeraldTranscript');
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2011-04-09 01:15:00 +02:00
|
|
|
// Render the table.
|
2011-03-25 05:32:26 +01:00
|
|
|
$handles = array();
|
2013-10-05 00:17:18 +02:00
|
|
|
if ($transcripts) {
|
|
|
|
$phids = mpull($transcripts, 'getObjectPHID', 'getObjectPHID');
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2011-03-25 05:32:26 +01:00
|
|
|
}
|
|
|
|
|
2014-04-27 20:18:48 +02:00
|
|
|
$list = new PHUIObjectItemListView();
|
|
|
|
$list->setCards(true);
|
2013-10-05 00:17:18 +02:00
|
|
|
foreach ($transcripts as $xscript) {
|
2014-04-27 20:18:48 +02:00
|
|
|
$view_href = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/herald/transcript/'.$xscript->getID().'/',
|
|
|
|
),
|
|
|
|
pht('View Full Transcript'));
|
|
|
|
|
|
|
|
$item = new PHUIObjectItemView();
|
|
|
|
$item->setObjectName($xscript->getID());
|
|
|
|
$item->setHeader($view_href);
|
|
|
|
if ($xscript->getDryRun()) {
|
|
|
|
$item->addAttribute(pht('Dry Run'));
|
|
|
|
}
|
|
|
|
$item->addAttribute($handles[$xscript->getObjectPHID()]->renderLink());
|
|
|
|
$item->addAttribute(
|
|
|
|
number_format((int)(1000 * $xscript->getDuration())).' ms');
|
|
|
|
$item->addIcon(
|
|
|
|
'none',
|
|
|
|
phabricator_datetime($xscript->getTime(), $viewer));
|
|
|
|
|
|
|
|
$list->addItem($item);
|
2011-03-25 05:32:26 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 23:25:58 +02:00
|
|
|
return $list;
|
2013-01-21 16:46:13 +01:00
|
|
|
|
2011-03-25 05:32:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|