From 78b89711cbddcbb56ba57824c21cce9a75656359 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 8 May 2014 10:08:37 -0700 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 84 ++++--------------- ...habricatorDashboardPanelListController.php | 25 +----- .../PhabricatorDashboardPanelSearchEngine.php | 26 ++++++ .../DifferentialRevisionListController.php | 63 +------------- .../DifferentialRevisionSearchEngine.php | 72 ++++++++++++++++ .../DiffusionPushLogListController.php | 3 +- .../DiffusionRepositoryListController.php | 80 +----------------- .../controller/DivinerAtomListController.php | 31 +------ .../diviner/query/DivinerAtomSearchEngine.php | 32 +++++++ .../DrydockBlueprintListController.php | 29 +------ .../query/DrydockBlueprintSearchEngine.php | 31 +++++++ .../PhabricatorApplicationFiles.php | 3 - .../PhabricatorFileListController.php | 64 +------------- .../query/PhabricatorFileSearchEngine.php | 75 ++++++++++++++++- .../PhabricatorFlagListController.php | 55 +----------- .../query/PhabricatorFlagSearchEngine.php | 58 +++++++++++++ .../HarbormasterBuildableListController.php | 56 +------------ .../HarbormasterPlanListController.php | 31 +------ .../HarbormasterBuildPlanSearchEngine.php | 32 +++++++ .../HarbormasterBuildableSearchEngine.php | 56 +++++++++++++ .../controller/HeraldRuleListController.php | 55 +----------- .../herald/query/HeraldRuleSearchEngine.php | 61 ++++++++++++++ .../PhabricatorRepositorySearchEngine.php | 83 ++++++++++++++++++ ...PhabricatorApplicationSearchController.php | 2 + .../PhabricatorApplicationSearchEngine.php | 10 +++ 25 files changed, 561 insertions(+), 556 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index f91a5cc4b6..3e1a46e635 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelListController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelListController.php index d2cd894495..9b5fc523b8 100644 --- a/src/applications/dashboard/controller/PhabricatorDashboardPanelListController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelListController.php @@ -1,10 +1,10 @@ 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; - } - } diff --git a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php index 3245dc165e..fc766fa2a1 100644 --- a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php +++ b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php @@ -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; + } + } diff --git a/src/applications/differential/controller/DifferentialRevisionListController.php b/src/applications/differential/controller/DifferentialRevisionListController.php index d3048325ab..b2ac03b7b2 100644 --- a/src/applications/differential/controller/DifferentialRevisionListController.php +++ b/src/applications/differential/controller/DifferentialRevisionListController.php @@ -1,7 +1,6 @@ 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; - } - } - } diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php index eb80f6caeb..27869d3dfd 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -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; + } + } + } diff --git a/src/applications/diffusion/controller/DiffusionPushLogListController.php b/src/applications/diffusion/controller/DiffusionPushLogListController.php index 6c8b9ef366..26822c64f5 100644 --- a/src/applications/diffusion/controller/DiffusionPushLogListController.php +++ b/src/applications/diffusion/controller/DiffusionPushLogListController.php @@ -1,7 +1,6 @@ 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(); diff --git a/src/applications/diviner/controller/DivinerAtomListController.php b/src/applications/diviner/controller/DivinerAtomListController.php index 1bddea8658..8681e41293 100644 --- a/src/applications/diviner/controller/DivinerAtomListController.php +++ b/src/applications/diviner/controller/DivinerAtomListController.php @@ -1,7 +1,6 @@ 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; - } - } diff --git a/src/applications/diviner/query/DivinerAtomSearchEngine.php b/src/applications/diviner/query/DivinerAtomSearchEngine.php index 6c8382be3b..2ae82ae06c 100644 --- a/src/applications/diviner/query/DivinerAtomSearchEngine.php +++ b/src/applications/diviner/query/DivinerAtomSearchEngine.php @@ -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; + } + } diff --git a/src/applications/drydock/controller/DrydockBlueprintListController.php b/src/applications/drydock/controller/DrydockBlueprintListController.php index c20d9a3715..f0a08e2363 100644 --- a/src/applications/drydock/controller/DrydockBlueprintListController.php +++ b/src/applications/drydock/controller/DrydockBlueprintListController.php @@ -1,7 +1,6 @@ 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); diff --git a/src/applications/drydock/query/DrydockBlueprintSearchEngine.php b/src/applications/drydock/query/DrydockBlueprintSearchEngine.php index c4eedc8863..962cf38efb 100644 --- a/src/applications/drydock/query/DrydockBlueprintSearchEngine.php +++ b/src/applications/drydock/query/DrydockBlueprintSearchEngine.php @@ -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; + } + } diff --git a/src/applications/files/application/PhabricatorApplicationFiles.php b/src/applications/files/application/PhabricatorApplicationFiles.php index 81a9557089..2ef01c7789 100644 --- a/src/applications/files/application/PhabricatorApplicationFiles.php +++ b/src/applications/files/application/PhabricatorApplicationFiles.php @@ -1,8 +1,5 @@ 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; - } - } diff --git a/src/applications/files/query/PhabricatorFileSearchEngine.php b/src/applications/files/query/PhabricatorFileSearchEngine.php index c16d816685..2b638c5493 100644 --- a/src/applications/files/query/PhabricatorFileSearchEngine.php +++ b/src/applications/files/query/PhabricatorFileSearchEngine.php @@ -1,11 +1,12 @@ 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; + } + } diff --git a/src/applications/flag/controller/PhabricatorFlagListController.php b/src/applications/flag/controller/PhabricatorFlagListController.php index 6a22022a29..f70d100a55 100644 --- a/src/applications/flag/controller/PhabricatorFlagListController.php +++ b/src/applications/flag/controller/PhabricatorFlagListController.php @@ -1,7 +1,6 @@ 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; - } - } diff --git a/src/applications/flag/query/PhabricatorFlagSearchEngine.php b/src/applications/flag/query/PhabricatorFlagSearchEngine.php index aa9304cf1b..8c1f6e3f64 100644 --- a/src/applications/flag/query/PhabricatorFlagSearchEngine.php +++ b/src/applications/flag/query/PhabricatorFlagSearchEngine.php @@ -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; + } + + } diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableListController.php b/src/applications/harbormaster/controller/HarbormasterBuildableListController.php index 55a1142359..2f83d30f0b 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildableListController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildableListController.php @@ -1,8 +1,6 @@ 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(); diff --git a/src/applications/harbormaster/controller/HarbormasterPlanListController.php b/src/applications/harbormaster/controller/HarbormasterPlanListController.php index 8559ce087e..0d94f0bb69 100644 --- a/src/applications/harbormaster/controller/HarbormasterPlanListController.php +++ b/src/applications/harbormaster/controller/HarbormasterPlanListController.php @@ -1,8 +1,6 @@ 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(); diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php index 76402cc5c5..7a086bc675 100644 --- a/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php +++ b/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php @@ -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; + } + } diff --git a/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php index bd9394e321..4bb38230c6 100644 --- a/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php +++ b/src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php @@ -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; + } } diff --git a/src/applications/herald/controller/HeraldRuleListController.php b/src/applications/herald/controller/HeraldRuleListController.php index 40f8080ada..7fe16c26bf 100644 --- a/src/applications/herald/controller/HeraldRuleListController.php +++ b/src/applications/herald/controller/HeraldRuleListController.php @@ -1,7 +1,6 @@ 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; - } } diff --git a/src/applications/herald/query/HeraldRuleSearchEngine.php b/src/applications/herald/query/HeraldRuleSearchEngine.php index 2e6f658bc3..1150c60c59 100644 --- a/src/applications/herald/query/HeraldRuleSearchEngine.php +++ b/src/applications/herald/query/HeraldRuleSearchEngine.php @@ -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; + } + } diff --git a/src/applications/repository/query/PhabricatorRepositorySearchEngine.php b/src/applications/repository/query/PhabricatorRepositorySearchEngine.php index 264bb15547..12f37071e8 100644 --- a/src/applications/repository/query/PhabricatorRepositorySearchEngine.php +++ b/src/applications/repository/query/PhabricatorRepositorySearchEngine.php @@ -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; + } + } diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php index 5a9563c417..9109b63812 100644 --- a/src/applications/search/controller/PhabricatorApplicationSearchController.php +++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php @@ -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); diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index 7b04d5b404..5fe1dd6587 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -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) {