1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +01:00

Move a bunch more rendering into SearchEngine

Summary: Ref T4986. These are mostly mechanical now, I skipped a couple of slightly tricky ones. Still a bunch to go.

Test Plan:
For each engine:

  - Viewed the application;
  - created a panel to issue the query.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4986

Differential Revision: https://secure.phabricator.com/D9017
This commit is contained in:
epriestley 2014-05-08 10:08:37 -07:00
parent c6a68aadc0
commit 78b89711cb
25 changed files with 561 additions and 556 deletions

View file

@ -3061,11 +3061,7 @@ phutil_register_library_map(array(
'DifferentialRevisionEditController' => 'DifferentialController',
'DifferentialRevisionIDField' => 'DifferentialCustomField',
'DifferentialRevisionLandController' => 'DifferentialController',
'DifferentialRevisionListController' =>
array(
0 => 'DifferentialController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DifferentialRevisionListController' => 'DifferentialController',
'DifferentialRevisionListView' => 'AphrontView',
'DifferentialRevisionMailReceiver' => 'PhabricatorObjectMailReceiver',
'DifferentialRevisionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
@ -3150,11 +3146,7 @@ phutil_register_library_map(array(
'DiffusionPathValidateController' => 'DiffusionController',
'DiffusionPushEventViewController' => 'DiffusionPushLogController',
'DiffusionPushLogController' => 'DiffusionController',
'DiffusionPushLogListController' =>
array(
0 => 'DiffusionPushLogController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DiffusionPushLogListController' => 'DiffusionPushLogController',
'DiffusionQuery' => 'PhabricatorQuery',
'DiffusionRawDiffQuery' => 'DiffusionQuery',
'DiffusionRepositoryController' => 'DiffusionController',
@ -3172,11 +3164,7 @@ phutil_register_library_map(array(
'DiffusionRepositoryEditLocalController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditMainController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditSubversionController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryListController' =>
array(
0 => 'DiffusionController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DiffusionRepositoryListController' => 'DiffusionController',
'DiffusionRepositoryNewController' => 'DiffusionController',
'DiffusionRepositoryRef' => 'Phobject',
'DiffusionRepositoryRemarkupRule' => 'PhabricatorRemarkupRuleObject',
@ -3208,11 +3196,7 @@ phutil_register_library_map(array(
'DivinerArticleAtomizer' => 'DivinerAtomizer',
'DivinerAtomCache' => 'DivinerDiskCache',
'DivinerAtomController' => 'DivinerController',
'DivinerAtomListController' =>
array(
0 => 'DivinerController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DivinerAtomListController' => 'DivinerController',
'DivinerAtomQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DivinerAtomSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DivinerAtomizeWorkflow' => 'DivinerWorkflow',
@ -3281,11 +3265,7 @@ phutil_register_library_map(array(
'DrydockBlueprintCreateController' => 'DrydockBlueprintController',
'DrydockBlueprintEditController' => 'DrydockBlueprintController',
'DrydockBlueprintEditor' => 'PhabricatorApplicationTransactionEditor',
'DrydockBlueprintListController' =>
array(
0 => 'DrydockBlueprintController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DrydockBlueprintListController' => 'DrydockBlueprintController',
'DrydockBlueprintQuery' => 'DrydockQuery',
'DrydockBlueprintSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DrydockBlueprintTransaction' => 'PhabricatorApplicationTransaction',
@ -3438,11 +3418,7 @@ phutil_register_library_map(array(
2 => 'HarbormasterBuildableInterface',
),
'HarbormasterBuildableActionController' => 'HarbormasterController',
'HarbormasterBuildableListController' =>
array(
0 => 'HarbormasterController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'HarbormasterBuildableListController' => 'HarbormasterController',
'HarbormasterBuildableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'HarbormasterBuildableSearchEngine' => 'PhabricatorApplicationSearchEngine',
'HarbormasterBuildableViewController' => 'HarbormasterController',
@ -3466,11 +3442,7 @@ phutil_register_library_map(array(
'HarbormasterPlanController' => 'HarbormasterController',
'HarbormasterPlanDisableController' => 'HarbormasterPlanController',
'HarbormasterPlanEditController' => 'HarbormasterPlanController',
'HarbormasterPlanListController' =>
array(
0 => 'HarbormasterPlanController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'HarbormasterPlanListController' => 'HarbormasterPlanController',
'HarbormasterPlanOrderController' => 'HarbormasterController',
'HarbormasterPlanRunController' => 'HarbormasterController',
'HarbormasterPlanViewController' => 'HarbormasterPlanController',
@ -3520,11 +3492,7 @@ phutil_register_library_map(array(
'HeraldRuleEditHistoryController' => 'HeraldController',
'HeraldRuleEditHistoryView' => 'AphrontView',
'HeraldRuleEditor' => 'PhabricatorApplicationTransactionEditor',
'HeraldRuleListController' =>
array(
0 => 'HeraldController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'HeraldRuleListController' => 'HeraldController',
'HeraldRuleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'HeraldRuleSearchEngine' => 'PhabricatorApplicationSearchEngine',
'HeraldRuleTransaction' => 'PhabricatorApplicationTransaction',
@ -4133,11 +4101,7 @@ phutil_register_library_map(array(
'PhabricatorConduitConsoleController' => 'PhabricatorConduitController',
'PhabricatorConduitController' => 'PhabricatorController',
'PhabricatorConduitDAO' => 'PhabricatorLiskDAO',
'PhabricatorConduitListController' =>
array(
0 => 'PhabricatorConduitController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'PhabricatorConduitListController' => 'PhabricatorConduitController',
'PhabricatorConduitLogController' => 'PhabricatorConduitController',
'PhabricatorConduitLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorConduitMethodCallLog' =>
@ -4202,11 +4166,7 @@ phutil_register_library_map(array(
'PhabricatorCountdownDAO' => 'PhabricatorLiskDAO',
'PhabricatorCountdownDeleteController' => 'PhabricatorCountdownController',
'PhabricatorCountdownEditController' => 'PhabricatorCountdownController',
'PhabricatorCountdownListController' =>
array(
0 => 'PhabricatorCountdownController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'PhabricatorCountdownListController' => 'PhabricatorCountdownController',
'PhabricatorCountdownPHIDTypeCountdown' => 'PhabricatorPHIDType',
'PhabricatorCountdownQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorCountdownRemarkupRule' => 'PhabricatorRemarkupRuleObject',
@ -4265,11 +4225,7 @@ phutil_register_library_map(array(
'PhabricatorDashboardController' => 'PhabricatorController',
'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO',
'PhabricatorDashboardEditController' => 'PhabricatorDashboardController',
'PhabricatorDashboardListController' =>
array(
0 => 'PhabricatorDashboardController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'PhabricatorDashboardListController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPHIDTypeDashboard' => 'PhabricatorPHIDType',
'PhabricatorDashboardPHIDTypePanel' => 'PhabricatorPHIDType',
'PhabricatorDashboardPanel' =>
@ -4286,11 +4242,7 @@ phutil_register_library_map(array(
'PhabricatorDashboardPanelCreateController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField',
'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelListController' =>
array(
0 => 'PhabricatorDashboardController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'PhabricatorDashboardPanelListController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorDashboardPanelRenderController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelRenderingEngine' => 'Phobject',
@ -4415,11 +4367,7 @@ phutil_register_library_map(array(
'PhabricatorFileInfoController' => 'PhabricatorFileController',
'PhabricatorFileLinkListView' => 'AphrontView',
'PhabricatorFileLinkView' => 'AphrontView',
'PhabricatorFileListController' =>
array(
0 => 'PhabricatorFileController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'PhabricatorFileListController' => 'PhabricatorFileController',
'PhabricatorFilePHIDTypeFile' => 'PhabricatorPHIDType',
'PhabricatorFileQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorFileSearchEngine' => 'PhabricatorApplicationSearchEngine',
@ -4452,11 +4400,7 @@ phutil_register_library_map(array(
'PhabricatorFlagDAO' => 'PhabricatorLiskDAO',
'PhabricatorFlagDeleteController' => 'PhabricatorFlagController',
'PhabricatorFlagEditController' => 'PhabricatorFlagController',
'PhabricatorFlagListController' =>
array(
0 => 'PhabricatorFlagController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'PhabricatorFlagListController' => 'PhabricatorFlagController',
'PhabricatorFlagQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorFlagSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorFlagSelectControl' => 'AphrontFormControl',

View file

@ -1,10 +1,10 @@
<?php
final class PhabricatorDashboardPanelListController
extends PhabricatorDashboardController
implements PhabricatorApplicationSearchResultsControllerInterface {
extends PhabricatorDashboardController {
private $queryKey;
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
@ -47,25 +47,4 @@ final class PhabricatorDashboardPanelListController
return $crumbs;
}
public function renderResultsList(
array $panels,
PhabricatorSavedQuery $query) {
$viewer = $this->getRequest()->getUser();
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($panels as $panel) {
$item = id(new PHUIObjectItemView())
->setObjectName($panel->getMonogram())
->setHeader($panel->getName())
->setHref('/'.$panel->getMonogram())
->setObject($panel);
$list->addItem($item);
}
return $list;
}
}

View file

@ -3,6 +3,10 @@
final class PhabricatorDashboardPanelSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationDashboard';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
@ -46,4 +50,26 @@ final class PhabricatorDashboardPanelSearchEngine
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $panels,
PhabricatorSavedQuery $query,
array $handles) {
$viewer = $this->requireViewer();
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($panels as $panel) {
$item = id(new PHUIObjectItemView())
->setObjectName($panel->getMonogram())
->setHeader($panel->getName())
->setHref('/'.$panel->getMonogram())
->setObject($panel);
$list->addItem($item);
}
return $list;
}
}

View file

@ -1,7 +1,6 @@
<?php
final class DifferentialRevisionListController extends DifferentialController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class DifferentialRevisionListController extends DifferentialController {
private $queryKey;
@ -23,64 +22,4 @@ final class DifferentialRevisionListController extends DifferentialController
return $this->delegateToController($controller);
}
public function renderResultsList(
array $revisions,
PhabricatorSavedQuery $query) {
assert_instances_of($revisions, 'DifferentialRevision');
$user = $this->getRequest()->getUser();
$template = id(new DifferentialRevisionListView())
->setUser($user);
$views = array();
if ($query->getQueryKey() == 'active') {
$split = DifferentialRevisionQuery::splitResponsible(
$revisions,
$query->getParameter('responsiblePHIDs'));
list($blocking, $active, $waiting) = $split;
$views[] = id(clone $template)
->setHeader(pht('Blocking Others'))
->setNoDataString(
pht('No revisions are blocked on your action.'))
->setHighlightAge(true)
->setRevisions($blocking)
->setHandles(array());
$views[] = id(clone $template)
->setHeader(pht('Action Required'))
->setNoDataString(
pht('No revisions require your action.'))
->setHighlightAge(true)
->setRevisions($active)
->setHandles(array());
$views[] = id(clone $template)
->setHeader(pht('Waiting on Others'))
->setNoDataString(
pht('You have no revisions waiting on others.'))
->setRevisions($waiting)
->setHandles(array());
} else {
$views[] = id(clone $template)
->setRevisions($revisions)
->setHandles(array());
}
$phids = array_mergev(mpull($views, 'getRequiredHandlePHIDs'));
$handles = $this->loadViewerHandles($phids);
foreach ($views as $view) {
$view->setHandles($handles);
}
if (count($views) == 1) {
// Reduce this to a PHUIObjectItemListView so we can get the free
// support from ApplicationSearch.
return head($views)->render();
} else {
return $views;
}
}
}

View file

@ -3,6 +3,10 @@
final class DifferentialRevisionSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationDifferential';
}
public function getPageSize(PhabricatorSavedQuery $saved) {
if ($saved->getQueryKey() == 'active') {
return 0xFFFF;
@ -243,4 +247,72 @@ final class DifferentialRevisionSearchEngine
);
}
protected function renderResultList(
array $revisions,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($revisions, 'DifferentialRevision');
$viewer = $this->requireViewer();
$template = id(new DifferentialRevisionListView())
->setUser($viewer);
$views = array();
if ($query->getQueryKey() == 'active') {
$split = DifferentialRevisionQuery::splitResponsible(
$revisions,
$query->getParameter('responsiblePHIDs'));
list($blocking, $active, $waiting) = $split;
$views[] = id(clone $template)
->setHeader(pht('Blocking Others'))
->setNoDataString(
pht('No revisions are blocked on your action.'))
->setHighlightAge(true)
->setRevisions($blocking)
->setHandles(array());
$views[] = id(clone $template)
->setHeader(pht('Action Required'))
->setNoDataString(
pht('No revisions require your action.'))
->setHighlightAge(true)
->setRevisions($active)
->setHandles(array());
$views[] = id(clone $template)
->setHeader(pht('Waiting on Others'))
->setNoDataString(
pht('You have no revisions waiting on others.'))
->setRevisions($waiting)
->setHandles(array());
} else {
$views[] = id(clone $template)
->setRevisions($revisions)
->setHandles(array());
}
$phids = array_mergev(mpull($views, 'getRequiredHandlePHIDs'));
if ($phids) {
$handles = id(new PhabricatorHandleQuery())
->setViewer($viewer)
->withPHIDs($phids)
->execute();
} else {
$handles = array();
}
foreach ($views as $view) {
$view->setHandles($handles);
}
if (count($views) == 1) {
// Reduce this to a PHUIObjectItemListView so we can get the free
// support from ApplicationSearch.
return head($views)->render();
} else {
return $views;
}
}
}

View file

@ -1,7 +1,6 @@
<?php
final class DiffusionPushLogListController extends DiffusionPushLogController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class DiffusionPushLogListController extends DiffusionPushLogController {
private $queryKey;

View file

@ -1,7 +1,6 @@
<?php
final class DiffusionRepositoryListController extends DiffusionController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class DiffusionRepositoryListController extends DiffusionController {
private $queryKey;
@ -23,83 +22,6 @@ final class DiffusionRepositoryListController extends DiffusionController
return $this->delegateToController($controller);
}
public function renderResultsList(
array $repositories,
PhabricatorSavedQuery $query) {
assert_instances_of($repositories, 'PhabricatorRepository');
$viewer = $this->getRequest()->getUser();
$project_phids = array_fuse(
array_mergev(
mpull($repositories, 'getProjectPHIDs')));
$project_handles = $this->loadViewerHandles($project_phids);
$list = new PHUIObjectItemListView();
$list->setCards(true);
foreach ($repositories as $repository) {
$id = $repository->getID();
$item = id(new PHUIObjectItemView())
->setUser($viewer)
->setHeader($repository->getName())
->setObjectName('r'.$repository->getCallsign())
->setHref($this->getApplicationURI($repository->getCallsign().'/'));
$commit = $repository->getMostRecentCommit();
if ($commit) {
$commit_link = DiffusionView::linkCommit(
$repository,
$commit->getCommitIdentifier(),
$commit->getSummary());
$item->setSubhead($commit_link);
$item->setEpoch($commit->getEpoch());
}
$item->addIcon(
'none',
PhabricatorRepositoryType::getNameForRepositoryType(
$repository->getVersionControlSystem()));
$size = $repository->getCommitCount();
if ($size) {
$history_uri = DiffusionRequest::generateDiffusionURI(
array(
'callsign' => $repository->getCallsign(),
'action' => 'history',
));
$item->addAttribute(
phutil_tag(
'a',
array(
'href' => $history_uri,
),
pht('%s Commit(s)', new PhutilNumber($size))));
} else {
$item->addAttribute(pht('No Commits'));
}
$handles = array_select_keys(
$project_handles,
$repository->getProjectPHIDs());
if ($handles) {
$item->addAttribute(
id(new ManiphestTaskProjectsView())
->setHandles($handles));
}
if (!$repository->isTracked()) {
$item->setDisabled(true);
$item->addIcon('disable-grey', pht('Inactive'));
}
$list->addItem($item);
}
return $list;
}
public function buildSideNavView($for_app = false) {
$viewer = $this->getRequest()->getUser();

View file

@ -1,7 +1,6 @@
<?php
final class DivinerAtomListController extends DivinerController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class DivinerAtomListController extends DivinerController {
private $key;
@ -23,32 +22,4 @@ final class DivinerAtomListController extends DivinerController
return $this->delegateToController($controller);
}
public function renderResultsList(
array $symbols,
PhabricatorSavedQuery $query) {
assert_instances_of($symbols, 'DivinerLiveSymbol');
$request = $this->getRequest();
$viewer = $request->getUser();
$list = id(new PHUIObjectItemListView())
->setUser($viewer);
foreach ($symbols as $symbol) {
$type = $symbol->getType();
$type_name = DivinerAtom::getAtomTypeNameString($type);
$item = id(new PHUIObjectItemView())
->setHeader($symbol->getTitle())
->setHref($symbol->getURI())
->addAttribute($symbol->getSummary())
->addIcon('none', $type_name);
$list->addItem($item);
}
return $list;
}
}

View file

@ -3,6 +3,10 @@
final class DivinerAtomSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationDiviner';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
@ -88,4 +92,32 @@ final class DivinerAtomSearchEngine
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $symbols,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($symbols, 'DivinerLiveSymbol');
$viewer = $this->requireViewer();
$list = id(new PHUIObjectItemListView())
->setUser($viewer);
foreach ($symbols as $symbol) {
$type = $symbol->getType();
$type_name = DivinerAtom::getAtomTypeNameString($type);
$item = id(new PHUIObjectItemView())
->setHeader($symbol->getTitle())
->setHref($symbol->getURI())
->addAttribute($symbol->getSummary())
->addIcon('none', $type_name);
$list->addItem($item);
}
return $list;
}
}

View file

@ -1,7 +1,6 @@
<?php
final class DrydockBlueprintListController extends DrydockBlueprintController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class DrydockBlueprintListController extends DrydockBlueprintController {
private $queryKey;
@ -23,32 +22,6 @@ final class DrydockBlueprintListController extends DrydockBlueprintController
return $this->delegateToController($controller);
}
public function renderResultsList(
array $blueprints,
PhabricatorSavedQuery $query) {
assert_instances_of($blueprints, 'DrydockBlueprint');
$viewer = $this->getRequest()->getUser();
$view = new PHUIObjectItemListView();
foreach ($blueprints as $blueprint) {
$item = id(new PHUIObjectItemView())
->setHeader($blueprint->getBlueprintName())
->setHref($this->getApplicationURI('/blueprint/'.$blueprint->getID()))
->setObjectName(pht('Blueprint %d', $blueprint->getID()));
if (!$blueprint->getImplementation()->isEnabled()) {
$item->setDisabled(true);
}
$item->addAttribute($blueprint->getImplementation()->getBlueprintName());
$view->addItem($item);
}
return $view;
}
public function buildApplicationCrumbs() {
$can_create = $this->hasApplicationCapability(
DrydockCapabilityCreateBlueprints::CAPABILITY);

View file

@ -3,6 +3,10 @@
final class DrydockBlueprintSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationDrydock';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
@ -45,4 +49,31 @@ final class DrydockBlueprintSearchEngine
return parent::buildSavedQueryFromBuiltin($query_key);
}
public function renderResultList(
array $blueprints,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($blueprints, 'DrydockBlueprint');
$viewer = $this->requireViewer();
$view = new PHUIObjectItemListView();
foreach ($blueprints as $blueprint) {
$item = id(new PHUIObjectItemView())
->setHeader($blueprint->getBlueprintName())
->setHref($this->getApplicationURI('/blueprint/'.$blueprint->getID()))
->setObjectName(pht('Blueprint %d', $blueprint->getID()));
if (!$blueprint->getImplementation()->isEnabled()) {
$item->setDisabled(true);
}
$item->addAttribute($blueprint->getImplementation()->getBlueprintName());
$view->addItem($item);
}
return $view;
}
}

View file

@ -1,8 +1,5 @@
<?php
/**
* @group file
*/
final class PhabricatorApplicationFiles extends PhabricatorApplication {
public function getBaseURI() {

View file

@ -1,7 +1,6 @@
<?php
final class PhabricatorFileListController extends PhabricatorFileController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class PhabricatorFileListController extends PhabricatorFileController {
private $key;
@ -23,65 +22,4 @@ final class PhabricatorFileListController extends PhabricatorFileController
return $this->delegateToController($controller);
}
public function renderResultsList(
array $files,
PhabricatorSavedQuery $query) {
assert_instances_of($files, 'PhabricatorFile');
$request = $this->getRequest();
$user = $request->getUser();
$highlighted_ids = $request->getStrList('h');
$this->loadHandles(mpull($files, 'getAuthorPHID'));
$request = $this->getRequest();
$user = $request->getUser();
$highlighted_ids = array_fill_keys($highlighted_ids, true);
$list_view = id(new PHUIObjectItemListView())
->setUser($user);
foreach ($files as $file) {
$id = $file->getID();
$phid = $file->getPHID();
$name = $file->getName();
$file_uri = $this->getApplicationURI("/info/{$phid}/");
$date_created = phabricator_date($file->getDateCreated(), $user);
$author_phid = $file->getAuthorPHID();
if ($author_phid) {
$author_link = $this->getHandle($author_phid)->renderLink();
$uploaded = pht('Uploaded by %s on %s', $author_link, $date_created);
} else {
$uploaded = pht('Uploaded on %s', $date_created);
}
$item = id(new PHUIObjectItemView())
->setObject($file)
->setObjectName("F{$id}")
->setHeader($name)
->setHref($file_uri)
->addAttribute($uploaded)
->addIcon('none', phabricator_format_bytes($file->getByteSize()));
$ttl = $file->getTTL();
if ($ttl !== null) {
$item->addIcon('blame', pht('Temporary'));
}
if (isset($highlighted_ids[$id])) {
$item->setEffect('highlighted');
}
$list_view->addItem($item);
}
$list_view->appendChild(id(new PhabricatorGlobalUploadTargetView())
->setUser($user));
return $list_view;
}
}

View file

@ -1,11 +1,12 @@
<?php
/**
* @group file
*/
final class PhabricatorFileSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationFiles';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
$saved->setParameter(
@ -113,4 +114,72 @@ final class PhabricatorFileSearchEngine
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function getRequiredHandlePHIDsForResultList(
array $files,
PhabricatorSavedQuery $query) {
return mpull($files, 'getAuthorPHID');
}
protected function renderResultList(
array $files,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($files, 'PhabricatorFile');
$request = $this->getRequest();
if ($request) {
$highlighted_ids = $request->getStrList('h');
} else {
$highlighted_ids = array();
}
$viewer = $this->requireViewer();
$highlighted_ids = array_fill_keys($highlighted_ids, true);
$list_view = id(new PHUIObjectItemListView())
->setUser($viewer);
foreach ($files as $file) {
$id = $file->getID();
$phid = $file->getPHID();
$name = $file->getName();
$file_uri = $this->getApplicationURI("/info/{$phid}/");
$date_created = phabricator_date($file->getDateCreated(), $viewer);
$author_phid = $file->getAuthorPHID();
if ($author_phid) {
$author_link = $handles[$author_phid]->renderLink();
$uploaded = pht('Uploaded by %s on %s', $author_link, $date_created);
} else {
$uploaded = pht('Uploaded on %s', $date_created);
}
$item = id(new PHUIObjectItemView())
->setObject($file)
->setObjectName("F{$id}")
->setHeader($name)
->setHref($file_uri)
->addAttribute($uploaded)
->addIcon('none', phabricator_format_bytes($file->getByteSize()));
$ttl = $file->getTTL();
if ($ttl !== null) {
$item->addIcon('blame', pht('Temporary'));
}
if (isset($highlighted_ids[$id])) {
$item->setEffect('highlighted');
}
$list_view->addItem($item);
}
$list_view->appendChild(id(new PhabricatorGlobalUploadTargetView())
->setUser($viewer));
return $list_view;
}
}

View file

@ -1,7 +1,6 @@
<?php
final class PhabricatorFlagListController extends PhabricatorFlagController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class PhabricatorFlagListController extends PhabricatorFlagController {
private $queryKey;
@ -23,56 +22,4 @@ final class PhabricatorFlagListController extends PhabricatorFlagController
return $this->delegateToController($controller);
}
public function renderResultsList(
array $flags,
PhabricatorSavedQuery $query) {
assert_instances_of($flags, 'PhabricatorFlag');
$viewer = $this->getRequest()->getUser();
$list = id(new PHUIObjectItemListView())
->setUser($viewer);
foreach ($flags as $flag) {
$id = $flag->getID();
$phid = $flag->getObjectPHID();
$class = PhabricatorFlagColor::getCSSClass($flag->getColor());
$flag_icon = phutil_tag(
'div',
array(
'class' => 'phabricator-flag-icon '.$class,
),
'');
$item = id(new PHUIObjectItemView())
->addHeadIcon($flag_icon)
->setHeader($flag->getHandle()->renderLink());
$item->addAction(
id(new PHUIListItemView())
->setIcon('edit')
->setHref($this->getApplicationURI("edit/{$phid}/"))
->setWorkflow(true));
$item->addAction(
id(new PHUIListItemView())
->setIcon('delete')
->setHref($this->getApplicationURI("delete/{$id}/"))
->setWorkflow(true));
if ($flag->getNote()) {
$item->addAttribute($flag->getNote());
}
$item->addIcon(
'none',
phabricator_datetime($flag->getDateCreated(), $viewer));
$list->addItem($item);
}
return $list;
}
}

View file

@ -3,6 +3,10 @@
final class PhabricatorFlagSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationFlags';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
$saved->setParameter('colors', $request->getArr('colors'));
@ -115,4 +119,58 @@ final class PhabricatorFlagSearchEngine
return $options;
}
protected function renderResultList(
array $flags,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($flags, 'PhabricatorFlag');
$viewer = $this->requireViewer();
$list = id(new PHUIObjectItemListView())
->setUser($viewer);
foreach ($flags as $flag) {
$id = $flag->getID();
$phid = $flag->getObjectPHID();
$class = PhabricatorFlagColor::getCSSClass($flag->getColor());
$flag_icon = phutil_tag(
'div',
array(
'class' => 'phabricator-flag-icon '.$class,
),
'');
$item = id(new PHUIObjectItemView())
->addHeadIcon($flag_icon)
->setHeader($flag->getHandle()->renderLink());
$item->addAction(
id(new PHUIListItemView())
->setIcon('edit')
->setHref($this->getApplicationURI("edit/{$phid}/"))
->setWorkflow(true));
$item->addAction(
id(new PHUIListItemView())
->setIcon('delete')
->setHref($this->getApplicationURI("delete/{$id}/"))
->setWorkflow(true));
if ($flag->getNote()) {
$item->addAttribute($flag->getNote());
}
$item->addIcon(
'none',
phabricator_datetime($flag->getDateCreated(), $viewer));
$list->addItem($item);
}
return $list;
}
}

View file

@ -1,8 +1,6 @@
<?php
final class HarbormasterBuildableListController
extends HarbormasterController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class HarbormasterBuildableListController extends HarbormasterController {
private $queryKey;
@ -24,58 +22,6 @@ final class HarbormasterBuildableListController
return $this->delegateToController($controller);
}
public function renderResultsList(
array $buildables,
PhabricatorSavedQuery $query) {
assert_instances_of($buildables, 'HarbormasterBuildable');
$viewer = $this->getRequest()->getUser();
$list = new PHUIObjectItemListView();
$list->setCards(true);
foreach ($buildables as $buildable) {
$id = $buildable->getID();
$item = id(new PHUIObjectItemView())
->setHeader(pht('Buildable %d', $buildable->getID()));
if ($buildable->getContainerHandle() !== null) {
$item->addAttribute($buildable->getContainerHandle()->getName());
}
if ($buildable->getBuildableHandle() !== null) {
$item->addAttribute($buildable->getBuildableHandle()->getFullName());
}
if ($id) {
$item->setHref("/B{$id}");
}
if ($buildable->getIsManualBuildable()) {
$item->addIcon('wrench-grey', pht('Manual'));
}
switch ($buildable->getBuildableStatus()) {
case HarbormasterBuildable::STATUS_PASSED:
$item->setBarColor('green');
$item->addByline(pht('Build Passed'));
break;
case HarbormasterBuildable::STATUS_FAILED:
$item->setBarColor('red');
$item->addByline(pht('Build Failed'));
break;
case HarbormasterBuildable::STATUS_BUILDING:
$item->setBarColor('red');
$item->addByline(pht('Building'));
break;
}
$list->addItem($item);
}
return $list;
}
public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();

View file

@ -1,8 +1,6 @@
<?php
final class HarbormasterPlanListController
extends HarbormasterPlanController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class HarbormasterPlanListController extends HarbormasterPlanController {
private $queryKey;
@ -24,33 +22,6 @@ final class HarbormasterPlanListController
return $this->delegateToController($controller);
}
public function renderResultsList(
array $plans,
PhabricatorSavedQuery $query) {
assert_instances_of($plans, 'HarbormasterBuildPlan');
$viewer = $this->getRequest()->getUser();
$list = new PHUIObjectItemListView();
foreach ($plans as $plan) {
$id = $plan->getID();
$item = id(new PHUIObjectItemView())
->setObjectName(pht('Plan %d', $plan->getID()))
->setHeader($plan->getName());
if ($plan->isDisabled()) {
$item->setDisabled(true);
}
$item->setHref($this->getApplicationURI("plan/{$id}/"));
$list->addItem($item);
}
return $list;
}
public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();

View file

@ -3,6 +3,10 @@
final class HarbormasterBuildPlanSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationHarbormaster';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
@ -79,4 +83,32 @@ final class HarbormasterBuildPlanSearchEngine
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $plans,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($plans, 'HarbormasterBuildPlan');
$viewer = $this->requireViewer();
$list = new PHUIObjectItemListView();
foreach ($plans as $plan) {
$id = $plan->getID();
$item = id(new PHUIObjectItemView())
->setObjectName(pht('Plan %d', $plan->getID()))
->setHeader($plan->getName());
if ($plan->isDisabled()) {
$item->setDisabled(true);
}
$item->setHref($this->getApplicationURI("plan/{$id}/"));
$list->addItem($item);
}
return $list;
}
}

View file

@ -3,6 +3,10 @@
final class HarbormasterBuildableSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationHarbormaster';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
@ -172,4 +176,56 @@ final class HarbormasterBuildableSearchEngine
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $buildables,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($buildables, 'HarbormasterBuildable');
$viewer = $this->requireViewer();
$list = new PHUIObjectItemListView();
$list->setCards(true);
foreach ($buildables as $buildable) {
$id = $buildable->getID();
$item = id(new PHUIObjectItemView())
->setHeader(pht('Buildable %d', $buildable->getID()));
if ($buildable->getContainerHandle() !== null) {
$item->addAttribute($buildable->getContainerHandle()->getName());
}
if ($buildable->getBuildableHandle() !== null) {
$item->addAttribute($buildable->getBuildableHandle()->getFullName());
}
if ($id) {
$item->setHref("/B{$id}");
}
if ($buildable->getIsManualBuildable()) {
$item->addIcon('wrench-grey', pht('Manual'));
}
switch ($buildable->getBuildableStatus()) {
case HarbormasterBuildable::STATUS_PASSED:
$item->setBarColor('green');
$item->addByline(pht('Build Passed'));
break;
case HarbormasterBuildable::STATUS_FAILED:
$item->setBarColor('red');
$item->addByline(pht('Build Failed'));
break;
case HarbormasterBuildable::STATUS_BUILDING:
$item->setBarColor('red');
$item->addByline(pht('Building'));
break;
}
$list->addItem($item);
}
return $list;
}
}

View file

@ -1,7 +1,6 @@
<?php
final class HeraldRuleListController extends HeraldController
implements PhabricatorApplicationSearchResultsControllerInterface {
final class HeraldRuleListController extends HeraldController {
private $queryKey;
@ -23,57 +22,5 @@ final class HeraldRuleListController extends HeraldController
return $this->delegateToController($controller);
}
public function renderResultsList(
array $rules,
PhabricatorSavedQuery $query) {
assert_instances_of($rules, 'HeraldRule');
$viewer = $this->getRequest()->getUser();
$phids = mpull($rules, 'getAuthorPHID');
$this->loadHandles($phids);
$content_type_map = HeraldAdapter::getEnabledAdapterMap($viewer);
$list = id(new PHUIObjectItemListView())
->setUser($viewer)
->setCards(true);
foreach ($rules as $rule) {
$id = $rule->getID();
$item = id(new PHUIObjectItemView())
->setObjectName("H{$id}")
->setHeader($rule->getName())
->setHref($this->getApplicationURI("rule/{$id}/"));
if ($rule->isPersonalRule()) {
$item->addIcon('user', pht('Personal Rule'));
$item->addByline(
pht(
'Authored by %s',
$this->getHandle($rule->getAuthorPHID())->renderLink()));
} else {
$item->addIcon('world', pht('Global Rule'));
}
if ($rule->getIsDisabled()) {
$item->setDisabled(true);
$item->addIcon('disable-grey', pht('Disabled'));
}
$item->addAction(
id(new PHUIListItemView())
->setHref($this->getApplicationURI("history/{$id}/"))
->setIcon('transcript')
->setName(pht('Edit Log')));
$content_type_name = idx($content_type_map, $rule->getContentType());
$item->addAttribute(pht('Affects: %s', $content_type_name));
$list->addItem($item);
}
return $list;
}
}

View file

@ -3,6 +3,10 @@
final class HeraldRuleSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationHerald';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
@ -152,4 +156,61 @@ final class HeraldRuleSearchEngine
return array_fuse(array_keys(HeraldRuleTypeConfig::getRuleTypeMap()));
}
protected function getRequiredHandlePHIDsForResultList(
array $rules,
PhabricatorSavedQuery $query) {
return mpull($rules, 'getAuthorPHID');
}
protected function renderResultList(
array $rules,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($rules, 'HeraldRule');
$viewer = $this->requireViewer();
$content_type_map = HeraldAdapter::getEnabledAdapterMap($viewer);
$list = id(new PHUIObjectItemListView())
->setUser($viewer)
->setCards(true);
foreach ($rules as $rule) {
$id = $rule->getID();
$item = id(new PHUIObjectItemView())
->setObjectName("H{$id}")
->setHeader($rule->getName())
->setHref($this->getApplicationURI("rule/{$id}/"));
if ($rule->isPersonalRule()) {
$item->addIcon('user', pht('Personal Rule'));
$item->addByline(
pht(
'Authored by %s',
$handles[$rule->getAuthorPHID()]->renderLink()));
} else {
$item->addIcon('world', pht('Global Rule'));
}
if ($rule->getIsDisabled()) {
$item->setDisabled(true);
$item->addIcon('disable-grey', pht('Disabled'));
}
$item->addAction(
id(new PHUIListItemView())
->setHref($this->getApplicationURI("history/{$id}/"))
->setIcon('transcript')
->setName(pht('Edit Log')));
$content_type_name = idx($content_type_map, $rule->getContentType());
$item->addAttribute(pht('Affects: %s', $content_type_name));
$list->addItem($item);
}
return $list;
}
}

View file

@ -3,6 +3,10 @@
final class PhabricatorRepositorySearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorApplicationDiffusion';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
@ -215,4 +219,83 @@ final class PhabricatorRepositorySearchEngine
);
}
protected function getRequiredHandlePHIDsForResultList(
array $repositories,
PhabricatorSavedQuery $query) {
return array_mergev(mpull($repositories, 'getProjectPHIDs'));
}
protected function renderResultList(
array $repositories,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($repositories, 'PhabricatorRepository');
$viewer = $this->requireViewer();;
$list = new PHUIObjectItemListView();
$list->setCards(true);
foreach ($repositories as $repository) {
$id = $repository->getID();
$item = id(new PHUIObjectItemView())
->setUser($viewer)
->setHeader($repository->getName())
->setObjectName('r'.$repository->getCallsign())
->setHref($this->getApplicationURI($repository->getCallsign().'/'));
$commit = $repository->getMostRecentCommit();
if ($commit) {
$commit_link = DiffusionView::linkCommit(
$repository,
$commit->getCommitIdentifier(),
$commit->getSummary());
$item->setSubhead($commit_link);
$item->setEpoch($commit->getEpoch());
}
$item->addIcon(
'none',
PhabricatorRepositoryType::getNameForRepositoryType(
$repository->getVersionControlSystem()));
$size = $repository->getCommitCount();
if ($size) {
$history_uri = DiffusionRequest::generateDiffusionURI(
array(
'callsign' => $repository->getCallsign(),
'action' => 'history',
));
$item->addAttribute(
phutil_tag(
'a',
array(
'href' => $history_uri,
),
pht('%s Commit(s)', new PhutilNumber($size))));
} else {
$item->addAttribute(pht('No Commits'));
}
$project_handles = array_select_keys(
$handles,
$repository->getProjectPHIDs());
if ($project_handles) {
$item->addAttribute(
id(new ManiphestTaskProjectsView())
->setHandles($project_handles));
}
if (!$repository->isTracked()) {
$item->setDisabled(true);
$item->addIcon('disable-grey', pht('Inactive'));
}
$list->addItem($item);
}
return $list;
}
}

View file

@ -220,6 +220,8 @@ final class PhabricatorApplicationSearchController
if ($parent instanceof $interface) {
$list = $parent->renderResultsList($objects, $saved_query);
} else {
$engine->setRequest($request);
$list = $engine->renderResults(
$objects,
$saved_query);

View file

@ -21,6 +21,7 @@ abstract class PhabricatorApplicationSearchEngine {
private $viewer;
private $errors = array();
private $customFields = false;
private $request;
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
@ -593,6 +594,15 @@ abstract class PhabricatorApplicationSearchEngine {
/* -( Rendering )---------------------------------------------------------- */
public function setRequest(AphrontRequest $request) {
$this->request = $request;
return $this;
}
public function getRequest() {
return $this->request;
}
public function renderResults(
array $objects,
PhabricatorSavedQuery $query) {