1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 04:50:55 +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 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() { public function isUnlisted() {
return false; return false;
} }
@ -89,6 +96,8 @@ abstract class PhabricatorApplication
/** /**
* Returns true if an application is first-party (developed by Phacility) * Returns true if an application is first-party (developed by Phacility)
* and false otherwise. * and false otherwise.
*
* @return bool True if this application is developed by Phacility.
*/ */
final public function isFirstParty() { final public function isFirstParty() {
$where = id(new ReflectionClass($this))->getFileName(); $where = id(new ReflectionClass($this))->getFileName();

View file

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

View file

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

View file

@ -7,6 +7,7 @@ final class PhabricatorApplicationQuery
private $beta; private $beta;
private $firstParty; private $firstParty;
private $nameContains; private $nameContains;
private $unlisted;
private $classes; private $classes;
private $phids; private $phids;
@ -35,6 +36,11 @@ final class PhabricatorApplicationQuery
return $this; return $this;
} }
public function withUnlisted($unlisted) {
$this->unlisted = $unlisted;
return $this;
}
public function withClasses(array $classes) { public function withClasses(array $classes) {
$this->classes = $classes; $this->classes = $classes;
return $this; 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) { switch ($this->order) {
case self::ORDER_NAME: case self::ORDER_NAME:
$apps = msort($apps, 'getName'); $apps = msort($apps, 'getName');

View file

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