mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Expose subscribers in search and some polish
Summary: was poking at T654 and noticed subscribers weren't exposed in search UI so I did so. Also make ponder a little less silly on the double handles load. Finally, stopped showing the "Examine Index" link to non admins since they can't click it. Note this introduces a UI oddity in that you Users and Phriction Documents don't currently have the subscribe functionality. Test Plan: searched for subscribers in all applications - it worked! Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3907
This commit is contained in:
parent
fabf36a819
commit
730cf80a36
8 changed files with 51 additions and 144 deletions
|
@ -225,6 +225,10 @@ abstract class PhabricatorController extends AphrontController {
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function getLoadedHandles() {
|
||||
return $this->handles;
|
||||
}
|
||||
|
||||
protected function loadViewerHandles(array $phids) {
|
||||
return id(new PhabricatorObjectHandleData($phids))
|
||||
->setViewer($this->getRequest()->getUser())
|
||||
|
|
|
@ -41,8 +41,8 @@ final class PonderQuestionViewController extends PonderController {
|
|||
|
||||
$object_phids = array_merge($object_phids, $subscribers);
|
||||
|
||||
$handles = $this->loadViewerHandles($object_phids);
|
||||
$this->loadHandles($object_phids);
|
||||
$handles = $this->getLoadedHandles();
|
||||
|
||||
$detail_panel = new PonderQuestionDetailView();
|
||||
$detail_panel
|
||||
|
|
|
@ -48,6 +48,19 @@ final class PhabricatorSearchPonderIndexer
|
|||
}
|
||||
}
|
||||
|
||||
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
||||
$question->getPHID());
|
||||
$handles = id(new PhabricatorObjectHandleData($subscribers))
|
||||
->loadHandles();
|
||||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$doc->addRelationship(
|
||||
PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER,
|
||||
$phid,
|
||||
$handle->getType(),
|
||||
$question->getDateModified()); // Bogus timestamp.
|
||||
}
|
||||
|
||||
self::reindexAbstractDocument($doc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,11 @@ final class PhabricatorSearchController
|
|||
$query->setParameter('owner', $request->getArr('owner'));
|
||||
}
|
||||
|
||||
if ($request->getArr('subscribers')) {
|
||||
$query->setParameter('subscribers',
|
||||
$request->getArr('subscribers'));
|
||||
}
|
||||
|
||||
if ($request->getInt('open')) {
|
||||
$query->setParameter('open', $request->getInt('open'));
|
||||
}
|
||||
|
@ -109,6 +114,7 @@ final class PhabricatorSearchController
|
|||
$phids = array_merge(
|
||||
$query->getParameter('author', array()),
|
||||
$query->getParameter('owner', array()),
|
||||
$query->getParameter('subscribers', array()),
|
||||
$query->getParameter('project', array())
|
||||
);
|
||||
|
||||
|
@ -124,6 +130,11 @@ final class PhabricatorSearchController
|
|||
$query->getParameter('owner', array()));
|
||||
$owner_value = mpull($owner_value, 'getFullName', 'getPHID');
|
||||
|
||||
$subscribers_value = array_select_keys(
|
||||
$handles,
|
||||
$query->getParameter('subscribers', array()));
|
||||
$subscribers_value = mpull($subscribers_value, 'getFullName', 'getPHID');
|
||||
|
||||
$project_value = array_select_keys(
|
||||
$handles,
|
||||
$query->getParameter('project', array()));
|
||||
|
@ -172,6 +183,12 @@ final class PhabricatorSearchController
|
|||
->setValue($owner_value)
|
||||
->setCaption(
|
||||
'Tip: search for "Up For Grabs" to find unowned documents.'))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setName('subscribers')
|
||||
->setLabel('Subscribers')
|
||||
->setDatasource('/typeahead/common/users/')
|
||||
->setValue($subscribers_value))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setName('project')
|
||||
|
@ -213,15 +230,16 @@ final class PhabricatorSearchController
|
|||
|
||||
if ($results) {
|
||||
|
||||
$loader = new PhabricatorObjectHandleData($results);
|
||||
$loader = id(new PhabricatorObjectHandleData($results))
|
||||
->setViewer($user);
|
||||
$handles = $loader->loadHandles();
|
||||
$objects = $loader->loadObjects();
|
||||
$results = array();
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$view = new PhabricatorSearchResultView();
|
||||
$view->setHandle($handle);
|
||||
$view->setQuery($query);
|
||||
$view->setObject(idx($objects, $phid));
|
||||
$view = id(new PhabricatorSearchResultView())
|
||||
->setHandle($handle)
|
||||
->setQuery($query)
|
||||
->setObject(idx($objects, $phid));
|
||||
$results[] = $view->render();
|
||||
}
|
||||
$results =
|
||||
|
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group search
|
||||
*/
|
||||
final class PhabricatorSearchIndexController
|
||||
extends PhabricatorSearchBaseController {
|
||||
|
||||
private $phid;
|
||||
|
||||
public function shouldRequireAdmin() {
|
||||
// This basically shows you all the text of any object in the system, so
|
||||
// make it admin-only.
|
||||
return true;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->phid = $data['phid'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$engine = PhabricatorSearchEngineSelector::newSelector()->newEngine();
|
||||
$document = $engine->reconstructDocument($this->phid);
|
||||
if (!$document) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$panels = array();
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Abstract Document Index');
|
||||
|
||||
$props = array(
|
||||
'PHID' => phutil_escape_html($document->getPHID()),
|
||||
'Title' => phutil_escape_html($document->getDocumentTitle()),
|
||||
'Type' => phutil_escape_html($document->getDocumentType()),
|
||||
);
|
||||
$rows = array();
|
||||
foreach ($props as $name => $value) {
|
||||
$rows[] = array($name, $value);
|
||||
}
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
'header',
|
||||
'',
|
||||
));
|
||||
$panel->appendChild($table);
|
||||
$panels[] = $panel;
|
||||
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Document Fields');
|
||||
|
||||
$fields = $document->getFieldData();
|
||||
$rows = array();
|
||||
foreach ($fields as $field) {
|
||||
list($name, $corpus, $aux_phid) = $field;
|
||||
$rows[] = array(
|
||||
phutil_escape_html($name),
|
||||
phutil_escape_html(nonempty($aux_phid, null)),
|
||||
str_replace("\n", '<br />', phutil_escape_html($corpus)),
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'Field',
|
||||
'Aux PHID',
|
||||
'Corpus',
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'',
|
||||
'wide',
|
||||
));
|
||||
$panel->appendChild($table);
|
||||
$panels[] = $panel;
|
||||
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Document Relationships');
|
||||
|
||||
$relationships = $document->getRelationshipData();
|
||||
|
||||
$phids = ipull($relationships, 1);
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
$rows = array();
|
||||
foreach ($relationships as $relationship) {
|
||||
list($type, $phid, $rtype, $time) = $relationship;
|
||||
$rows[] = array(
|
||||
phutil_escape_html($type),
|
||||
phutil_escape_html($phid),
|
||||
phutil_escape_html($rtype),
|
||||
$handles[$phid]->renderLink(),
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'Relationship',
|
||||
'Related PHID',
|
||||
'Related Type',
|
||||
'Related Handle',
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'wide',
|
||||
));
|
||||
$panel->appendChild($table);
|
||||
$panels[] = $panel;
|
||||
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$panels,
|
||||
array(
|
||||
'title' => 'Raw Index',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -118,6 +118,7 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
|||
'author' => PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
|
||||
'open' => PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
|
||||
'owner' => PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
|
||||
'subscribers' => PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER,
|
||||
'project' => PhabricatorSearchRelationship::RELATIONSHIP_PROJECT,
|
||||
'repository' => PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
|
||||
);
|
||||
|
|
|
@ -224,6 +224,12 @@ final class PhabricatorSearchEngineMySQL extends PhabricatorSearchEngine {
|
|||
'owner',
|
||||
PhabricatorSearchRelationship::RELATIONSHIP_OWNER);
|
||||
|
||||
$join[] = $this->joinRelationship(
|
||||
$conn_r,
|
||||
$query,
|
||||
'subscribers',
|
||||
PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER);
|
||||
|
||||
$join[] = $this->joinRelationship(
|
||||
$conn_r,
|
||||
$query,
|
||||
|
|
|
@ -26,6 +26,9 @@ final class PhabricatorSearchResultView extends AphrontView {
|
|||
|
||||
public function render() {
|
||||
$handle = $this->handle;
|
||||
if (!$handle->isComplete()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$type_name = nonempty($handle->getTypeName(), 'Document');
|
||||
|
||||
|
@ -66,19 +69,10 @@ final class PhabricatorSearchResultView extends AphrontView {
|
|||
break;
|
||||
}
|
||||
|
||||
$index_link = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/search/index/'.$handle->getPHID().'/',
|
||||
'style' => 'float: right',
|
||||
),
|
||||
'Examine Index');
|
||||
|
||||
return
|
||||
'<div class="phabricator-search-result">'.
|
||||
$img.
|
||||
'<div class="result-desc">'.
|
||||
$index_link.
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
|
|
Loading…
Reference in a new issue