Skip to content

Commit 0883ea6

Browse files
author
epriestley
committed
Move "unlisted" apps to Query, use Query for app preferences
Summary: - Demagic "unlisted" apps. - Respect policies in application visibility settings. Test Plan: Viewed applications, settings. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7212
1 parent 1edb875 commit 0883ea6

File tree

5 files changed

+36
-16
lines changed

5 files changed

+36
-16
lines changed

src/applications/base/PhabricatorApplication.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,22 @@ public function isBeta() {
8282
return false;
8383
}
8484

85+
/**
86+
* Return true if this application should not appear in application lists in
87+
* the UI. Primarily intended for unit test applications or other
88+
* pseudo-applications.
89+
*
90+
* @return bool True to remove application from UI lists.
91+
*/
8592
public function isUnlisted() {
8693
return false;
8794
}
8895

8996
/**
9097
* Returns true if an application is first-party (developed by Phacility)
9198
* and false otherwise.
99+
*
100+
* @return bool True if this application is developed by Phacility.
92101
*/
93102
final public function isFirstParty() {
94103
$where = id(new ReflectionClass($this))->getFileName();

src/applications/meta/controller/PhabricatorApplicationsListController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ public function renderResultsList(
3030
$applications = msort($applications, 'getName');
3131

3232
foreach ($applications as $application) {
33-
if ($application->isUnlisted()) {
34-
continue;
35-
}
36-
3733
$item = id(new PHUIObjectItemView())
3834
->setHeader($application->getName())
3935
->setHref('/applications/view/'.get_class($application).'/')

src/applications/meta/query/PhabricatorAppSearchEngine.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public function buildSavedQueryFromRequest(AphrontRequest $request) {
2121

2222
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
2323
$query = id(new PhabricatorApplicationQuery())
24-
->setOrder(PhabricatorApplicationQuery::ORDER_NAME);
24+
->setOrder(PhabricatorApplicationQuery::ORDER_NAME)
25+
->withUnlisted(false);
2526

2627
$name = $saved->getParameter('name');
2728
if (strlen($name)) {

src/applications/meta/query/PhabricatorApplicationQuery.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ final class PhabricatorApplicationQuery
77
private $beta;
88
private $firstParty;
99
private $nameContains;
10+
private $unlisted;
1011
private $classes;
1112
private $phids;
1213

@@ -35,6 +36,11 @@ public function withFirstParty($first_party) {
3536
return $this;
3637
}
3738

39+
public function withUnlisted($unlisted) {
40+
$this->unlisted = $unlisted;
41+
return $this;
42+
}
43+
3844
public function withClasses(array $classes) {
3945
$this->classes = $classes;
4046
return $this;
@@ -103,6 +109,14 @@ public function loadPage() {
103109
}
104110
}
105111

112+
if ($this->unlisted !== null) {
113+
foreach ($apps as $key => $app) {
114+
if ($app->isUnlisted() != $this->unlisted) {
115+
unset($apps[$key]);
116+
}
117+
}
118+
}
119+
106120
switch ($this->order) {
107121
case self::ORDER_NAME:
108122
$apps = msort($apps, 'getName');

src/applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ public function processRequest(AphrontRequest $request) {
2121

2222
require_celerity_resource('phabricator-settings-css');
2323

24-
$apps = PhabricatorApplication::getAllInstalledApplications();
24+
$apps = id(new PhabricatorApplicationQuery())
25+
->setViewer($user)
26+
->withUnlisted(false)
27+
->execute();
28+
2529
$pref_tiles = PhabricatorUserPreferences::PREFERENCE_APP_TILES;
2630
$tiles = $preferences->getPreference($pref_tiles, array());
2731

@@ -137,7 +141,7 @@ public function processRequest(AphrontRequest $request) {
137141
));
138142

139143
$app_column = hsprintf(
140-
"<strong>%s</strong><br /><em> Default: %s</em>"
144+
"<strong>%s</strong><br /><em>Default: %s</em>"
141145
, $app->getName(), $default_name);
142146

143147
$rows[] = array(
@@ -176,14 +180,12 @@ public function processRequest(AphrontRequest $request) {
176180

177181

178182
$panel = id(new AphrontPanelView())
179-
->setHeader($group_name)
180-
->addClass('phabricator-settings-panelview')
181-
->appendChild($table)
182-
->setNoBackground();
183-
183+
->setHeader($group_name)
184+
->addClass('phabricator-settings-panelview')
185+
->appendChild($table)
186+
->setNoBackground();
184187

185188
$output[] = $panel;
186-
187189
}
188190

189191
$form
@@ -205,9 +207,7 @@ public function processRequest(AphrontRequest $request) {
205207
->setFormError($error_view)
206208
->setForm($form);
207209

208-
return array(
209-
$form_box,
210-
);
210+
return $form_box;
211211
}
212212
}
213213

0 commit comments

Comments
 (0)