forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorDashboardViewController.php
81 lines (66 loc) · 1.95 KB
/
PhabricatorDashboardViewController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
final class PhabricatorDashboardViewController
extends PhabricatorDashboardController {
private $id;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->needPanels(true)
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$title = $dashboard->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->setBorder(true);
$crumbs->addTextCrumb(pht('Dashboard %d', $dashboard->getID()));
if ($dashboard->getPanelPHIDs()) {
$rendered_dashboard = id(new PhabricatorDashboardRenderingEngine())
->setViewer($viewer)
->setDashboard($dashboard)
->renderDashboard();
} else {
$rendered_dashboard = $this->buildEmptyView();
}
return $this->buildApplicationPage(
array(
$crumbs,
$rendered_dashboard,
),
array(
'title' => $title,
));
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$id = $this->id;
$crumbs->addAction(
id(new PHUIListItemView())
->setIcon('fa-th')
->setName(pht('Manage Dashboard'))
->setHref($this->getApplicationURI("manage/{$id}/")));
return $crumbs;
}
public function buildEmptyView() {
$id = $this->id;
$manage_uri = $this->getApplicationURI("manage/{$id}/");
return id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
->appendChild(
pht('This dashboard has no panels '.
'yet. Use %s to add panels.',
phutil_tag(
'a',
array('href' => $manage_uri),
pht('Manage Dashboard'))));
}
}