1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 20:40:56 +01:00

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
This commit is contained in:
epriestley 2013-10-04 06:46:47 -07:00
parent 1edb875978
commit 0883ea6977
5 changed files with 36 additions and 16 deletions

View file

@ -82,6 +82,13 @@ abstract class PhabricatorApplication
return false;
}
/**
* Return true if this application should not appear in application lists in
* the UI. Primarily intended for unit test applications or other
* pseudo-applications.
*
* @return bool True to remove application from UI lists.
*/
public function isUnlisted() {
return false;
}
@ -89,6 +96,8 @@ abstract class PhabricatorApplication
/**
* Returns true if an application is first-party (developed by Phacility)
* and false otherwise.
*
* @return bool True if this application is developed by Phacility.
*/
final public function isFirstParty() {
$where = id(new ReflectionClass($this))->getFileName();

View file

@ -30,10 +30,6 @@ final class PhabricatorApplicationsListController
$applications = msort($applications, 'getName');
foreach ($applications as $application) {
if ($application->isUnlisted()) {
continue;
}
$item = id(new PHUIObjectItemView())
->setHeader($application->getName())
->setHref('/applications/view/'.get_class($application).'/')

View file

@ -21,7 +21,8 @@ final class PhabricatorAppSearchEngine
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new PhabricatorApplicationQuery())
->setOrder(PhabricatorApplicationQuery::ORDER_NAME);
->setOrder(PhabricatorApplicationQuery::ORDER_NAME)
->withUnlisted(false);
$name = $saved->getParameter('name');
if (strlen($name)) {

View file

@ -7,6 +7,7 @@ final class PhabricatorApplicationQuery
private $beta;
private $firstParty;
private $nameContains;
private $unlisted;
private $classes;
private $phids;
@ -35,6 +36,11 @@ final class PhabricatorApplicationQuery
return $this;
}
public function withUnlisted($unlisted) {
$this->unlisted = $unlisted;
return $this;
}
public function withClasses(array $classes) {
$this->classes = $classes;
return $this;
@ -103,6 +109,14 @@ final class PhabricatorApplicationQuery
}
}
if ($this->unlisted !== null) {
foreach ($apps as $key => $app) {
if ($app->isUnlisted() != $this->unlisted) {
unset($apps[$key]);
}
}
}
switch ($this->order) {
case self::ORDER_NAME:
$apps = msort($apps, 'getName');

View file

@ -21,7 +21,11 @@ final class PhabricatorSettingsPanelHomePreferences
require_celerity_resource('phabricator-settings-css');
$apps = PhabricatorApplication::getAllInstalledApplications();
$apps = id(new PhabricatorApplicationQuery())
->setViewer($user)
->withUnlisted(false)
->execute();
$pref_tiles = PhabricatorUserPreferences::PREFERENCE_APP_TILES;
$tiles = $preferences->getPreference($pref_tiles, array());
@ -137,7 +141,7 @@ final class PhabricatorSettingsPanelHomePreferences
));
$app_column = hsprintf(
"<strong>%s</strong><br /><em> Default: %s</em>"
"<strong>%s</strong><br /><em>Default: %s</em>"
, $app->getName(), $default_name);
$rows[] = array(
@ -176,14 +180,12 @@ final class PhabricatorSettingsPanelHomePreferences
$panel = id(new AphrontPanelView())
->setHeader($group_name)
->addClass('phabricator-settings-panelview')
->appendChild($table)
->setNoBackground();
->setHeader($group_name)
->addClass('phabricator-settings-panelview')
->appendChild($table)
->setNoBackground();
$output[] = $panel;
}
$form
@ -205,9 +207,7 @@ final class PhabricatorSettingsPanelHomePreferences
->setFormError($error_view)
->setForm($form);
return array(
$form_box,
);
return $form_box;
}
}