1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +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; return 0.130;
} }

View file

@ -26,6 +26,26 @@
*/ */
abstract class PhabricatorApplication { 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 )-------------------------------------------- */ /* -( Application Information )-------------------------------------------- */
@ -66,8 +86,12 @@ abstract class PhabricatorApplication {
return true; return true;
} }
public function getCoreApplicationOrder() { public function getApplicationOrder() {
return null; return PHP_INT_MAX;
}
public function getApplicationGroup() {
return self::GROUP_MISC;
} }
public function getTitleGlyph() { public function getTitleGlyph() {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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