Skip to content

Commit 6df1a02

Browse files
author
epriestley
committed
(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
1 parent 8827854 commit 6df1a02

File tree

34 files changed

+128
-93
lines changed

34 files changed

+128
-93
lines changed

src/applications/audit/application/PhabricatorApplicationAudit.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public function getShortDescription() {
1414
return pht('Browse and Audit Commits');
1515
}
1616

17+
public function isPinnedByDefault(PhabricatorUser $viewer) {
18+
return true;
19+
}
20+
1721
public function getHelpURI() {
1822
return PhabricatorEnv::getDoclink('Audit User Guide');
1923
}
@@ -34,10 +38,6 @@ public function getRoutes() {
3438
);
3539
}
3640

37-
public function getApplicationGroup() {
38-
return self::GROUP_CORE;
39-
}
40-
4141
public function getApplicationOrder() {
4242
return 0.130;
4343
}

src/applications/auth/application/PhabricatorApplicationAuth.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ public function getIconName() {
1414
return 'authentication';
1515
}
1616

17+
public function isPinnedByDefault(PhabricatorUser $viewer) {
18+
return $viewer->getIsAdmin();
19+
}
20+
1721
public function getShortDescription() {
18-
return pht('Configure Login and Registration');
22+
return pht('Login/Registration');
1923
}
2024

