@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.

(Redesign) Clean up older "Tile" code

Summary:
This does some backend cleanup of the tile stuff, and some general cleanup of other application things:

- Users who haven't customized preferences get a small, specific set of pinned applications: Differential, Maniphest, Diffusion, Audit, Phriction, Projects (and, for administrators, Auth, Config and People).
- Old tile size methods are replaced with `isPinnnedByDefault()`.
- Shortened some short descriptions.
- `shouldAppearInLaunchView()` replaced by less ambiguous `isLaunchable()`.
- Added a marker for third-party / extension applications.

Test Plan: Faked away my preferences and viewed the home page, saw a smaller set of default pins.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

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

+128 -93
+4 -4
src/applications/audit/application/PhabricatorApplicationAudit.php
··· 14 14 return pht('Browse and Audit Commits'); 15 15 } 16 16 17 + public function isPinnedByDefault(PhabricatorUser $viewer) { 18 + return true; 19 + } 20 + 17 21 public function getHelpURI() { 18 22 return PhabricatorEnv::getDoclink('Audit User Guide'); 19 23 } ··· 32 36 'preview/(?P<id>[1-9]\d*)/' => 'PhabricatorAuditPreviewController', 33 37 ), 34 38 ); 35 - } 36 - 37 - public function getApplicationGroup() { 38 - return self::GROUP_CORE; 39 39 } 40 40 41 41 public function getApplicationOrder() {
+5 -1
src/applications/auth/application/PhabricatorApplicationAuth.php
··· 14 14 return 'authentication'; 15 15 } 16 16 17 + public function isPinnedByDefault(PhabricatorUser $viewer) { 18 + return $viewer->getIsAdmin(); 19 + } 20 + 17 21 public function getShortDescription() { 18 - return pht('Configure Login and Registration'); 22 + return pht('Login/Registration'); 19 23 } 20 24 21 25 public function getHelpURI() {
+46 -42
src/applications/base/PhabricatorApplication.php
··· 16 16 const GROUP_ADMIN = 'admin'; 17 17 const GROUP_DEVELOPER = 'developer'; 18 18 19 - const TILE_INVISIBLE = 'invisible'; 20 - const TILE_HIDE = 'hide'; 21 - const TILE_SHOW = 'show'; 22 - const TILE_FULL = 'full'; 23 - 24 19 public static function getApplicationGroups() { 25 20 return array( 26 21 self::GROUP_CORE => pht('Core Applications'), ··· 30 25 ); 31 26 } 32 27 33 - public static function getTileDisplayName($constant) { 34 - $names = array( 35 - self::TILE_INVISIBLE => pht('Invisible'), 36 - self::TILE_HIDE => pht('Hidden'), 37 - self::TILE_SHOW => pht('Show Small Tile'), 38 - self::TILE_FULL => pht('Show Large Tile'), 39 - ); 40 - return idx($names, $constant); 41 - } 42 28 43 - 29 + /* -( Application Information )-------------------------------------------- */ 44 30 45 - /* -( Application Information )-------------------------------------------- */ 46 31 47 32 public function getName() { 48 33 return substr(get_class($this), strlen('PhabricatorApplication')); ··· 68 53 return empty($uninstalled[get_class($this)]); 69 54 } 70 55 56 + 71 57 public function isBeta() { 72 58 return false; 73 59 } 74 60 61 + 75 62 /** 76 - * Return true if this application should not appear in application lists in 77 - * the UI. Primarily intended for unit test applications or other 63 + * Return `true` if this application should never appear in application lists 64 + * in the UI. Primarily intended for unit test applications or other 78 65 * pseudo-applications. 79 66 * 67 + * Few applications should be unlisted. For most applications, use 68 + * @{method:isLaunchable} to hide them from main launch views instead. 69 + * 80 70 * @return bool True to remove application from UI lists. 81 71 */ 82 72 public function isUnlisted() { 83 73 return false; 84 74 } 85 75 76 + 77 + /** 78 + * Return `true` if this application is a normal application with a base 79 + * URI and a web interface. 80 + * 81 + * Launchable applications can be pinned to the home page, and show up in the 82 + * "Launcher" view of the Applications application. Making an application 83 + * unlauncahble prevents pinning and hides it from this view. 84 + * 85 + * Usually, an application should be marked unlaunchable if: 86 + * 87 + * - it is available on every page anyway (like search); or 88 + * - it does not have a web interface (like subscriptions); or 89 + * - it is still pre-release and being intentionally buried. 90 + * 91 + * To hide applications more completely, use @{method:isUnlisted}. 92 + * 93 + * @return bool True if the application is launchable. 94 + */ 95 + public function isLaunchable() { 96 + return true; 97 + } 98 + 99 + 100 + /** 101 + * Return `true` if this application should be pinned by default. 102 + * 103 + * Users who have not yet set preferences see a default list of applications. 104 + * 105 + * @param PhabricatorUser User viewing the pinned application list. 106 + * @return bool True if this application should be pinned by default. 107 + */ 108 + public function isPinnedByDefault(PhabricatorUser $viewer) { 109 + return false; 110 + } 111 + 112 + 86 113 /** 87 114 * Returns true if an application is first-party (developed by Phacility) 88 115 * and false otherwise. ··· 113 140 } 114 141 115 142 public function getTypeaheadURI() { 116 - return $this->getBaseURI(); 143 + return $this->isLaunchable() ? $this->getBaseURI() : null; 117 144 } 118 145 119 146 public function getBaseURI() { ··· 132 159 return 'application'; 133 160 } 134 161 135 - public function shouldAppearInLaunchView() { 136 - return true; 137 - } 138 - 139 162 public function getApplicationOrder() { 140 163 return PHP_INT_MAX; 141 164 } ··· 158 181 159 182 public function getEventListeners() { 160 183 return array(); 161 - } 162 - 163 - public function getDefaultTileDisplay(PhabricatorUser $user) { 164 - switch ($this->getApplicationGroup()) { 165 - case self::GROUP_CORE: 166 - return self::TILE_FULL; 167 - case self::GROUP_UTILITIES: 168 - case self::GROUP_DEVELOPER: 169 - return self::TILE_HIDE; 170 - case self::GROUP_ADMIN: 171 - if ($user->getIsAdmin()) { 172 - return self::TILE_SHOW; 173 - } else { 174 - return self::TILE_INVISIBLE; 175 - } 176 - break; 177 - default: 178 - return self::TILE_SHOW; 179 - } 180 184 } 181 185 182 186 public function getRemarkupRules() {
+4 -4
src/applications/base/controller/__tests__/PhabricatorApplicationTest.php
··· 8 8 return true; 9 9 } 10 10 11 + public function isLaunchable() { 12 + return false; 13 + } 14 + 11 15 public function reset() { 12 16 $this->policies = array(); 13 17 } ··· 19 23 20 24 public function getPolicy($capability) { 21 25 return idx($this->policies, $capability, parent::getPolicy($capability)); 22 - } 23 - 24 - public function shouldAppearInLaunchView() { 25 - return false; 26 26 } 27 27 28 28 public function canUninstall() {
+1 -1
src/applications/conduit/application/PhabricatorApplicationConduit.php
··· 19 19 } 20 20 21 21 public function getShortDescription() { 22 - return pht('Phabricator Developer API Console'); 22 + return pht('Developer API'); 23 23 } 24 24 25 25 public function getTitleGlyph() {
+4
src/applications/config/application/PhabricatorApplicationConfig.php
··· 10 10 return 'setup'; 11 11 } 12 12 13 + public function isPinnedByDefault(PhabricatorUser $viewer) { 14 + return $viewer->getIsAdmin(); 15 + } 16 + 13 17 public function getTitleGlyph() { 14 18 return "\xE2\x98\xBA"; 15 19 }
+7 -1
src/applications/dashboard/application/PhabricatorApplicationDashboard.php
··· 48 48 ); 49 49 } 50 50 51 - public function shouldAppearInLaunchView() { 51 + public function isBeta() { 52 + return true; 53 + } 54 + 55 + public function isLaunchable() { 56 + // TODO: This is just concealing the application from launch views for 57 + // now since it's not really beta yet. 52 58 return false; 53 59 } 54 60
+4 -4
src/applications/differential/application/PhabricatorApplicationDifferential.php
··· 14 14 return 'differential'; 15 15 } 16 16 17 + public function isPinnedByDefault(PhabricatorUser $viewer) { 18 + return true; 19 + } 20 + 17 21 public function getHelpURI() { 18 22 return PhabricatorEnv::getDoclink('Differential User Guide'); 19 23 } ··· 72 76 'preview/' => 'PhabricatorMarkupPreviewController', 73 77 ), 74 78 ); 75 - } 76 - 77 - public function getApplicationGroup() { 78 - return self::GROUP_CORE; 79 79 } 80 80 81 81 public function getApplicationOrder() {
+4 -4
src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
··· 14 14 return 'diffusion'; 15 15 } 16 16 17 + public function isPinnedByDefault(PhabricatorUser $viewer) { 18 + return true; 19 + } 20 + 17 21 public function getHelpURI() { 18 22 return PhabricatorEnv::getDoclink('Diffusion User Guide'); 19 23 } ··· 114 118 'lint/' => 'DiffusionLintController', 115 119 ), 116 120 ); 117 - } 118 - 119 - public function getApplicationGroup() { 120 - return self::GROUP_CORE; 121 121 } 122 122 123 123 public function getApplicationOrder() {
+1 -1
src/applications/doorkeeper/application/PhabricatorApplicationDoorkeeper.php
··· 6 6 return false; 7 7 } 8 8 9 - public function shouldAppearInLaunchView() { 9 + public function isLaunchable() { 10 10 return false; 11 11 } 12 12
+1 -1
src/applications/flag/application/PhabricatorApplicationFlags.php
··· 3 3 final class PhabricatorApplicationFlags extends PhabricatorApplication { 4 4 5 5 public function getShortDescription() { 6 - return pht('Personal Bookmarks and Reminders'); 6 + return pht('Personal Bookmarks'); 7 7 } 8 8 9 9 public function getBaseURI() {
+1 -1
src/applications/harbormaster/application/PhabricatorApplicationHarbormaster.php
··· 7 7 } 8 8 9 9 public function getShortDescription() { 10 - return pht('Builds and Continuous Integration'); 10 + return pht('Build/CI'); 11 11 } 12 12 13 13 public function getIconName() {
+1 -1
src/applications/home/application/PhabricatorApplicationHome.php
··· 23 23 ); 24 24 } 25 25 26 - public function shouldAppearInLaunchView() { 26 + public function isLaunchable() { 27 27 return false; 28 28 } 29 29
-8
src/applications/home/controller/PhabricatorHomeController.php
··· 28 28 ->withLaunchable(true) 29 29 ->execute(); 30 30 31 - foreach ($applications as $key => $application) { 32 - $invisible = PhabricatorApplication::TILE_INVISIBLE; 33 - if ($application->getDefaultTileDisplay($user) == $invisible) { 34 - // Remove invisible applications (e.g., admin apps for non-admins). 35 - unset($applications[$key]); 36 - } 37 - } 38 - 39 31 $pinned = $user->loadPreferences()->getPinnedApplications( 40 32 $applications, 41 33 $user);
+2 -2
src/applications/maniphest/application/PhabricatorApplicationManiphest.php
··· 14 14 return 'maniphest'; 15 15 } 16 16 17 - public function getApplicationGroup() { 18 - return self::GROUP_CORE; 17 + public function isPinnedByDefault(PhabricatorUser $viewer) { 18 + return true; 19 19 } 20 20 21 21 public function getApplicationOrder() {
+6
src/applications/meta/application/PhabricatorApplicationApplications.php
··· 6 6 return false; 7 7 } 8 8 9 + public function isLaunchable() { 10 + // This application is launchable in the traditional sense, but showing it 11 + // on the application launch list is confusing. 12 + return false; 13 + } 14 + 9 15 public function getBaseURI() { 10 16 return '/applications/'; 11 17 }
+5 -1
src/applications/meta/query/PhabricatorAppSearchEngine.php
··· 226 226 } 227 227 228 228 if (!$application->isInstalled()) { 229 - $item->addIcon('delete', pht('Uninstalled')); 229 + $item->addIcon('fa-times', pht('Uninstalled')); 230 230 } 231 231 232 232 if ($application->isBeta()) { 233 233 $item->addIcon('fa-star-half-o grey', pht('Beta')); 234 + } 235 + 236 + if (!$application->isFirstParty()) { 237 + $item->addIcon('fa-puzzle-piece', pht('Extension')); 234 238 } 235 239 236 240 $list->addItem($item);
+1 -1
src/applications/meta/query/PhabricatorApplicationQuery.php
··· 125 125 126 126 if ($this->launchable !== null) { 127 127 foreach ($apps as $key => $app) { 128 - if ($app->shouldAppearInLaunchView() != $this->launchable) { 128 + if ($app->isLaunchable() != $this->launchable) { 129 129 unset($apps[$key]); 130 130 } 131 131 }
+1 -1
src/applications/metamta/application/PhabricatorApplicationMetaMTA.php
··· 22 22 return false; 23 23 } 24 24 25 - public function shouldAppearInLaunchView() { 25 + public function isLaunchable() { 26 26 return false; 27 27 } 28 28
+1 -1
src/applications/notification/application/PhabricatorApplicationNotifications.php
··· 24 24 ); 25 25 } 26 26 27 - public function shouldAppearInLaunchView() { 27 + public function isLaunchable() { 28 28 return false; 29 29 } 30 30
+1 -1
src/applications/nuance/application/PhabricatorApplicationNuance.php
··· 14 14 return true; 15 15 } 16 16 17 - public function shouldAppearInLaunchView() { 17 + public function isLaunchable() { 18 18 // try to hide this even more for now 19 19 return false; 20 20 }
+1 -1
src/applications/owners/application/PhabricatorApplicationOwners.php
··· 11 11 } 12 12 13 13 public function getShortDescription() { 14 - return pht('Track Ownership of Source Code'); 14 + return pht('Own Source Code'); 15 15 } 16 16 17 17 public function getTitleGlyph() {
+1 -1
src/applications/passphrase/application/PhabricatorApplicationPassphrase.php
··· 7 7 } 8 8 9 9 public function getShortDescription() { 10 - return pht('Store Passwords and Credentials'); 10 + return pht('Credential Store'); 11 11 } 12 12 13 13 public function getIconName() {
+4
src/applications/people/application/PhabricatorApplicationPeople.php
··· 18 18 return 'people'; 19 19 } 20 20 21 + public function isPinnedByDefault(PhabricatorUser $viewer) { 22 + return $viewer->getIsAdmin(); 23 + } 24 + 21 25 public function getFlavorText() { 22 26 return pht('Sort of a social utility.'); 23 27 }
+4
src/applications/phriction/application/PhabricatorApplicationPhriction.php
··· 14 14 return 'phriction'; 15 15 } 16 16 17 + public function isPinnedByDefault(PhabricatorUser $viewer) { 18 + return true; 19 + } 20 + 17 21 public function getHelpURI() { 18 22 return PhabricatorEnv::getDoclink('Phriction User Guide'); 19 23 }
+1 -1
src/applications/policy/application/PhabricatorApplicationPolicy.php
··· 2 2 3 3 final class PhabricatorApplicationPolicy extends PhabricatorApplication { 4 4 5 - public function shouldAppearInLaunchView() { 5 + public function isLaunchable() { 6 6 return false; 7 7 } 8 8
+5 -1
src/applications/project/application/PhabricatorApplicationProject.php
··· 7 7 } 8 8 9 9 public function getShortDescription() { 10 - return pht('Create Groups, Tags, and Projects'); 10 + return pht('Get Organized'); 11 + } 12 + 13 + public function isPinnedByDefault(PhabricatorUser $viewer) { 14 + return true; 11 15 } 12 16 13 17 public function getBaseURI() {
+1 -1
src/applications/search/application/PhabricatorApplicationSearch.php
··· 22 22 return 'search'; 23 23 } 24 24 25 - public function shouldAppearInLaunchView() { 25 + public function isLaunchable() { 26 26 return false; 27 27 } 28 28
+1 -1
src/applications/settings/application/PhabricatorApplicationSettings.php
··· 18 18 return false; 19 19 } 20 20 21 - public function shouldAppearInLaunchView() { 21 + public function isLaunchable() { 22 22 return false; 23 23 } 24 24
+6 -3
src/applications/settings/storage/PhabricatorUserPreferences.php
··· 66 66 67 67 $pref_tiles = PhabricatorUserPreferences::PREFERENCE_APP_TILES; 68 68 $tiles = $this->getPreference($pref_tiles, array()); 69 + $full_tile = 'full'; 69 70 70 71 $large = array(); 71 72 foreach ($apps as $app) { 72 - $tile = $app->getDefaultTileDisplay($viewer); 73 + $show = $app->isPinnedByDefault($viewer); 73 74 75 + // TODO: This is legacy stuff, clean it up eventually. This approximately 76 + // retains the old "tiles" preference. 74 77 if (isset($tiles[get_class($app)])) { 75 - $tile = $tiles[get_class($app)]; 78 + $show = ($tiles[get_class($app)] == $full_tile); 76 79 } 77 80 78 - if ($tile == PhabricatorApplication::TILE_FULL) { 81 + if ($show) { 79 82 $large[] = get_class($app); 80 83 } 81 84 }
+1 -1
src/applications/subscriptions/application/PhabricatorApplicationSubscriptions.php
··· 2 2 3 3 final class PhabricatorApplicationSubscriptions extends PhabricatorApplication { 4 4 5 - public function shouldAppearInLaunchView() { 5 + public function isLaunchable() { 6 6 return false; 7 7 } 8 8
+1 -1
src/applications/transactions/application/PhabricatorApplicationTransactions.php
··· 2 2 3 3 final class PhabricatorApplicationTransactions extends PhabricatorApplication { 4 4 5 - public function shouldAppearInLaunchView() { 5 + public function isLaunchable() { 6 6 return false; 7 7 } 8 8
+1 -1
src/applications/typeahead/application/PhabricatorApplicationTypeahead.php
··· 13 13 ); 14 14 } 15 15 16 - public function shouldAppearInLaunchView() { 16 + public function isLaunchable() { 17 17 return false; 18 18 } 19 19
+1 -1
src/applications/uiexample/application/PhabricatorApplicationUIExamples.php
··· 7 7 } 8 8 9 9 public function getShortDescription() { 10 - return pht('Phabricator Developer UI Examples'); 10 + return pht('Developer UI Examples'); 11 11 } 12 12 13 13 public function getIconName() {