2011-01-16 22:51:39 +01:00
|
|
|
<?php
|
|
|
|
|
2014-07-23 02:03:09 +02:00
|
|
|
final class PhabricatorHomeMainController extends PhabricatorHomeController {
|
2011-01-16 22:51:39 +01:00
|
|
|
|
2014-01-27 00:28:55 +01:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-24 00:08:35 +02:00
|
|
|
public function isGlobalDragAndDropUploadEnabled() {
|
|
|
|
return true;
|
2012-02-16 02:48:14 +01:00
|
|
|
}
|
|
|
|
|
2015-04-24 00:08:35 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
2016-08-25 20:16:34 +02:00
|
|
|
$viewer = $request->getViewer();
|
2013-01-16 00:41:22 +01:00
|
|
|
|
2014-05-20 01:09:31 +02:00
|
|
|
$dashboard = PhabricatorDashboardInstall::getDashboard(
|
2016-08-25 20:16:34 +02:00
|
|
|
$viewer,
|
|
|
|
$viewer->getPHID(),
|
2014-05-20 01:09:31 +02:00
|
|
|
get_class($this->getCurrentApplication()));
|
2014-06-24 00:14:38 +02:00
|
|
|
|
|
|
|
if (!$dashboard) {
|
|
|
|
$dashboard = PhabricatorDashboardInstall::getDashboard(
|
2016-08-25 20:16:34 +02:00
|
|
|
$viewer,
|
2014-07-23 02:03:09 +02:00
|
|
|
PhabricatorHomeApplication::DASHBOARD_DEFAULT,
|
2014-06-24 00:14:38 +02:00
|
|
|
get_class($this->getCurrentApplication()));
|
|
|
|
}
|
|
|
|
|
2014-05-20 01:09:31 +02:00
|
|
|
if ($dashboard) {
|
2014-06-13 04:16:53 +02:00
|
|
|
$content = id(new PhabricatorDashboardRenderingEngine())
|
2016-08-25 20:16:34 +02:00
|
|
|
->setViewer($viewer)
|
2014-05-20 01:09:31 +02:00
|
|
|
->setDashboard($dashboard)
|
|
|
|
->renderDashboard();
|
|
|
|
} else {
|
2016-08-25 20:16:34 +02:00
|
|
|
$content = $this->buildMainResponse();
|
2014-05-20 01:09:31 +02:00
|
|
|
}
|
|
|
|
|
2015-04-24 00:08:35 +02:00
|
|
|
if (!$request->getURIData('only')) {
|
2014-06-13 04:16:53 +02:00
|
|
|
$nav = $this->buildNav();
|
|
|
|
$nav->appendChild(
|
|
|
|
array(
|
|
|
|
$content,
|
2016-08-25 20:16:34 +02:00
|
|
|
id(new PhabricatorGlobalUploadTargetView())->setUser($viewer),
|
2014-06-13 04:16:53 +02:00
|
|
|
));
|
|
|
|
$content = $nav;
|
|
|
|
}
|
2012-02-16 02:48:14 +01:00
|
|
|
|
2016-04-05 22:32:06 +02:00
|
|
|
return $this->newPage()
|
|
|
|
->setTitle('Phabricator')
|
2016-10-01 21:35:13 +02:00
|
|
|
->addClass('phabricator-home')
|
2016-04-05 22:32:06 +02:00
|
|
|
->appendChild($content);
|
|
|
|
|
2012-02-16 02:48:14 +01:00
|
|
|
}
|
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
private function buildMainResponse() {
|
|
|
|
require_celerity_resource('phabricator-dashboard-css');
|
|
|
|
$viewer = $this->getViewer();
|
2012-04-03 21:10:45 +02:00
|
|
|
|
2014-03-15 19:28:02 +01:00
|
|
|
$has_maniphest = PhabricatorApplication::isClassInstalledForViewer(
|
2014-07-23 02:03:09 +02:00
|
|
|
'PhabricatorManiphestApplication',
|
2014-03-15 19:28:02 +01:00
|
|
|
$viewer);
|
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$has_diffusion = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorDiffusionApplication',
|
2014-03-15 19:28:02 +01:00
|
|
|
$viewer);
|
|
|
|
|
|
|
|
$has_differential = PhabricatorApplication::isClassInstalledForViewer(
|
2014-07-23 02:03:09 +02:00
|
|
|
'PhabricatorDifferentialApplication',
|
2014-03-15 19:28:02 +01:00
|
|
|
$viewer);
|
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$revision_panel = null;
|
|
|
|
if ($has_differential) {
|
|
|
|
$revision_panel = $this->buildRevisionPanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
$tasks_panel = null;
|
2014-03-15 19:28:02 +01:00
|
|
|
if ($has_maniphest) {
|
2012-02-18 01:08:35 +01:00
|
|
|
$tasks_panel = $this->buildTasksPanel();
|
|
|
|
}
|
2012-02-27 18:48:18 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$repository_panel = null;
|
|
|
|
if ($has_diffusion) {
|
|
|
|
$repository_panel = $this->buildRepositoryPanel();
|
2013-10-10 00:25:03 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$feed_panel = $this->buildFeedPanel();
|
2013-10-10 00:25:03 +02:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$dashboard = id(new AphrontMultiColumnView())
|
|
|
|
->setFluidlayout(true)
|
|
|
|
->setGutter(AphrontMultiColumnView::GUTTER_LARGE);
|
2011-01-25 20:31:40 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$main_panel = phutil_tag(
|
2015-01-28 00:30:11 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'homepage-panel',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$revision_panel,
|
|
|
|
$tasks_panel,
|
2016-08-25 20:16:34 +02:00
|
|
|
$repository_panel,
|
2015-01-28 00:30:11 +01:00
|
|
|
));
|
2016-08-25 20:16:34 +02:00
|
|
|
$dashboard->addColumn($main_panel, 'thirds');
|
Replace home directory list with a dashboard
Summary:
Rough cut that still needs a lot of polish, but replace the directory list with
more of a dashboard type thing:
- Show "Unbreak Now", triage-in-your-projects, and other stuff that you're
supposed to deal with, then feed.
- Move tools a click a way behind nav -- this also lets us put more stuff
there and subtools, etc., later.
- Remove tabs.
- Merge the category/item editing views.
- I also added a light blue wash to the side nav, not sure if I like that or
not.
Test Plan:
- Viewed all elements in empty and nonempty states.
- Viewed applications, edited items/categories.
Reviewers: btrahan, aran
Reviewed By: btrahan
CC: aran, epriestley, davidreuss
Maniphest Tasks: T21, T631
Differential Revision: https://secure.phabricator.com/D1574
2012-02-08 01:04:48 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$side_panel = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'homepage-side-panel',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$feed_panel,
|
|
|
|
));
|
|
|
|
$dashboard->addColumn($side_panel, 'third');
|
Replace home directory list with a dashboard
Summary:
Rough cut that still needs a lot of polish, but replace the directory list with
more of a dashboard type thing:
- Show "Unbreak Now", triage-in-your-projects, and other stuff that you're
supposed to deal with, then feed.
- Move tools a click a way behind nav -- this also lets us put more stuff
there and subtools, etc., later.
- Remove tabs.
- Merge the category/item editing views.
- I also added a light blue wash to the side nav, not sure if I like that or
not.
Test Plan:
- Viewed all elements in empty and nonempty states.
- Viewed applications, edited items/categories.
Reviewers: btrahan, aran
Reviewed By: btrahan
CC: aran, epriestley, davidreuss
Maniphest Tasks: T21, T631
Differential Revision: https://secure.phabricator.com/D1574
2012-02-08 01:04:48 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$view = id(new PHUIBoxView())
|
|
|
|
->addClass('dashboard-view')
|
|
|
|
->appendChild($dashboard);
|
Replace home directory list with a dashboard
Summary:
Rough cut that still needs a lot of polish, but replace the directory list with
more of a dashboard type thing:
- Show "Unbreak Now", triage-in-your-projects, and other stuff that you're
supposed to deal with, then feed.
- Move tools a click a way behind nav -- this also lets us put more stuff
there and subtools, etc., later.
- Remove tabs.
- Merge the category/item editing views.
- I also added a light blue wash to the side nav, not sure if I like that or
not.
Test Plan:
- Viewed all elements in empty and nonempty states.
- Viewed applications, edited items/categories.
Reviewers: btrahan, aran
Reviewed By: btrahan
CC: aran, epriestley, davidreuss
Maniphest Tasks: T21, T631
Differential Revision: https://secure.phabricator.com/D1574
2012-02-08 01:04:48 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
return $view;
|
Replace home directory list with a dashboard
Summary:
Rough cut that still needs a lot of polish, but replace the directory list with
more of a dashboard type thing:
- Show "Unbreak Now", triage-in-your-projects, and other stuff that you're
supposed to deal with, then feed.
- Move tools a click a way behind nav -- this also lets us put more stuff
there and subtools, etc., later.
- Remove tabs.
- Merge the category/item editing views.
- I also added a light blue wash to the side nav, not sure if I like that or
not.
Test Plan:
- Viewed all elements in empty and nonempty states.
- Viewed applications, edited items/categories.
Reviewers: btrahan, aran
Reviewed By: btrahan
CC: aran, epriestley, davidreuss
Maniphest Tasks: T21, T631
Differential Revision: https://secure.phabricator.com/D1574
2012-02-08 01:04:48 +01:00
|
|
|
}
|
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
private function buildHomepagePanel($title, $href, $view) {
|
2015-01-28 00:30:11 +01:00
|
|
|
$title = phutil_tag(
|
2014-01-21 23:23:36 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $href,
|
|
|
|
),
|
|
|
|
$title);
|
2016-08-25 20:16:34 +02:00
|
|
|
|
2015-05-22 16:13:40 +02:00
|
|
|
$icon = id(new PHUIIconView())
|
2016-01-28 05:38:01 +01:00
|
|
|
->setIcon('fa-search')
|
2015-05-22 16:13:40 +02:00
|
|
|
->setHref($href);
|
2016-08-25 20:16:34 +02:00
|
|
|
|
2015-01-28 00:30:11 +01:00
|
|
|
$header = id(new PHUIHeaderView())
|
2015-05-22 16:13:40 +02:00
|
|
|
->setHeader($title)
|
2016-03-05 03:34:37 +01:00
|
|
|
->addActionItem($icon);
|
2014-01-21 23:23:36 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header);
|
2012-02-16 02:49:23 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
if ($view->getObjectList()) {
|
|
|
|
$box->setObjectList($view->getObjectList());
|
|
|
|
}
|
|
|
|
if ($view->getContent()) {
|
|
|
|
$box->appendChild($view->getContent());
|
|
|
|
}
|
2012-02-27 18:48:18 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
return $box;
|
|
|
|
}
|
2012-02-27 18:48:18 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
private function buildRevisionPanel() {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
if (!$viewer->isLoggedIn()) {
|
|
|
|
return null;
|
2012-02-27 18:48:18 +01:00
|
|
|
}
|
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$engine = new DifferentialRevisionSearchEngine();
|
|
|
|
$engine->setViewer($viewer);
|
|
|
|
$saved = $engine->buildSavedQueryFromBuiltin('active');
|
|
|
|
$query = $engine->buildQueryFromSavedQuery($saved);
|
|
|
|
$pager = $engine->newPagerForSavedQuery($saved);
|
|
|
|
$pager->setPageSize(15);
|
|
|
|
$results = $engine->executeQuery($query, $pager);
|
|
|
|
$view = $engine->renderResults($results, $saved);
|
2012-02-27 18:48:18 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$title = pht('Active Revisions');
|
|
|
|
$href = '/differential/query/active/';
|
2012-02-27 18:48:18 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
return $this->buildHomepagePanel($title, $href, $view);
|
2012-02-27 18:48:18 +01:00
|
|
|
}
|
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
private function buildTasksPanel() {
|
|
|
|
$viewer = $this->getViewer();
|
2012-02-29 06:10:39 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$query = 'assigned';
|
|
|
|
$title = pht('Assigned Tasks');
|
|
|
|
$href = '/maniphest/query/assigned/';
|
|
|
|
if (!$viewer->isLoggedIn()) {
|
|
|
|
$query = 'open';
|
|
|
|
$title = pht('Open Tasks');
|
|
|
|
$href = '/maniphest/query/open/';
|
|
|
|
}
|
|
|
|
|
|
|
|
$engine = new ManiphestTaskSearchEngine();
|
|
|
|
$engine->setViewer($viewer);
|
|
|
|
$saved = $engine->buildSavedQueryFromBuiltin($query);
|
|
|
|
$query = $engine->buildQueryFromSavedQuery($saved);
|
|
|
|
$pager = $engine->newPagerForSavedQuery($saved);
|
|
|
|
$pager->setPageSize(15);
|
|
|
|
$results = $engine->executeQuery($query, $pager);
|
|
|
|
$view = $engine->renderResults($results, $saved);
|
|
|
|
|
|
|
|
return $this->buildHomepagePanel($title, $href, $view);
|
|
|
|
}
|
2012-02-29 06:10:39 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
public function buildFeedPanel() {
|
|
|
|
$viewer = $this->getViewer();
|
2012-02-29 06:10:39 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$engine = new PhabricatorFeedSearchEngine();
|
|
|
|
$engine->setViewer($viewer);
|
|
|
|
$saved = $engine->buildSavedQueryFromBuiltin('all');
|
|
|
|
$query = $engine->buildQueryFromSavedQuery($saved);
|
|
|
|
$pager = $engine->newPagerForSavedQuery($saved);
|
|
|
|
$pager->setPageSize(40);
|
|
|
|
$results = $engine->executeQuery($query, $pager);
|
|
|
|
$view = $engine->renderResults($results, $saved);
|
2016-08-31 22:53:27 +02:00
|
|
|
// Low tech NUX.
|
|
|
|
if (!$results && ($viewer->getIsAdmin() == 1)) {
|
|
|
|
$instance = PhabricatorEnv::getEnvConfig('cluster.instance');
|
|
|
|
if (!$instance) {
|
|
|
|
$content = pht(<<<EOT
|
|
|
|
Welcome to Phabricator, here are some links to get you started:
|
|
|
|
- [[ /config/ | Configure Phabricator ]]
|
2016-09-03 06:16:20 +02:00
|
|
|
- [[ /guides/ | Quick Start Guide ]]
|
2016-08-31 22:53:27 +02:00
|
|
|
- [[ /diffusion/ | Create a Repository ]]
|
|
|
|
- [[ /people/invite/send/ | Invite People ]]
|
|
|
|
- [[ https://twitter.com/phabricator/ | Follow us on Twitter ]]
|
|
|
|
EOT
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$content = pht(<<<EOT
|
|
|
|
Welcome to Phabricator, here are some links to get you started:
|
2016-09-03 06:16:20 +02:00
|
|
|
- [[ /guides/ | Quick Start Guide ]]
|
2016-08-31 22:53:27 +02:00
|
|
|
- [[ /diffusion/ | Create a Repository ]]
|
|
|
|
- [[ https://twitter.com/phabricator/ | Follow us on Twitter ]]
|
|
|
|
EOT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$welcome = new PHUIRemarkupView($viewer, $content);
|
|
|
|
|
|
|
|
$list = new PHUIObjectItemListView();
|
|
|
|
$view = new PhabricatorApplicationSearchResultView();
|
|
|
|
$view->setObjectList($list);
|
|
|
|
$view->setNoDataString($welcome);
|
|
|
|
}
|
2012-02-29 06:10:39 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$title = pht('Recent Activity');
|
|
|
|
$href = '/feed/';
|
2012-02-29 06:10:39 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
return $this->buildHomepagePanel($title, $href, $view);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildRepositoryPanel() {
|
|
|
|
$viewer = $this->getViewer();
|
2012-02-29 06:10:39 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$engine = new PhabricatorRepositorySearchEngine();
|
|
|
|
$engine->setViewer($viewer);
|
|
|
|
$saved = $engine->buildSavedQueryFromBuiltin('active');
|
|
|
|
$query = $engine->buildQueryFromSavedQuery($saved);
|
|
|
|
$pager = $engine->newPagerForSavedQuery($saved);
|
|
|
|
$pager->setPageSize(5);
|
|
|
|
$results = $engine->executeQuery($query, $pager);
|
|
|
|
$view = $engine->renderResults($results, $saved);
|
2012-02-29 06:10:39 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
$title = pht('Active Repositories');
|
|
|
|
$href = '/diffusion/';
|
2012-02-29 06:10:39 +01:00
|
|
|
|
2016-08-25 20:16:34 +02:00
|
|
|
return $this->buildHomepagePanel($title, $href, $view);
|
2012-02-29 06:10:39 +01:00
|
|
|
}
|
|
|
|
|
2011-01-16 22:51:39 +01:00
|
|
|
}
|