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

Add a way to get to the home dashboard on mobile

Summary: Fixes T5320. Adds a "Home" application at the top, for mobile-only.

Test Plan: See screenshots.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5320

Differential Revision: https://secure.phabricator.com/D9509
This commit is contained in:
epriestley 2014-06-12 19:16:53 -07:00
parent 0e1042db85
commit d0c09ef867
5 changed files with 56 additions and 36 deletions

View file

@ -3,11 +3,11 @@
final class PhabricatorApplicationHome extends PhabricatorApplication {
public function getBaseURI() {
return '/';
return '/home/';
}
public function getShortDescription() {
return pht('Where the <3 is');
return pht('Command Center');
}
public function getIconName() {
@ -16,7 +16,8 @@ final class PhabricatorApplicationHome extends PhabricatorApplication {
public function getRoutes() {
return array(
'/(?:(?P<filter>(?:jump))/)?' => 'PhabricatorHomeMainController',
'/' => 'PhabricatorHomeMainController',
'/(?P<only>home)/' => 'PhabricatorHomeMainController',
'/home/' => array(
'create/' => 'PhabricatorHomeQuickCreateController',
),

View file

@ -40,6 +40,15 @@ abstract class PhabricatorHomeController extends PhabricatorController {
$applications[$meta_app] = PhabricatorApplication::getByClass($meta_app);
$tiles = array();
$home_app = new PhabricatorApplicationHome();
$tiles[] = id(new PhabricatorApplicationLaunchView())
->setApplication($home_app)
->setApplicationStatus($home_app->loadStatus($user))
->addClass('phabricator-application-launch-phone-only')
->setUser($user);
foreach ($pinned as $pinned_application) {
if (empty($applications[$pinned_application])) {
continue;

View file

@ -3,7 +3,7 @@
final class PhabricatorHomeMainController
extends PhabricatorHomeController {
private $filter;
private $only;
private $minipanels = array();
public function shouldAllowPublic() {
@ -11,44 +11,49 @@ final class PhabricatorHomeMainController
}
public function willProcessRequest(array $data) {
$this->filter = idx($data, 'filter');
$this->only = idx($data, 'only');
}
public function processRequest() {
$user = $this->getRequest()->getUser();
$nav = $this->buildNav();
$dashboard = PhabricatorDashboardInstall::getDashboard(
$user,
$user->getPHID(),
get_class($this->getCurrentApplication()));
if ($dashboard) {
$rendered_dashboard = id(new PhabricatorDashboardRenderingEngine())
$content = id(new PhabricatorDashboardRenderingEngine())
->setViewer($user)
->setDashboard($dashboard)
->renderDashboard();
$nav->appendChild($rendered_dashboard);
} else {
$project_query = new PhabricatorProjectQuery();
$project_query->setViewer($user);
$project_query->withMemberPHIDs(array($user->getPHID()));
$projects = $project_query->execute();
$nav = $this->buildMainResponse($nav, $projects);
$content = $this->buildMainResponse($projects);
}
$nav->appendChild(id(new PhabricatorGlobalUploadTargetView())
->setUser($user));
if (!$this->only) {
$nav = $this->buildNav();
$nav->appendChild(
array(
$content,
id(new PhabricatorGlobalUploadTargetView())->setUser($user),
));
$content = $nav;
}
return $this->buildApplicationPage(
$nav,
$content,
array(
'title' => 'Phabricator',
'device' => true,
));
}
private function buildMainResponse($nav, array $projects) {
private function buildMainResponse(array $projects) {
assert_instances_of($projects, 'PhabricatorProject');
$viewer = $this->getRequest()->getUser();
@ -94,7 +99,7 @@ final class PhabricatorHomeMainController
$revision_panel = null;
}
$content = array(
return array(
$welcome_panel,
$unbreak_panel,
$triage_panel,
@ -104,11 +109,6 @@ final class PhabricatorHomeMainController
$commit_panel,
$this->minipanels,
);
$nav->appendChild($content);
return $nav;
}
private function buildUnbreakNowPanel() {

View file

@ -1,6 +1,6 @@
<?php
final class PhabricatorApplicationLaunchView extends AphrontView {
final class PhabricatorApplicationLaunchView extends AphrontTagView {
private $application;
private $status;
@ -15,7 +15,19 @@ final class PhabricatorApplicationLaunchView extends AphrontView {
return $this;
}
public function render() {
protected function getTagName() {
return $this->application ? 'a' : 'div';
}
protected function getTagAttributes() {
$application = $this->application;
return array(
'class' => array('phabricator-application-launch-container'),
'href' => $application ? $application->getBaseURI() : null,
);
}
protected function getTagContent() {
$application = $this->application;
require_celerity_resource('phabricator-application-launch-view-css');
@ -124,20 +136,10 @@ final class PhabricatorApplicationLaunchView extends AphrontView {
'');
}
$classes = array();
$classes[] = 'phabricator-application-launch-container';
$app_button = phutil_tag(
$application ? 'a' : 'div',
array(
'class' => implode(' ', $classes),
'href' => $application ? $application->getBaseURI() : null,
),
array(
$icon,
$content,
));
return $app_button;
return array(
$icon,
$content,
);
}
}

View file

@ -93,3 +93,11 @@ div.phabricator-application-launch-container {
.phabricator-application-attention-count {
color: {$sky};
}
a.phabricator-application-launch-phone-only {
display: none;
}
.device-phone a.phabricator-application-launch-phone-only {
display: block;
}