Page MenuHomePhabricator

D16155.id38863.diff
No OneTemporary

D16155.id38863.diff

diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -28,7 +28,7 @@
'rsrc/css/aphront/table-view.css' => '9258e19f',
'rsrc/css/aphront/tokenizer.css' => '056da01b',
'rsrc/css/aphront/tooltip.css' => '1a07aea8',
- 'rsrc/css/aphront/typeahead-browse.css' => 'd8581d2c',
+ 'rsrc/css/aphront/typeahead-browse.css' => 'b1186d5f',
'rsrc/css/aphront/typeahead.css' => 'd4f16145',
'rsrc/css/application/almanac/almanac.css' => 'dbb9b3af',
'rsrc/css/application/auth/auth.css' => '0877ed6e',
@@ -889,7 +889,7 @@
'syntax-default-css' => '9923583c',
'syntax-highlighting-css' => '9fc496d5',
'tokens-css' => '3d0f239e',
- 'typeahead-browse-css' => 'd8581d2c',
+ 'typeahead-browse-css' => 'b1186d5f',
'unhandled-exception-css' => '4c96257a',
),
'requires' => array(
diff --git a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php
--- a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php
+++ b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php
@@ -3,18 +3,6 @@
final class PhabricatorPeopleDatasource
extends PhabricatorTypeaheadDatasource {
- private $enrichResults;
-
- /**
- * Controls enriched rendering, for global search. This is a bit hacky and
- * should probably be handled in a more general way, but is fairly reasonable
- * for now.
- */
- public function setEnrichResults($enrich) {
- $this->enrichResults = $enrich;
- return $this;
- }
-
public function getBrowseTitle() {
return pht('Browse Users');
}
@@ -40,7 +28,9 @@
$users = $this->executeQuery($query);
- if ($this->enrichResults && $users) {
+ $is_browse = $this->getIsBrowse();
+
+ if ($is_browse && $users) {
$phids = mpull($users, 'getPHID');
$handles = id(new PhabricatorHandleQuery())
->setViewer($viewer)
@@ -74,7 +64,7 @@
$result->setIcon('fa-envelope-o');
}
- if ($this->enrichResults) {
+ if ($is_browse) {
$display_type = pht('User');
if ($user->getIsAdmin()) {
$display_type = pht('Administrator');
diff --git a/src/applications/search/typeahead/PhabricatorSearchDatasource.php b/src/applications/search/typeahead/PhabricatorSearchDatasource.php
--- a/src/applications/search/typeahead/PhabricatorSearchDatasource.php
+++ b/src/applications/search/typeahead/PhabricatorSearchDatasource.php
@@ -16,14 +16,22 @@
}
public function getComponentDatasources() {
- return array(
- id(new PhabricatorPeopleDatasource())->setEnrichResults(true),
+ $sources = array(
+ new PhabricatorPeopleDatasource(),
new PhabricatorProjectDatasource(),
new PhabricatorApplicationDatasource(),
new PhabricatorTypeaheadMonogramDatasource(),
new DiffusionRepositoryDatasource(),
new DiffusionSymbolDatasource(),
);
+
+ // These results are always rendered in the full browse display mode, so
+ // set the browse flag on all component sources.
+ foreach ($sources as $source) {
+ $source->setIsBrowse(true);
+ }
+
+ return $sources;
}
}
diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php
--- a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php
+++ b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php
@@ -65,7 +65,8 @@
}
$composite
- ->setOffset($offset);
+ ->setOffset($offset)
+ ->setIsBrowse(true);
}
$results = $composite->loadResults();
@@ -142,8 +143,7 @@
$items = array();
foreach ($results as $result) {
- $token = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
- $result);
+ $information = $this->renderBrowseResult($result);
// Disable already-selected tokens.
$disabled = isset($exclude[$result->getPHID()]);
@@ -167,8 +167,8 @@
'class' => 'typeahead-browse-item grouped',
),
array(
- $token,
$button,
+ $information,
));
}
@@ -350,4 +350,46 @@
->appendChild($view);
}
+ private function renderBrowseResult(PhabricatorTypeaheadResult $result) {
+ $name = phutil_tag(
+ 'div',
+ array(
+ 'class' => 'result-name',
+ ),
+ $result->getDisplayName());
+
+ $icon = $result->getIcon();
+ $icon = id(new PHUIIconView())->setIcon($icon);
+
+ $attributes = array();
+ $display_type = $result->getDisplayType();
+ if (strlen($display_type)) {
+ $attributes[] = $display_type;
+ }
+
+ if ($attributes) {
+ $attributes = array($icon, ' ', $attributes);
+ } else {
+ $attributes = $icon;
+ }
+
+ $attributes = phutil_tag(
+ 'div',
+ array(
+ 'class' => 'result-type',
+ ),
+ $attributes);
+
+ return phutil_tag(
+ 'div',
+ array(
+ 'class' => 'phabricator-main-search-typeahead-result',
+ 'style' => 'background-image: url('.$result->getImageURI().')',
+ ),
+ array(
+ $name,
+ $attributes,
+ ));
+ }
+
}
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
+++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
@@ -37,6 +37,7 @@
}
$stack = $this->getFunctionStack();
+ $is_browse = $this->getIsBrowse();
$results = array();
foreach ($this->getUsableDatasources() as $source) {
@@ -70,6 +71,10 @@
$source->setLimit($offset + $limit);
}
+ if ($is_browse) {
+ $source->setIsBrowse(true);
+ }
+
$source_results = $source->loadResults();
$source_results = $source->didLoadResults($source_results);
$results[] = $source_results;
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
+++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
@@ -12,6 +12,7 @@
private $limit;
private $parameters = array();
private $functionStack = array();
+ private $isBrowse;
public function setLimit($limit) {
$this->limit = $limit;
@@ -71,6 +72,15 @@
return idx($this->parameters, $name, $default);
}
+ public function setIsBrowse($is_browse) {
+ $this->isBrowse = $is_browse;
+ return $this;
+ }
+
+ public function getIsBrowse() {
+ return $this->isBrowse;
+ }
+
public function getDatasourceURI() {
$uri = new PhutilURI('/typeahead/class/'.get_class($this).'/');
$uri->setQueryParams($this->parameters);
diff --git a/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php b/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php
--- a/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php
+++ b/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php
@@ -188,4 +188,12 @@
return null;
}
+ public function getImageURI() {
+ return $this->imageURI;
+ }
+
+ public function getDisplayType() {
+ return $this->displayType;
+ }
+
}
diff --git a/webroot/rsrc/css/aphront/typeahead-browse.css b/webroot/rsrc/css/aphront/typeahead-browse.css
--- a/webroot/rsrc/css/aphront/typeahead-browse.css
+++ b/webroot/rsrc/css/aphront/typeahead-browse.css
@@ -57,10 +57,15 @@
.typeahead-browse-item button {
float: right;
- margin: 2px 6px;
+ margin: 8px 6px 0;
}
.typeahead-browse-item a.jx-tokenizer-token {
margin-top: 1px;
margin-left: 6px;
}
+
+.typeahead-browse-item .phabricator-main-search-typeahead-result {
+ margin: 2px 0;
+ padding: 0 0 0 48px;
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 8, 8:50 AM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7381476
Default Alt Text
D16155.id38863.diff (8 KB)

Event Timeline