Page MenuHomePhabricator

D9894.diff
No OneTemporary

D9894.diff

diff --git a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php
--- a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php
+++ b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php
@@ -25,8 +25,7 @@
->setName($repo->getMonogram().' '.$repo->getName())
->setURI('/diffusion/'.$repo->getCallsign().'/')
->setPHID($repo->getPHID())
- ->setPriorityString($repo->getMonogram())
- ->setIcon('fa-database bluegrey');
+ ->setPriorityString($repo->getMonogram());
}
return $results;
diff --git a/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php b/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
--- a/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
+++ b/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
@@ -23,7 +23,6 @@
foreach ($documents as $document) {
$results[] = id(new PhabricatorTypeaheadResult())
->setPHID($document->getPHID())
- ->setIcon('fa-file-text-o')
->setName($document->getMonogram().' '.$document->getTitle());
}
diff --git a/src/applications/macro/typeahead/PhabricatorMacroDatasource.php b/src/applications/macro/typeahead/PhabricatorMacroDatasource.php
--- a/src/applications/macro/typeahead/PhabricatorMacroDatasource.php
+++ b/src/applications/macro/typeahead/PhabricatorMacroDatasource.php
@@ -25,8 +25,7 @@
foreach ($macros as $macro) {
$results[] = id(new PhabricatorTypeaheadResult())
->setPHID($macro->getPHID())
- ->setName($macro->getName())
- ->setIcon('fa-meh-o bluegrey');
+ ->setName($macro->getName());
}
return $results;
diff --git a/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php b/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php
--- a/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php
+++ b/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php
@@ -12,6 +12,10 @@
return pht('Mailing List');
}
+ public function getTypeIcon() {
+ return 'fa-envelope-o';
+ }
+
public function newObject() {
return new PhabricatorMetaMTAMailingList();
}
diff --git a/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php b/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php
--- a/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php
+++ b/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php
@@ -12,6 +12,10 @@
return pht('Owners Package');
}
+ public function getTypeIcon() {
+ return 'fa-list-alt';
+ }
+
public function newObject() {
return new PhabricatorOwnersPackage();
}
diff --git a/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
--- a/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
+++ b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
@@ -23,7 +23,6 @@
foreach ($packages as $package) {
$results[] = id(new PhabricatorTypeaheadResult())
- ->setIcon('fa-list-alt bluegrey')
->setName($package->getName())
->setURI('/owners/package/'.$package->getID().'/')
->setPHID($package->getPHID());
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
@@ -104,7 +104,6 @@
->setURI('/p/'.$user->getUsername())
->setPHID($user->getPHID())
->setPriorityString($user->getUsername())
- ->setIcon('fa-user bluegrey')
->setPriorityType('user')
->setClosed($closed);
diff --git a/src/applications/project/typeahead/PhabricatorProjectDatasource.php b/src/applications/project/typeahead/PhabricatorProjectDatasource.php
--- a/src/applications/project/typeahead/PhabricatorProjectDatasource.php
+++ b/src/applications/project/typeahead/PhabricatorProjectDatasource.php
@@ -32,7 +32,7 @@
->setDisplayType('Project')
->setURI('/tag/'.$proj->getPrimarySlug().'/')
->setPHID($proj->getPHID())
- ->setIcon($proj->getIcon())
+ ->setIcon($proj->getIcon().' bluegrey')
->setPriorityType('proj')
->setClosed($closed);
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
@@ -79,7 +79,7 @@
$this->displayType,
$this->imageURI ? (string)$this->imageURI : null,
$this->priorityType,
- $this->icon,
+ ($this->icon === null) ? $this->getDefaultIcon() : $this->icon,
$this->closed,
$this->imageSprite ? (string)$this->imageSprite : null,
);
@@ -89,4 +89,32 @@
return $data;
}
+ /**
+ * If the datasource did not specify an icon explicitly, try to select a
+ * default based on PHID type.
+ */
+ private function getDefaultIcon() {
+ static $icon_map;
+ if ($icon_map === null) {
+ $types = PhabricatorPHIDType::getAllTypes();
+
+ $map = array();
+ foreach ($types as $type) {
+ $icon = $type->getTypeIcon();
+ if ($icon !== null) {
+ $map[$type->getTypeConstant()] = "{$icon} bluegrey";
+ }
+ }
+
+ $icon_map = $map;
+ }
+
+ $phid_type = phid_get_type($this->phid);
+ if (isset($icon_map[$phid_type])) {
+ return $icon_map[$phid_type];
+ }
+
+ return null;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sun, May 12, 5:38 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6285035
Default Alt Text
D9894.diff (5 KB)

Event Timeline