@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make typeahead datasources default to PHID type icons

Summary:
Ref T4420. If a datasource does not specify an icon explicitly, check if the PHID type has a default, and use that.

This leaves us with only Projects and some special stuff setting explicit icons, and reduces code duplication.

Test Plan: Used typeahead to find all affected object types.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4420

Differential Revision: https://secure.phabricator.com/D9894

+40 -9
+1 -2
src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php
··· 25 25 ->setName($repo->getMonogram().' '.$repo->getName()) 26 26 ->setURI('/diffusion/'.$repo->getCallsign().'/') 27 27 ->setPHID($repo->getPHID()) 28 - ->setPriorityString($repo->getMonogram()) 29 - ->setIcon('fa-database bluegrey'); 28 + ->setPriorityString($repo->getMonogram()); 30 29 } 31 30 32 31 return $results;
-1
src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
··· 23 23 foreach ($documents as $document) { 24 24 $results[] = id(new PhabricatorTypeaheadResult()) 25 25 ->setPHID($document->getPHID()) 26 - ->setIcon('fa-file-text-o') 27 26 ->setName($document->getMonogram().' '.$document->getTitle()); 28 27 } 29 28
+1 -2
src/applications/macro/typeahead/PhabricatorMacroDatasource.php
··· 25 25 foreach ($macros as $macro) { 26 26 $results[] = id(new PhabricatorTypeaheadResult()) 27 27 ->setPHID($macro->getPHID()) 28 - ->setName($macro->getName()) 29 - ->setIcon('fa-meh-o bluegrey'); 28 + ->setName($macro->getName()); 30 29 } 31 30 32 31 return $results;
+4
src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php
··· 12 12 return pht('Mailing List'); 13 13 } 14 14 15 + public function getTypeIcon() { 16 + return 'fa-envelope-o'; 17 + } 18 + 15 19 public function newObject() { 16 20 return new PhabricatorMetaMTAMailingList(); 17 21 }
+4
src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php
··· 12 12 return pht('Owners Package'); 13 13 } 14 14 15 + public function getTypeIcon() { 16 + return 'fa-list-alt'; 17 + } 18 + 15 19 public function newObject() { 16 20 return new PhabricatorOwnersPackage(); 17 21 }
-1
src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
··· 23 23 24 24 foreach ($packages as $package) { 25 25 $results[] = id(new PhabricatorTypeaheadResult()) 26 - ->setIcon('fa-list-alt bluegrey') 27 26 ->setName($package->getName()) 28 27 ->setURI('/owners/package/'.$package->getID().'/') 29 28 ->setPHID($package->getPHID());
-1
src/applications/people/typeahead/PhabricatorPeopleDatasource.php
··· 104 104 ->setURI('/p/'.$user->getUsername()) 105 105 ->setPHID($user->getPHID()) 106 106 ->setPriorityString($user->getUsername()) 107 - ->setIcon('fa-user bluegrey') 108 107 ->setPriorityType('user') 109 108 ->setClosed($closed); 110 109
+1 -1
src/applications/project/typeahead/PhabricatorProjectDatasource.php
··· 32 32 ->setDisplayType('Project') 33 33 ->setURI('/tag/'.$proj->getPrimarySlug().'/') 34 34 ->setPHID($proj->getPHID()) 35 - ->setIcon($proj->getIcon()) 35 + ->setIcon($proj->getIcon().' bluegrey') 36 36 ->setPriorityType('proj') 37 37 ->setClosed($closed); 38 38
+29 -1
src/applications/typeahead/storage/PhabricatorTypeaheadResult.php
··· 79 79 $this->displayType, 80 80 $this->imageURI ? (string)$this->imageURI : null, 81 81 $this->priorityType, 82 - $this->icon, 82 + ($this->icon === null) ? $this->getDefaultIcon() : $this->icon, 83 83 $this->closed, 84 84 $this->imageSprite ? (string)$this->imageSprite : null, 85 85 ); ··· 87 87 array_pop($data); 88 88 } 89 89 return $data; 90 + } 91 + 92 + /** 93 + * If the datasource did not specify an icon explicitly, try to select a 94 + * default based on PHID type. 95 + */ 96 + private function getDefaultIcon() { 97 + static $icon_map; 98 + if ($icon_map === null) { 99 + $types = PhabricatorPHIDType::getAllTypes(); 100 + 101 + $map = array(); 102 + foreach ($types as $type) { 103 + $icon = $type->getTypeIcon(); 104 + if ($icon !== null) { 105 + $map[$type->getTypeConstant()] = "{$icon} bluegrey"; 106 + } 107 + } 108 + 109 + $icon_map = $map; 110 + } 111 + 112 + $phid_type = phid_get_type($this->phid); 113 + if (isset($icon_map[$phid_type])) { 114 + return $icon_map[$phid_type]; 115 + } 116 + 117 + return null; 90 118 } 91 119 92 120 }