1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

(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
This commit is contained in:
epriestley 2014-06-03 15:47:27 -07:00
parent 8827854ff8
commit 6df1a02413
34 changed files with 128 additions and 93 deletions

View file

@ -14,6 +14,10 @@ final class PhabricatorApplicationAudit extends PhabricatorApplication {
return pht('Browse and Audit Commits');
}
public function isPinnedByDefault(PhabricatorUser $viewer) {
return true;
}
public function getHelpURI() {
return PhabricatorEnv::getDoclink('Audit User Guide');
}
@ -34,10 +38,6 @@ final class PhabricatorApplicationAudit extends PhabricatorApplication {
);
}
public function getApplicationGroup() {
return self::GROUP_CORE;
}
public function getApplicationOrder() {
return 0.130;
}

View file

@ -14,8 +14,12 @@ final class PhabricatorApplicationAuth extends PhabricatorApplication {
return 'authentication';
}
public function isPinnedByDefault(PhabricatorUser $viewer) {
return $viewer->getIsAdmin();
}
public function getShortDescription() {
return pht('Configure Login and Registration');
return pht('Login/Registration');
}
public function getHelpURI() {

View file

@ -16,11 +16,6 @@ abstract class PhabricatorApplication
const GROUP_ADMIN = 'admin';
const GROUP_DEVELOPER = 'developer';
const TILE_INVISIBLE = 'invisible';
const TILE_HIDE = 'hide';
const TILE_SHOW = 'show';
const TILE_FULL = 'full';
public static function getApplicationGroups() {
return array(
self::GROUP_CORE => pht('Core Applications'),
@ -30,20 +25,10 @@ abstract class PhabricatorApplication
);
}
public static function getTileDisplayName($constant) {
$names = array(
self::TILE_INVISIBLE => pht('Invisible'),
self::TILE_HIDE => pht('Hidden'),
self::TILE_SHOW => pht('Show Small Tile'),
self::TILE_FULL => pht('Show Large Tile'),
);
return idx($names, $constant);
}
/* -( Application Information )-------------------------------------------- */
public function getName() {
return substr(get_class($this), strlen('PhabricatorApplication'));
}
@ -68,21 +53,63 @@ abstract class PhabricatorApplication
return empty($uninstalled[get_class($this)]);
}
public function isBeta() {
return false;
}
/**
* Return true if this application should not appear in application lists in
* the UI. Primarily intended for unit test applications or other
* Return `true` if this application should never appear in application lists
* in the UI. Primarily intended for unit test applications or other
* pseudo-applications.
*
* Few applications should be unlisted. For most applications, use
* @{method:isLaunchable} to hide them from main launch views instead.
*
* @return bool True to remove application from UI lists.
*/
public function isUnlisted() {
return false;
}
/**
* Return `true` if this application is a normal application with a base
* URI and a web interface.
*
* Launchable applications can be pinned to the home page, and show up in the
* "Launcher" view of the Applications application. Making an application
* unlauncahble prevents pinning and hides it from this view.
*
* Usually, an application should be marked unlaunchable if:
*
* - it is available on every page anyway (like search); or
* - it does not have a web interface (like subscriptions); or
* - it is still pre-release and being intentionally buried.
*
* To hide applications more completely, use @{method:isUnlisted}.
*
* @return bool True if the application is launchable.
*/
public function isLaunchable() {
return true;
}
/**
* Return `true` if this application should be pinned by default.
*
* Users who have not yet set preferences see a default list of applications.
*
* @param PhabricatorUser User viewing the pinned application list.
* @return bool True if this application should be pinned by default.
*/
public function isPinnedByDefault(PhabricatorUser $viewer) {
return false;
}
/**
* Returns true if an application is first-party (developed by Phacility)
* and false otherwise.
@ -113,7 +140,7 @@ abstract class PhabricatorApplication
}
public function getTypeaheadURI() {
return $this->getBaseURI();
return $this->isLaunchable() ? $this->getBaseURI() : null;
}
public function getBaseURI() {
@ -132,10 +159,6 @@ abstract class PhabricatorApplication
return 'application';
}
public function shouldAppearInLaunchView() {
return true;
}
public function getApplicationOrder() {
return PHP_INT_MAX;
}
@ -160,25 +183,6 @@ abstract class PhabricatorApplication
return array();
}
public function getDefaultTileDisplay(PhabricatorUser $user) {
switch ($this->getApplicationGroup()) {
case self::GROUP_CORE:
return self::TILE_FULL;
case self::GROUP_UTILITIES:
case self::GROUP_DEVELOPER:
return self::TILE_HIDE;
case self::GROUP_ADMIN:
if ($user->getIsAdmin()) {
return self::TILE_SHOW;
} else {
return self::TILE_INVISIBLE;
}
break;
default:
return self::TILE_SHOW;
}
}
public function getRemarkupRules() {
return array();
}

View file

@ -8,6 +8,10 @@ final class PhabricatorApplicationTest extends PhabricatorApplication {
return true;
}
public function isLaunchable() {
return false;
}
public function reset() {
$this->policies = array();
}
@ -21,10 +25,6 @@ final class PhabricatorApplicationTest extends PhabricatorApplication {
return idx($this->policies, $capability, parent::getPolicy($capability));
}
public function shouldAppearInLaunchView() {
return false;
}
public function canUninstall() {
return false;
}

View file

@ -19,7 +19,7 @@ final class PhabricatorApplicationConduit extends PhabricatorApplication {
}
public function getShortDescription() {
return pht('Phabricator Developer API Console');
return pht('Developer API');
}
public function getTitleGlyph() {

View file

@ -10,6 +10,10 @@ final class PhabricatorApplicationConfig extends PhabricatorApplication {
return 'setup';
}
public function isPinnedByDefault(PhabricatorUser $viewer) {
return $viewer->getIsAdmin();
}
public function getTitleGlyph() {
return "\xE2\x98\xBA";
}

View file

@ -48,7 +48,13 @@ final class PhabricatorApplicationDashboard extends PhabricatorApplication {
);
}
public function shouldAppearInLaunchView() {
public function isBeta() {
return true;
}
public function isLaunchable() {
// TODO: This is just concealing the application from launch views for
// now since it's not really beta yet.
return false;
}

View file

@ -14,6 +14,10 @@ final class PhabricatorApplicationDifferential extends PhabricatorApplication {
return 'differential';
}
public function isPinnedByDefault(PhabricatorUser $viewer) {
return true;
}
public function getHelpURI() {
return PhabricatorEnv::getDoclink('Differential User Guide');
}
@ -74,10 +78,6 @@ EOTEXT
);
}
public function getApplicationGroup() {
return self::GROUP_CORE;
}
public function getApplicationOrder() {
return 0.100;
}

View file

@ -14,6 +14,10 @@ final class PhabricatorApplicationDiffusion extends PhabricatorApplication {
return 'diffusion';
}
public function isPinnedByDefault(PhabricatorUser $viewer) {
return true;
}
public function getHelpURI() {
return PhabricatorEnv::getDoclink('Diffusion User Guide');
}
@ -116,10 +120,6 @@ final class PhabricatorApplicationDiffusion extends PhabricatorApplication {
);
}
public function getApplicationGroup() {
return self::GROUP_CORE;
}
public function getApplicationOrder() {
return 0.120;
}

View file

@ -6,7 +6,7 @@ final class PhabricatorApplicationDoorkeeper extends PhabricatorApplication {
return false;
}
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -3,7 +3,7 @@
final class PhabricatorApplicationFlags extends PhabricatorApplication {
public function getShortDescription() {
return pht('Personal Bookmarks and Reminders');
return pht('Personal Bookmarks');
}
public function getBaseURI() {

View file

@ -7,7 +7,7 @@ final class PhabricatorApplicationHarbormaster extends PhabricatorApplication {
}
public function getShortDescription() {
return pht('Builds and Continuous Integration');
return pht('Build/CI');
}
public function getIconName() {

View file

@ -23,7 +23,7 @@ final class PhabricatorApplicationHome extends PhabricatorApplication {
);
}
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -28,14 +28,6 @@ abstract class PhabricatorHomeController extends PhabricatorController {
->withLaunchable(true)
->execute();
foreach ($applications as $key => $application) {
$invisible = PhabricatorApplication::TILE_INVISIBLE;
if ($application->getDefaultTileDisplay($user) == $invisible) {
// Remove invisible applications (e.g., admin apps for non-admins).
unset($applications[$key]);
}
}
$pinned = $user->loadPreferences()->getPinnedApplications(
$applications,
$user);

View file

@ -14,8 +14,8 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
return 'maniphest';
}
public function getApplicationGroup() {
return self::GROUP_CORE;
public function isPinnedByDefault(PhabricatorUser $viewer) {
return true;
}
public function getApplicationOrder() {

View file

@ -6,6 +6,12 @@ final class PhabricatorApplicationApplications extends PhabricatorApplication {
return false;
}
public function isLaunchable() {
// This application is launchable in the traditional sense, but showing it
// on the application launch list is confusing.
return false;
}
public function getBaseURI() {
return '/applications/';
}

View file

@ -226,13 +226,17 @@ final class PhabricatorAppSearchEngine
}
if (!$application->isInstalled()) {
$item->addIcon('delete', pht('Uninstalled'));
$item->addIcon('fa-times', pht('Uninstalled'));
}
if ($application->isBeta()) {
$item->addIcon('fa-star-half-o grey', pht('Beta'));
}
if (!$application->isFirstParty()) {
$item->addIcon('fa-puzzle-piece', pht('Extension'));
}
$list->addItem($item);
}

View file

@ -125,7 +125,7 @@ final class PhabricatorApplicationQuery
if ($this->launchable !== null) {
foreach ($apps as $key => $app) {
if ($app->shouldAppearInLaunchView() != $this->launchable) {
if ($app->isLaunchable() != $this->launchable) {
unset($apps[$key]);
}
}

View file

@ -22,7 +22,7 @@ final class PhabricatorApplicationMetaMTA extends PhabricatorApplication {
return false;
}
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -24,7 +24,7 @@ final class PhabricatorApplicationNotifications extends PhabricatorApplication {
);
}
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -14,7 +14,7 @@ final class PhabricatorApplicationNuance extends PhabricatorApplication {
return true;
}
public function shouldAppearInLaunchView() {
public function isLaunchable() {
// try to hide this even more for now
return false;
}

View file

@ -11,7 +11,7 @@ final class PhabricatorApplicationOwners extends PhabricatorApplication {
}
public function getShortDescription() {
return pht('Track Ownership of Source Code');
return pht('Own Source Code');
}
public function getTitleGlyph() {

View file

@ -7,7 +7,7 @@ final class PhabricatorApplicationPassphrase extends PhabricatorApplication {
}
public function getShortDescription() {
return pht('Store Passwords and Credentials');
return pht('Credential Store');
}
public function getIconName() {

View file

@ -18,6 +18,10 @@ final class PhabricatorApplicationPeople extends PhabricatorApplication {
return 'people';
}
public function isPinnedByDefault(PhabricatorUser $viewer) {
return $viewer->getIsAdmin();
}
public function getFlavorText() {
return pht('Sort of a social utility.');
}

View file

@ -14,6 +14,10 @@ final class PhabricatorApplicationPhriction extends PhabricatorApplication {
return 'phriction';
}
public function isPinnedByDefault(PhabricatorUser $viewer) {
return true;
}
public function getHelpURI() {
return PhabricatorEnv::getDoclink('Phriction User Guide');
}

View file

@ -2,7 +2,7 @@
final class PhabricatorApplicationPolicy extends PhabricatorApplication {
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -7,7 +7,11 @@ final class PhabricatorApplicationProject extends PhabricatorApplication {
}
public function getShortDescription() {
return pht('Create Groups, Tags, and Projects');
return pht('Get Organized');
}
public function isPinnedByDefault(PhabricatorUser $viewer) {
return true;
}
public function getBaseURI() {

View file

@ -22,7 +22,7 @@ final class PhabricatorApplicationSearch extends PhabricatorApplication {
return 'search';
}
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -18,7 +18,7 @@ final class PhabricatorApplicationSettings extends PhabricatorApplication {
return false;
}
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -66,16 +66,19 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO {
$pref_tiles = PhabricatorUserPreferences::PREFERENCE_APP_TILES;
$tiles = $this->getPreference($pref_tiles, array());
$full_tile = 'full';
$large = array();
foreach ($apps as $app) {
$tile = $app->getDefaultTileDisplay($viewer);
$show = $app->isPinnedByDefault($viewer);
// TODO: This is legacy stuff, clean it up eventually. This approximately
// retains the old "tiles" preference.
if (isset($tiles[get_class($app)])) {
$tile = $tiles[get_class($app)];
$show = ($tiles[get_class($app)] == $full_tile);
}
if ($tile == PhabricatorApplication::TILE_FULL) {
if ($show) {
$large[] = get_class($app);
}
}

View file

@ -2,7 +2,7 @@
final class PhabricatorApplicationSubscriptions extends PhabricatorApplication {
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -2,7 +2,7 @@
final class PhabricatorApplicationTransactions extends PhabricatorApplication {
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -13,7 +13,7 @@ final class PhabricatorApplicationTypeahead extends PhabricatorApplication {
);
}
public function shouldAppearInLaunchView() {
public function isLaunchable() {
return false;
}

View file

@ -7,7 +7,7 @@ final class PhabricatorApplicationUIExamples extends PhabricatorApplication {
}
public function getShortDescription() {
return pht('Phabricator Developer UI Examples');
return pht('Developer UI Examples');
}
public function getIconName() {