Skip to content

Commit 73924df

Browse files
author
epriestley
committed
Add initial skeleton for Dashboard application
Summary: Ref T3583. General idea here is: - Users will be able to create `DashboardPanel`s, which are things like the jump nav, or a minifeed, or recent assigned tasks, or recent tokens given, or whatever else. - The `DashboardPanel`s can be combined into `Dashboard`s, which select specific panels and arrange them in some layout (and maybe have a few other options eventually). - Then, you'll be able to set a specific `Dashboard` for your home page, and maybe for project home pages. But you can also use `Dashboard`s on their own if you just like dashboards. My plan is pretty much: - Put in basic infrastructure for dashboards (this diff). - Add basic create/edit (next few diffs). - Once dashboards sort of work, do the homepage integration. This diff does very little: you can't create dashboards or panels yet, and thus there are no dashboards to look at. This is all skeleton code, pretty much. IMPORTANT: We need an icon bwahahahahaha Test Plan: omg si purrfect {F106367} Reviewers: chad, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3583 Differential Revision: https://secure.phabricator.com/D8109
1 parent eb397a4 commit 73924df

17 files changed

+653
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE {$NAMESPACE}_dashboard.dashboard (
2+
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
3+
phid VARCHAR(64) NOT NULL COLLATE utf8_bin,
4+
name VARCHAR(255) NOT NULL,
5+
viewPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin,
6+
editPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin,
7+
dateCreated INT UNSIGNED NOT NULL,
8+
dateModified INT UNSIGNED NOT NULL,
9+
UNIQUE KEY `key_phid` (phid)
10+
) ENGINE=InnoDB, COLLATE=utf8_general_ci;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CREATE TABLE {$NAMESPACE}_dashboard.dashboard_panel (
2+
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
3+
phid VARCHAR(64) NOT NULL COLLATE utf8_bin,
4+
name VARCHAR(255) NOT NULL,
5+
viewPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin,
6+
editPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin,
7+
properties LONGTEXT NOT NULL COLLATE utf8_bin,
8+
dateCreated INT UNSIGNED NOT NULL,
9+
dateModified INT UNSIGNED NOT NULL,
10+
UNIQUE KEY `key_phid` (phid)
11+
) ENGINE=InnoDB, COLLATE=utf8_general_ci;