2125
public function getHelpURI() {

src/applications/base/PhabricatorApplication.php

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ abstract class PhabricatorApplication
1616
const GROUP_ADMIN = 'admin';
1717
const GROUP_DEVELOPER = 'developer';
1818

19-
const TILE_INVISIBLE = 'invisible';
20-
const TILE_HIDE = 'hide';
21-
const TILE_SHOW = 'show';
22-
const TILE_FULL = 'full';
23-
2419
public static function getApplicationGroups() {
2520
return array(
2621
self::GROUP_CORE => pht('Core Applications'),
@@ -30,20 +25,10 @@ public static function getApplicationGroups() {
3025
);
3126
}
3227

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-
43-
4428

4529
/* -( Application Information )-------------------------------------------- */
4630

31+
4732
public function getName() {
4833
return substr(get_class($this), strlen('PhabricatorApplication'));
4934
}
@@ -68,21 +53,63 @@ public function isInstalled() {
6853
return empty($uninstalled[get_class($this)]);
6954
}
7055

56+
7157
public function isBeta() {
7258
return false;
7359
}
7460

61+
7562
/**
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
7865
* pseudo-applications.
7966
*
67+
* Few applications should be unlisted. For most applications, use
68+
* @{method:isLaunchable} to hide them from main launch views instead.
69+
*
8070
* @return bool True to remove application from UI lists.
8171
*/
8272
public function isUnlisted() {
8373
return false;
8474
}
8575

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+
86113
/**
87114
* Returns true if an application is first-party (developed by Phacility)
88115
* and false otherwise.
@@ -113,7 +140,7 @@ public function getPHID() {
113140
}
114141

115142
public function getTypeaheadURI() {
116-
return $this->getBaseURI();
143+
return $this->isLaunchable() ? $this->getBaseURI() : null;
117144
}
118145

119146
public function getBaseURI() {
@@ -132,10 +159,6 @@ public function getIconName() {
132159
return 'application';
133160
}
134161

135-
public function shouldAppearInLaunchView() {
136-
return true;
137-
}
138-
139162
public function getApplicationOrder() {
140163
return PHP_INT_MAX;
141164
}
@@ -160,25 +183,6 @@ public function getEventListeners() {
160183
return array();
161184
}
162185

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-
}
181-
182186
public function getRemarkupRules() {
183187
return array();
184188
}

src/applications/base/controller/__tests__/PhabricatorApplicationTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ public function isUnlisted() {
88
return true;
99
}
1010

11+
public function isLaunchable() {
12+
return false;
13+
}
14+
1115
public function reset() {
1216
$this->policies = array();
1317
}
@@ -21,10 +25,6 @@ public function getPolicy($capability) {
2125
return idx($this->policies, $capability, parent::getPolicy($capability));
2226
}
2327

24-
public function shouldAppearInLaunchView() {
25-
return false;
26-
}
27-
2828
public function canUninstall() {
2929
return false;
3030
}

src/applications/conduit/application/PhabricatorApplicationConduit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function getHelpURI() {
1919
}
2020

2121
public function getShortDescription() {
22-
return pht('Phabricator Developer API Console');
22+
return pht('Developer API');
2323
}
2424

2525
public function getTitleGlyph() {

src/applications/config/application/PhabricatorApplicationConfig.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ public function getIconName() {
1010
return 'setup';
1111
}
1212

13+
public function isPinnedByDefault(PhabricatorUser $viewer) {
14+
return $viewer->getIsAdmin();
15+
}
16+
1317
public function getTitleGlyph() {
1418
return "\xE2\x98\xBA";
1519
}

src/applications/dashboard/application/PhabricatorApplicationDashboard.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ public function getRemarkupRules() {
4848
);
4949
}
5050

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.
5258
return false;
5359
}
5460

src/applications/differential/application/PhabricatorApplicationDifferential.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public function getIconName() {
1414
return 'differential';
1515
}
1616

17+
public function isPinnedByDefault(PhabricatorUser $viewer) {
18+
return true;
19+
}
20+
1721
public function getHelpURI() {
1822
return PhabricatorEnv::getDoclink('Differential User Guide');
1923
}
@@ -74,10 +78,6 @@ public function getRoutes() {
7478
);
7579
}
7680

77-
public function getApplicationGroup() {
78-
return self::GROUP_CORE;
79-
}
80-
8181
public function getApplicationOrder() {
8282
return 0.100;
8383
}

src/applications/diffusion/application/PhabricatorApplicationDiffusion.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public function getIconName() {
1414
return 'diffusion';
1515
}
1616

17+
public function isPinnedByDefault(PhabricatorUser $viewer) {
18+
return true;
19+
}
20+
1721
public function getHelpURI() {
1822
return PhabricatorEnv::getDoclink('Diffusion User Guide');
1923
}
@@ -116,10 +120,6 @@ public function getRoutes() {
116120
);
117121
}
118122

119-
public function getApplicationGroup() {
120-
return self::GROUP_CORE;
121-
}
122-
123123
public function getApplicationOrder() {
124124
return 0.120;
125125
}

src/applications/doorkeeper/application/PhabricatorApplicationDoorkeeper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public function canUninstall() {
66
return false;
77
}
88

9-
public function shouldAppearInLaunchView() {
9+
public function isLaunchable() {
1010
return false;
1111
}
1212

src/applications/flag/application/PhabricatorApplicationFlags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
final class PhabricatorApplicationFlags extends PhabricatorApplication {
44

55
public function getShortDescription() {
6-
return pht('Personal Bookmarks and Reminders');
6+
return pht('Personal Bookmarks');
77
}
88

99
public function getBaseURI() {

src/applications/harbormaster/application/PhabricatorApplicationHarbormaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public function getBaseURI() {
77
}
88

99
public function getShortDescription() {
10-
return pht('Builds and Continuous Integration');
10+
return pht('Build/CI');
1111
}
1212

1313
public function getIconName() {

src/applications/home/application/PhabricatorApplicationHome.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function getRoutes() {
2323
);
2424
}
2525

26-
public function shouldAppearInLaunchView() {
26+
public function isLaunchable() {
2727
return false;
2828
}
2929

src/applications/home/controller/PhabricatorHomeController.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ public function buildNav() {
2828
->withLaunchable(true)
2929
->execute();
3030

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-
3931
$pinned = $user->loadPreferences()->getPinnedApplications(
4032
$applications,
4133
$user);

src/applications/maniphest/application/PhabricatorApplicationManiphest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public function getIconName() {
1414
return 'maniphest';
1515
}
1616

17-
public function getApplicationGroup() {
18-
return self::GROUP_CORE;
17+
public function isPinnedByDefault(PhabricatorUser $viewer) {
18+
return true;
1919
}
2020

2121
public function getApplicationOrder() {

src/applications/meta/application/PhabricatorApplicationApplications.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ public function canUninstall() {
66
return false;
77
}
88

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+
915
public function getBaseURI() {
1016
return '/applications/';
1117
}

src/applications/meta/query/PhabricatorAppSearchEngine.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,17 @@ protected function renderResultList(
226226
}
227227

228228
if (!$application->isInstalled()) {
229-
$item->addIcon('delete', pht('Uninstalled'));
229+
$item->addIcon('fa-times', pht('Uninstalled'));
230230
}
231231

232232
if ($application->isBeta()) {
233233
$item->addIcon('fa-star-half-o grey', pht('Beta'));
234234
}
235235

236+
if (!$application->isFirstParty()) {
237+
$item->addIcon('fa-puzzle-piece', pht('Extension'));
238+
}
239+
236240
$list->addItem($item);
237241
}
238242

src/applications/meta/query/PhabricatorApplicationQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function loadPage() {
125125

126126
if ($this->launchable !== null) {
127127
foreach ($apps as $key => $app) {
128-
if ($app->shouldAppearInLaunchView() != $this->launchable) {
128+
if ($app->isLaunchable() != $this->launchable) {
129129
unset($apps[$key]);
130130
}
131131
}

src/applications/metamta/application/PhabricatorApplicationMetaMTA.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function canUninstall() {
2222
return false;
2323
}
2424

25-
public function shouldAppearInLaunchView() {
25+
public function isLaunchable() {
2626
return false;
2727
}
2828

0 commit comments

Comments
 (0)