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

Group applications into groups on /applications/

Summary: So they're maybe a little easier to deal with? I'm going to take this formally to "plz @chad plz help" land.

Test Plan: {F20329}

Reviewers: btrahan, vrana, chad

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3609
This commit is contained in:
epriestley 2012-10-03 15:46:19 -07:00
parent fe6022cd97
commit 78784aa1fe
31 changed files with 187 additions and 27 deletions

View file

@ -42,7 +42,11 @@ final class PhabricatorApplicationAudit extends PhabricatorApplication {
);
}
public function getCoreApplicationOrder() {
public function getApplicationGroup() {
return self::GROUP_CORE;
}
public function getApplicationOrder() {
return 0.130;
}

View file

@ -26,6 +26,26 @@
*/
abstract class PhabricatorApplication {
const GROUP_CORE = 'core';
const GROUP_COMMUNICATION = 'communication';
const GROUP_ORGANIZATION = 'organization';
const GROUP_UTILITIES = 'util';
const GROUP_ADMIN = 'admin';
const GROUP_DEVELOPER = 'developer';
const GROUP_MISC = 'misc';
public static function getApplicationGroups() {
return array(
self::GROUP_CORE => pht('Core Applications'),
self::GROUP_COMMUNICATION => pht('Communication'),
self::GROUP_ORGANIZATION => pht('Organization'),
self::GROUP_UTILITIES => pht('Utilities'),
self::GROUP_ADMIN => pht('Administration'),
self::GROUP_DEVELOPER => pht('Developer Tools'),
self::GROUP_MISC => pht('Miscellaneous Applications'),
);
}
/* -( Application Information )-------------------------------------------- */
@ -66,8 +86,12 @@ abstract class PhabricatorApplication {
return true;
}
public function getCoreApplicationOrder() {
return null;
public function getApplicationOrder() {
return PHP_INT_MAX;
}
public function getApplicationGroup() {
return self::GROUP_MISC;
}
public function getTitleGlyph() {

View file

@ -39,6 +39,14 @@ final class PhabricatorApplicationConduit extends PhabricatorApplication {
return "\xE2\x87\xB5";
}
public function getApplicationGroup() {
return self::GROUP_DEVELOPER;
}
public function getApplicationOrder() {
return 0.100;
}
public function getRoutes() {
return array(
'/conduit/' => array(

View file

@ -38,6 +38,10 @@ final class PhabricatorApplicationCountdown extends PhabricatorApplication {
return pht('Utilize the full capabilities of your ALU.');
}
public function getApplicationGroup() {
return self::GROUP_UTILITIES;
}
public function getRoutes() {
return array(
'/countdown/' => array(

View file

@ -38,6 +38,10 @@ final class PhabricatorApplicationDaemons extends PhabricatorApplication {
return 'daemons';
}
public function getApplicationGroup() {
return self::GROUP_ADMIN;
}
public function getRoutes() {
return array(
'/daemon/' => array(

View file

@ -66,7 +66,11 @@ final class PhabricatorApplicationDifferential extends PhabricatorApplication {
);
}
public function getCoreApplicationOrder() {
public function getApplicationGroup() {
return self::GROUP_CORE;
}
public function getApplicationOrder() {
return 0.100;
}

View file

@ -82,7 +82,11 @@ final class PhabricatorApplicationDiffusion extends PhabricatorApplication {
);
}
public function getCoreApplicationOrder() {
public function getApplicationGroup() {
return self::GROUP_CORE;
}
public function getApplicationOrder() {
return 0.120;
}

View file

@ -40,6 +40,10 @@ final class PhabricatorApplicationDiviner extends PhabricatorApplication {
);
}
public function getApplicationGroup() {
return self::GROUP_COMMUNICATION;
}
public function buildMainMenuItems(
PhabricatorUser $user,
PhabricatorController $controller = null) {

View file

@ -30,6 +30,10 @@ final class PhabricatorApplicationFact extends PhabricatorApplication {
return 'fact';
}
public function getApplicationGroup() {
return self::GROUP_UTILITIES;
}
public function getRoutes() {
return array(
'/fact/' => array(

View file

@ -38,6 +38,10 @@ final class PhabricatorApplicationFiles extends PhabricatorApplication {
return pht('Blob store for Pokemon pictures.');
}
public function getApplicationGroup() {
return self::GROUP_UTILITIES;
}
public function getRoutes() {
return array(
'/F(?P<id>\d+)' => 'PhabricatorFileShortcutController',

View file

@ -36,6 +36,10 @@ final class PhabricatorApplicationFlags extends PhabricatorApplication {
);
}
public function getApplicationGroup() {
return self::GROUP_ORGANIZATION;
}
public function loadStatus(PhabricatorUser $user) {
$status = array();

View file

@ -42,6 +42,10 @@ final class PhabricatorApplicationHerald extends PhabricatorApplication {
return pht('Watch for danger!');
}
public function getApplicationGroup() {
return self::GROUP_ORGANIZATION;
}
public function getRoutes() {
return array(
'/herald/' => array(

View file

@ -34,6 +34,10 @@ final class PhabricatorApplicationMacro extends PhabricatorApplication {
return "\xE2\x9A\x98";
}
public function getApplicationGroup() {
return self::GROUP_UTILITIES;
}
public function getRoutes() {
return array(
'/macro/' => array(

View file

@ -34,6 +34,10 @@ final class PhabricatorApplicationMailingLists extends PhabricatorApplication {
return 'mail';
}
public function getApplicationGroup() {
return self::GROUP_ADMIN;
}
public function getRoutes() {
return array(
'/mailinglists/' => array(

View file

@ -34,7 +34,11 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
return 'maniphest';
}
public function getCoreApplicationOrder() {
public function getApplicationGroup() {
return self::GROUP_CORE;
}
public function getApplicationOrder() {
return 0.110;
}

View file

@ -24,7 +24,6 @@ final class PhabricatorApplicationsListController
$user = $request->getUser();
$applications = PhabricatorApplication::getAllInstalledApplications();
$applications = msort($applications, 'getName');
foreach ($applications as $key => $application) {
if (!$application->shouldAppearInLaunchView()) {
@ -32,25 +31,37 @@ final class PhabricatorApplicationsListController
}
}
$status = array();
foreach ($applications as $key => $application) {
$status[$key] = $application->loadStatus($user);
}
$groups = PhabricatorApplication::getApplicationGroups();
$views = array();
foreach ($applications as $key => $application) {
$views[] = id(new PhabricatorApplicationLaunchView())
->setApplication($application)
->setApplicationStatus(idx($status, $key, array()))
->setUser($user);
}
$applications = msort($applications, 'getApplicationOrder');
$applications = mgroup($applications, 'getApplicationGroup');
$applications = array_select_keys($applications, array_keys($groups));
$view = phutil_render_tag(
'div',
array(
'class' => 'phabricator-application-list',
),
id(new AphrontNullView())->appendChild($views)->render());
$view = array();
foreach ($applications as $group => $application_list) {
$status = array();
foreach ($application_list as $key => $application) {
$status[$key] = $application->loadStatus($user);
}
$views = array();
foreach ($application_list as $key => $application) {
$views[] = id(new PhabricatorApplicationLaunchView())
->setApplication($application)
->setApplicationStatus(idx($status, $key, array()))
->setUser($user);
}
$view[] = id(new PhabricatorHeaderView())
->setHeader($groups[$group]);
$view[] = phutil_render_tag(
'div',
array(
'class' => 'phabricator-application-list',
),
id(new AphrontNullView())->appendChild($views)->render());
}
return $this->buildApplicationPage(
$view,

View file

@ -34,6 +34,10 @@ final class PhabricatorApplicationMetaMTA extends PhabricatorApplication {
return pht('Yo dawg, we heard you like MTAs.');
}
public function getApplicationGroup() {
return self::GROUP_ADMIN;
}
public function getRoutes() {
return array(
$this->getBaseURI() => array(

View file

@ -42,6 +42,10 @@ final class PhabricatorApplicationOwners extends PhabricatorApplication {
return pht('Adopt today!');
}
public function getApplicationGroup() {
return self::GROUP_ORGANIZATION;
}
public function getRoutes() {
return array(
'/owners/' => array(

View file

@ -30,6 +30,10 @@ final class PhabricatorApplicationPaste extends PhabricatorApplication {
return "\xE2\x9C\x8E";
}
public function getApplicationGroup() {
return self::GROUP_UTILITIES;
}
public function getRoutes() {
return array(
'/P(?P<id>\d+)' => 'PhabricatorPasteViewController',

View file

@ -38,6 +38,10 @@ final class PhabricatorApplicationPeople extends PhabricatorApplication {
return pht('Sort of a social utility.');
}
public function getApplicationGroup() {
return self::GROUP_ADMIN;
}
public function getRoutes() {
return array(
'/people/' => array(

View file

@ -38,6 +38,10 @@ final class PhabricatorApplicationPhame extends PhabricatorApplication {
return PhabricatorEnv::getDoclink('article/Phame_User_Guide.html');
}
public function getApplicationGroup() {
return self::GROUP_COMMUNICATION;
}
public function getRoutes() {
return array(
'/phame/' => array(

View file

@ -38,6 +38,10 @@ final class PhabricatorApplicationPHID extends PhabricatorApplication {
return "#";
}
public function getApplicationGroup() {
return self::GROUP_DEVELOPER;
}
public function getRoutes() {
return array(
'/phid/' => array(

View file

@ -57,7 +57,11 @@ final class PhabricatorApplicationPhriction extends PhabricatorApplication {
);
}
public function getCoreApplicationOrder() {
public function getApplicationGroup() {
return self::GROUP_COMMUNICATION;
}
public function getApplicationOrder() {
return 0.140;
}

View file

@ -43,6 +43,10 @@ final class PhabricatorApplicationPonder extends PhabricatorApplication {
return $status;
}
public function getApplicationGroup() {
return self::GROUP_COMMUNICATION;
}
public function getroutes() {
return array(
'/Q(?P<id>\d+)' => 'PonderQuestionViewController',

View file

@ -38,6 +38,10 @@ final class PhabricatorApplicationProject extends PhabricatorApplication {
return pht('Group stuff into big piles.');
}
public function getApplicationGroup() {
return self::GROUP_ORGANIZATION;
}
public function getRoutes() {
return array(
'/project/' => array(

View file

@ -34,6 +34,10 @@ final class PhabricatorApplicationRepositories extends PhabricatorApplication {
return "rX";
}
public function getApplicationGroup() {
return self::GROUP_ADMIN;
}
public function getRoutes() {
return array(
'/repository/' => array(

View file

@ -39,6 +39,10 @@ final class PhabricatorApplicationSettings extends PhabricatorApplication {
);
}
public function getApplicationGroup() {
return self::GROUP_UTILITIES;
}
public function buildMainMenuItems(
PhabricatorUser $user,
PhabricatorController $controller = null) {

View file

@ -42,6 +42,10 @@ final class PhabricatorApplicationSlowvote extends PhabricatorApplication {
return pht('Design by committee.');
}
public function getApplicationGroup() {
return self::GROUP_UTILITIES;
}
public function getRoutes() {
return array(
'/V(?P<id>\d+)' => 'PhabricatorSlowvotePollController',

View file

@ -38,6 +38,14 @@ final class PhabricatorApplicationUIExamples extends PhabricatorApplication {
return pht('A gallery of modern art.');
}
public function getApplicationGroup() {
return self::GROUP_DEVELOPER;
}
public function getApplicationOrder() {
return 0.110;
}
public function getRoutes() {
return array(
'/uiexample/' => array(

View file

@ -34,6 +34,10 @@ final class PhabricatorApplicationPHPAST extends PhabricatorApplication {
return "\xE2\x96\xA0";
}
public function getApplicationGroup() {
return self::GROUP_DEVELOPER;
}
public function getRoutes() {
return array(
'/xhpast/' => array(

View file

@ -193,18 +193,23 @@ final class AphrontSideNavView extends AphrontView {
$meta = null;
$group_core = PhabricatorApplication::GROUP_CORE;
$applications = PhabricatorApplication::getAllInstalledApplications();
foreach ($applications as $application) {
if ($application instanceof PhabricatorApplicationApplications) {
$meta = $application;
continue;
}
if ($application->getCoreApplicationOrder() !== null) {
if ($application->getApplicationGroup() != $group_core) {
continue;
}
if ($application->getApplicationOrder() !== null) {
$core[] = $application;
}
}
$core = msort($core, 'getCoreApplicationOrder');
$core = msort($core, 'getApplicationOrder');
if ($meta) {
$core[] = $meta;
}