src/__phutil_library_map__.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,7 @@
10751075
'PhabricatorApplicationConpherence' => 'applications/conpherence/application/PhabricatorApplicationConpherence.php',
10761076
'PhabricatorApplicationCountdown' => 'applications/countdown/application/PhabricatorApplicationCountdown.php',
10771077
'PhabricatorApplicationDaemons' => 'applications/daemon/application/PhabricatorApplicationDaemons.php',
1078+
'PhabricatorApplicationDashboard' => 'applications/dashboard/application/PhabricatorApplicationDashboard.php',
10781079
'PhabricatorApplicationDetailViewController' => 'applications/meta/controller/PhabricatorApplicationDetailViewController.php',
10791080
'PhabricatorApplicationDifferential' => 'applications/differential/application/PhabricatorApplicationDifferential.php',
10801081
'PhabricatorApplicationDiffusion' => 'applications/diffusion/application/PhabricatorApplicationDiffusion.php',
@@ -1378,6 +1379,18 @@
13781379
'PhabricatorDaemonManagementWorkflow' => 'applications/daemon/management/PhabricatorDaemonManagementWorkflow.php',
13791380
'PhabricatorDaemonReference' => 'infrastructure/daemon/control/PhabricatorDaemonReference.php',
13801381
'PhabricatorDaemonTaskGarbageCollector' => 'applications/daemon/garbagecollector/PhabricatorDaemonTaskGarbageCollector.php',
1382+
'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php',
1383+
'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php',
1384+
'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php',
1385+
'PhabricatorDashboardListController' => 'applications/dashboard/controller/PhabricatorDashboardListController.php',
1386+
'PhabricatorDashboardPHIDTypeDashboard' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php',
1387+
'PhabricatorDashboardPHIDTypePanel' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php',
1388+
'PhabricatorDashboardPanel' => 'applications/dashboard/storage/PhabricatorDashboardPanel.php',
1389+
'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php',
1390+
'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php',
1391+
'PhabricatorDashboardPanelSearchEngine' => 'applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php',
1392+
'PhabricatorDashboardQuery' => 'applications/dashboard/query/PhabricatorDashboardQuery.php',
1393+
'PhabricatorDashboardSearchEngine' => 'applications/dashboard/query/PhabricatorDashboardSearchEngine.php',
13811394
'PhabricatorDataNotAttachedException' => 'infrastructure/storage/lisk/PhabricatorDataNotAttachedException.php',
13821395
'PhabricatorDebugController' => 'applications/system/PhabricatorDebugController.php',
13831396
'PhabricatorDefaultFileStorageEngineSelector' => 'applications/files/engineselector/PhabricatorDefaultFileStorageEngineSelector.php',
@@ -3662,6 +3675,7 @@
36623675
'PhabricatorApplicationConpherence' => 'PhabricatorApplication',
36633676
'PhabricatorApplicationCountdown' => 'PhabricatorApplication',
36643677
'PhabricatorApplicationDaemons' => 'PhabricatorApplication',
3678+
'PhabricatorApplicationDashboard' => 'PhabricatorApplication',
36653679
'PhabricatorApplicationDetailViewController' => 'PhabricatorApplicationsController',
36663680
'PhabricatorApplicationDifferential' => 'PhabricatorApplication',
36673681
'PhabricatorApplicationDiffusion' => 'PhabricatorApplication',
@@ -4007,6 +4021,30 @@
40074021
'PhabricatorDaemonManagementStopWorkflow' => 'PhabricatorDaemonManagementWorkflow',
40084022
'PhabricatorDaemonManagementWorkflow' => 'PhabricatorManagementWorkflow',
40094023
'PhabricatorDaemonTaskGarbageCollector' => 'PhabricatorGarbageCollector',
4024+
'PhabricatorDashboard' =>
4025+
array(
4026+
0 => 'PhabricatorDashboardDAO',
4027+
1 => 'PhabricatorPolicyInterface',
4028+
),
4029+
'PhabricatorDashboardController' => 'PhabricatorController',
4030+
'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO',
4031+
'PhabricatorDashboardListController' =>
4032+
array(
4033+
0 => 'PhabricatorDashboardController',
4034+
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
4035+
),
4036+
'PhabricatorDashboardPHIDTypeDashboard' => 'PhabricatorPHIDType',
4037+
'PhabricatorDashboardPHIDTypePanel' => 'PhabricatorPHIDType',
4038+
'PhabricatorDashboardPanel' => 'PhabricatorDashboardDAO',
4039+
'PhabricatorDashboardPanelListController' =>
4040+
array(
4041+
0 => 'PhabricatorDashboardController',
4042+
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
4043+
),
4044+
'PhabricatorDashboardPanelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
4045+
'PhabricatorDashboardPanelSearchEngine' => 'PhabricatorApplicationSearchEngine',
4046+
'PhabricatorDashboardQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
4047+
'PhabricatorDashboardSearchEngine' => 'PhabricatorApplicationSearchEngine',
40104048
'PhabricatorDataNotAttachedException' => 'Exception',
40114049
'PhabricatorDebugController' => 'PhabricatorController',
40124050
'PhabricatorDefaultFileStorageEngineSelector' => 'PhabricatorFileStorageEngineSelector',
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
final class PhabricatorApplicationDashboard extends PhabricatorApplication {
4+
5+
public function getBaseURI() {
6+
return '/dashboard/';
7+
}
8+
9+
public function getShortDescription() {
10+
return pht('Such Data');
11+
}
12+
13+
public function getIconName() {
14+
return 'dashboard';
15+
}
16+
17+
public function getRoutes() {
18+
return array(
19+
'/W(?P<id>\d+)' => 'PhabricatorDashboardPanelViewController',
20+
'/dashboard/' => array(
21+
'(?:query/(?P<queryKey>[^/]+)/)?'
22+
=> 'PhabricatorDashboardListController',
23+
'view/(?P<id>\d+)/' => 'PhabricatorDashboardViewController',
24+
'panel/' => array(
25+
'(?:query/(?P<queryKey>[^/]+)/)?'
26+
=> 'PhabricatorDashboardPanelListController',
27+
),
28+
),
29+
);
30+
}
31+
32+
public function shouldAppearInLaunchView() {
33+
return false;
34+
}
35+
36+
public function canUninstall() {
37+
return false;
38+
}
39+
40+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
abstract class PhabricatorDashboardController extends PhabricatorController {
4+
5+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
final class PhabricatorDashboardListController
4+
extends PhabricatorDashboardController
5+
implements PhabricatorApplicationSearchResultsControllerInterface {
6+
7+
private $queryKey;
8+
public function willProcessRequest(array $data) {
9+
$this->queryKey = idx($data, 'queryKey');
10+
}
11+
12+
public function processRequest() {
13+
$request = $this->getRequest();
14+
$controller = id(new PhabricatorApplicationSearchController($request))
15+
->setQueryKey($this->queryKey)
16+
->setSearchEngine(new PhabricatorDashboardSearchEngine())
17+
->setNavigation($this->buildSideNavView());
18+
return $this->delegateToController($controller);
19+
}
20+
21+
public function buildSideNavView() {
22+
$user = $this->getRequest()->getUser();
23+
24+
$nav = new AphrontSideNavFilterView();
25+
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
26+
27+
id(new PhabricatorDashboardSearchEngine())
28+
->setViewer($user)
29+
->addNavigationItems($nav->getMenu());
30+
31+
$nav->selectFilter(null);
32+
33+
return $nav;
34+
}
35+
36+
public function renderResultsList(
37+
array $dashboards,
38+
PhabricatorSavedQuery $query) {
39+
40+
return 'got '.count($dashboards).' ok';
41+
}
42+
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
final class PhabricatorDashboardPanelListController
4+
extends PhabricatorDashboardController
5+
implements PhabricatorApplicationSearchResultsControllerInterface {
6+
7+
private $queryKey;
8+
public function willProcessRequest(array $data) {
9+
$this->queryKey = idx($data, 'queryKey');
10+
}
11+
12+
public function processRequest() {
13+
$request = $this->getRequest();
14+
$controller = id(new PhabricatorApplicationSearchController($request))
15+
->setQueryKey($this->queryKey)
16+
->setSearchEngine(new PhabricatorDashboardPanelSearchEngine())
17+
->setNavigation($this->buildSideNavView());
18+
return $this->delegateToController($controller);
19+
}
20+
21+
public function buildSideNavView() {
22+
$user = $this->getRequest()->getUser();
23+
24+
$nav = new AphrontSideNavFilterView();
25+
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
26+
27+
id(new PhabricatorDashboardPanelSearchEngine())
28+
->setViewer($user)
29+
->addNavigationItems($nav->getMenu());
30+
31+
$nav->selectFilter(null);
32+
33+
return $nav;
34+
}
35+
36+
public function renderResultsList(
37+
array $panels,
38+
PhabricatorSavedQuery $query) {
39+
40+
return 'got '.count($panels).' ok';
41+
}
42+
43+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
final class PhabricatorDashboardPHIDTypeDashboard extends PhabricatorPHIDType {
4+
5+
const TYPECONST = 'DSHB';
6+
7+
public function getTypeConstant() {
8+
return self::TYPECONST;
9+
}
10+
11+
public function getTypeName() {
12+
return pht('Dashboard');
13+
}
14+
15+
public function newObject() {
16+
return new PhabricatorDashboard();
17+
}
18+
19+
protected function buildQueryForObjects(
20+
PhabricatorObjectQuery $query,
21+
array $phids) {
22+
23+
return id(new PhabricatorDashboardQuery())
24+
->withPHIDs($phids);
25+
}
26+
27+
public function loadHandles(
28+
PhabricatorHandleQuery $query,
29+
array $handles,
30+
array $objects) {
31+
32+
foreach ($handles as $phid => $handle) {
33+
$dashboard = $objects[$phid];
34+
35+
$id = $dashboard->getID();
36+
37+
$handle->setName($dashboard->getName());
38+
$handle->setURI("/dashboard/view/{$id}/");
39+
}
40+
}
41+
42+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
final class PhabricatorDashboardPHIDTypePanel extends PhabricatorPHIDType {
4+
5+
const TYPECONST = 'DSHP';
6+
7+
public function getTypeConstant() {
8+
return self::TYPECONST;
9+
}
10+
11+
public function getTypeName() {
12+
return pht('Panel');
13+
}
14+
15+
public function newObject() {
16+
return new PhabricatorDashboardPanel();
17+
}
18+
19+
protected function buildQueryForObjects(
20+
PhabricatorObjectQuery $query,
21+
array $phids) {
22+
23+
return id(new PhabricatorDashboardPanelQuery())
24+
->withPHIDs($phids);
25+
}
26+
27+
public function loadHandles(
28+
PhabricatorHandleQuery $query,
29+
array $handles,
30+
array $objects) {
31+
32+
foreach ($handles as $phid => $handle) {
33+
$panel = $objects[$phid];
34+
35+
$name = $panel->getName();
36+
$monogram = $panel->getMonogram();
37+
38+
$handle->setName($panel->getMonogram());
39+
$handle->setFullName("{$monogram} {$name}");
40+
$handle->setURI("/{$monogram}");
41+
}
42+
}
43+
44+
public function canLoadNamedObject($name) {
45+
return preg_match('/^W\d*[1-9]\d*$/i', $name);
46+
}
47+
48+
public function loadNamedObjects(
49+
PhabricatorObjectQuery $query,
50+
array $names) {
51+
52+
$id_map = array();
53+
foreach ($names as $name) {
54+
$id = (int)substr($name, 1);
55+
$id_map[$id][] = $name;
56+
}
57+
58+
$objects = id(new PhabricatorDashboardPanelQuery())
59+
->setViewer($query->getViewer())
60+
->withIDs(array_keys($id_map))
61+
->execute();
62+
63+
$results = array();
64+
foreach ($objects as $id => $object) {
65+
foreach (idx($id_map, $id, array()) as $name) {
66+
$results[$name] = $object;
67+
}
68+
}
69+
70+
return $results;
71+
}
72+
73+
}

0 commit comments

Comments
 (0)