2013-12-05 11:56:14 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
final class PhabricatorRepositoryPushLogSearchEngine
|
|
|
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
|
|
2014-06-12 13:22:20 -07:00
|
|
|
public function getResultTypeDescription() {
|
|
|
|
|
return pht('Push Logs');
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 12:28:02 -07:00
|
|
|
public function getApplicationClassName() {
|
|
|
|
|
return 'PhabricatorApplicationDiffusion';
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 11:56:14 -08:00
|
|
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
|
|
|
|
$saved = new PhabricatorSavedQuery();
|
|
|
|
|
|
2013-12-05 11:59:33 -08:00
|
|
|
$saved->setParameter(
|
|
|
|
|
'repositoryPHIDs',
|
|
|
|
|
$this->readPHIDsFromRequest(
|
|
|
|
|
$request,
|
|
|
|
|
'repositories',
|
|
|
|
|
array(
|
|
|
|
|
PhabricatorRepositoryPHIDTypeRepository::TYPECONST,
|
|
|
|
|
)));
|
|
|
|
|
|
|
|
|
|
$saved->setParameter(
|
|
|
|
|
'pusherPHIDs',
|
|
|
|
|
$this->readUsersFromRequest(
|
|
|
|
|
$request,
|
|
|
|
|
'pushers'));
|
|
|
|
|
|
2013-12-05 11:56:14 -08:00
|
|
|
return $saved;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
|
|
|
|
$query = id(new PhabricatorRepositoryPushLogQuery());
|
|
|
|
|
|
2013-12-05 11:59:33 -08:00
|
|
|
$repository_phids = $saved->getParameter('repositoryPHIDs');
|
|
|
|
|
if ($repository_phids) {
|
|
|
|
|
$query->withRepositoryPHIDs($repository_phids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$pusher_phids = $saved->getParameter('pusherPHIDs');
|
|
|
|
|
if ($pusher_phids) {
|
|
|
|
|
$query->withPusherPHIDs($pusher_phids);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 11:56:14 -08:00
|
|
|
return $query;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function buildSearchForm(
|
|
|
|
|
AphrontFormView $form,
|
|
|
|
|
PhabricatorSavedQuery $saved_query) {
|
|
|
|
|
|
2013-12-05 11:59:33 -08:00
|
|
|
$repository_phids = $saved_query->getParameter('repositoryPHIDs', array());
|
|
|
|
|
$pusher_phids = $saved_query->getParameter('pusherPHIDs', array());
|
|
|
|
|
|
|
|
|
|
$all_phids = array_merge(
|
|
|
|
|
$repository_phids,
|
|
|
|
|
$pusher_phids);
|
|
|
|
|
|
|
|
|
|
if ($all_phids) {
|
|
|
|
|
$handles = id(new PhabricatorHandleQuery())
|
|
|
|
|
->setViewer($this->requireViewer())
|
|
|
|
|
->withPHIDs($all_phids)
|
|
|
|
|
->execute();
|
|
|
|
|
} else {
|
|
|
|
|
$handles = array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$repository_handles = array_select_keys($handles, $repository_phids);
|
|
|
|
|
$pusher_handles = array_select_keys($handles, $pusher_phids);
|
|
|
|
|
|
|
|
|
|
$form
|
|
|
|
|
->appendChild(
|
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
|
->setDatasource('/typeahead/common/repositories/')
|
|
|
|
|
->setName('repositories')
|
|
|
|
|
->setLabel(pht('Repositories'))
|
|
|
|
|
->setValue($repository_handles))
|
|
|
|
|
->appendChild(
|
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
|
->setDatasource('/typeahead/common/accounts/')
|
|
|
|
|
->setName('pushers')
|
|
|
|
|
->setLabel(pht('Pushers'))
|
|
|
|
|
->setValue($pusher_handles));
|
2013-12-05 11:56:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getURI($path) {
|
|
|
|
|
return '/diffusion/pushlog/'.$path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getBuiltinQueryNames() {
|
|
|
|
|
$names = array(
|
|
|
|
|
'all' => pht('All Push Logs'),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return $names;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
|
|
|
|
|
|
$query = $this->newSavedQuery();
|
|
|
|
|
$query->setQueryKey($query_key);
|
|
|
|
|
|
|
|
|
|
switch ($query_key) {
|
|
|
|
|
case 'all':
|
|
|
|
|
return $query;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 14:00:24 -07:00
|
|
|
protected function getRequiredHandlePHIDsForResultList(
|
|
|
|
|
array $logs,
|
|
|
|
|
PhabricatorSavedQuery $query) {
|
|
|
|
|
return mpull($logs, 'getPusherPHID');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function renderResultList(
|
|
|
|
|
array $logs,
|
|
|
|
|
PhabricatorSavedQuery $query,
|
|
|
|
|
array $handles) {
|
|
|
|
|
|
|
|
|
|
$table = id(new DiffusionPushLogListView())
|
|
|
|
|
->setUser($this->requireViewer())
|
|
|
|
|
->setHandles($handles)
|
|
|
|
|
->setLogs($logs);
|
|
|
|
|
|
|
|
|
|
$box = id(new PHUIBoxView())
|
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE)
|
|
|
|
|
->appendChild($table);
|
|
|
|
|
|
|
|
|
|
return $box;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 11:56:14 -08:00
|
|
|
}
|