Permalink
Browse files

Added basic hovercard controller

Summary:
Refs T1048; Depends on D5542, D5543, D5544 - It currently just renders multiple hovercards nicely for test purposes. More is on the way.

Mode `test`: Human test chamber.
Mode `retrieve`: For JS. Added so it would not clash with search key routing.

badassery

Test Plan:
`/search/hovercard/test/?phids[hover-T4]=PHID-TASK-g5pduvwrrwvkq5gkx736&phids[hover-T2]=PHID-TASK-gta6lzaaagziavkktima`

Verified the appearance of two tasks with correct rendering and correct ids

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1048

Differential Revision: https://secure.phabricator.com/D5545
  • Loading branch information...
1 parent c9cc59a commit d5841fe4991cf135e36575ccc518d5fbc780631f @AnhNhan AnhNhan committed with epriestley Apr 3, 2013
@@ -1300,6 +1300,7 @@
'PhabricatorSearchEngineMySQL' => 'applications/search/engine/PhabricatorSearchEngineMySQL.php',
'PhabricatorSearchEngineSelector' => 'applications/search/selector/PhabricatorSearchEngineSelector.php',
'PhabricatorSearchField' => 'applications/search/constants/PhabricatorSearchField.php',
+ 'PhabricatorSearchHovercardController' => 'applications/search/controller/PhabricatorSearchHovercardController.php',
'PhabricatorSearchIndexer' => 'applications/search/index/PhabricatorSearchIndexer.php',
'PhabricatorSearchManagementIndexWorkflow' => 'applications/search/management/PhabricatorSearchManagementIndexWorkflow.php',
'PhabricatorSearchManagementWorkflow' => 'applications/search/management/PhabricatorSearchManagementWorkflow.php',
@@ -2962,6 +2963,7 @@
'PhabricatorSearchDocumentRelationship' => 'PhabricatorSearchDAO',
'PhabricatorSearchEngineElastic' => 'PhabricatorSearchEngine',
'PhabricatorSearchEngineMySQL' => 'PhabricatorSearchEngine',
+ 'PhabricatorSearchHovercardController' => 'PhabricatorSearchBaseController',
'PhabricatorSearchManagementIndexWorkflow' => 'PhabricatorSearchManagementWorkflow',
'PhabricatorSearchManagementWorkflow' => 'PhutilArgumentWorkflow',
'PhabricatorSearchQuery' => 'PhabricatorSearchDAO',
@@ -81,6 +81,8 @@ public function getURIMap() {
'select/(?P<type>\w+)/'
=> 'PhabricatorSearchSelectController',
'index/(?P<phid>[^/]+)/' => 'PhabricatorSearchIndexController',
+ 'hovercard/(?P<mode>retrieve|test)/' =>
+ 'PhabricatorSearchHovercardController',
),
'/status/' => 'PhabricatorStatusController',
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * @group search
+ */
+final class PhabricatorSearchHovercardController
+ extends PhabricatorSearchBaseController {
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $user = $request->getUser();
+
+ $phids = $request->getArr('phids');
+
+ $handle_data = new PhabricatorObjectHandleData($phids);
+ $handle_data->setViewer($user);
+ $handles = $handle_data->loadHandles();
+ $objects = $handle_data->loadObjects();
+
+ $cards = array();
+
+ foreach ($phids as $phid) {
+ $handle = $handles[$phid];
+
+ $hovercard = new PhabricatorHovercardView();
+ $hovercard->setObjectHandle($handle);
+
+ // Send it to the other side of the world, thanks to PhutilEventEngine
+ $event = new PhabricatorEvent(
+ PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD,
+ array(
+ 'hovercard' => $hovercard,
+ 'handle' => $handle,
+ 'object' => idx($objects, $phid),
+ ));
+ $event->setUser($user);
+ PhutilEventEngine::dispatchEvent($event);
+
+ $cards[$phid] = $hovercard;
+ }
+
+ // Browser-friendly for non-Ajax requests
+ if (!$request->isAjax()) {
+ foreach ($cards as $key => $hovercard) {
+ $cards[$key] = phutil_tag('div',
+ array(
+ 'style' => 'margin: 20px;',
+ ),
+ $hovercard);
+ }
+
+ return $this->buildApplicationPage(
+ $cards,
+ array(
+ 'dust' => true,
+ ));
+ }
+
+ // TODO: Write a reasonable way to provide client-side-ready hovercard
+ // put-into-the-browser markup (coming in the next diff)
+ }
+
+}

0 comments on commit d5841fe

Please sign in to comment.