Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/home/view/PHUIHomeView.php
12256 views
1
<?php
2
3
final class PHUIHomeView
4
extends AphrontTagView {
5
6
protected function getTagName() {
7
return null;
8
}
9
10
protected function getTagAttributes() {
11
return array();
12
}
13
14
protected function getTagContent() {
15
require_celerity_resource('phabricator-dashboard-css');
16
$viewer = $this->getViewer();
17
18
$has_maniphest = PhabricatorApplication::isClassInstalledForViewer(
19
'PhabricatorManiphestApplication',
20
$viewer);
21
22
$has_diffusion = PhabricatorApplication::isClassInstalledForViewer(
23
'PhabricatorDiffusionApplication',
24
$viewer);
25
26
$has_differential = PhabricatorApplication::isClassInstalledForViewer(
27
'PhabricatorDifferentialApplication',
28
$viewer);
29
30
$revision_panel = null;
31
if ($has_differential) {
32
$revision_panel = $this->buildRevisionPanel();
33
}
34
35
$tasks_panel = null;
36
if ($has_maniphest) {
37
$tasks_panel = $this->buildTasksPanel();
38
}
39
40
$repository_panel = null;
41
if ($has_diffusion) {
42
$repository_panel = $this->buildRepositoryPanel();
43
}
44
45
$feed_panel = $this->buildFeedPanel();
46
47
$dashboard = id(new AphrontMultiColumnView())
48
->setFluidlayout(true)
49
->setGutter(AphrontMultiColumnView::GUTTER_LARGE);
50
51
$main_panel = phutil_tag(
52
'div',
53
array(
54
'class' => 'homepage-panel',
55
),
56
array(
57
$revision_panel,
58
$tasks_panel,
59
$repository_panel,
60
));
61
$dashboard->addColumn($main_panel, 'thirds');
62
63
$side_panel = phutil_tag(
64
'div',
65
array(
66
'class' => 'homepage-side-panel',
67
),
68
array(
69
$feed_panel,
70
));
71
$dashboard->addColumn($side_panel, 'third');
72
73
$view = id(new PHUIBoxView())
74
->addClass('dashboard-view')
75
->appendChild($dashboard);
76
77
return $view;
78
}
79
80
private function buildRevisionPanel() {
81
$viewer = $this->getViewer();
82
if (!$viewer->isLoggedIn()) {
83
return null;
84
}
85
86
$panel = $this->newQueryPanel()
87
->setName(pht('Active Revisions'))
88
->setProperty('class', 'DifferentialRevisionSearchEngine')
89
->setProperty('key', 'active');
90
91
return $this->renderPanel($panel);
92
}
93
94
private function buildTasksPanel() {
95
$viewer = $this->getViewer();
96
97
if ($viewer->isLoggedIn()) {
98
$name = pht('Assigned Tasks');
99
$query = 'assigned';
100
} else {
101
$name = pht('Open Tasks');
102
$query = 'open';
103
}
104
105
$panel = $this->newQueryPanel()
106
->setName($name)
107
->setProperty('class', 'ManiphestTaskSearchEngine')
108
->setProperty('key', $query)
109
->setProperty('limit', 15);
110
111
return $this->renderPanel($panel);
112
}
113
114
public function buildFeedPanel() {
115
$panel = $this->newQueryPanel()
116
->setName(pht('Recent Activity'))
117
->setProperty('class', 'PhabricatorFeedSearchEngine')
118
->setProperty('key', 'all')
119
->setProperty('limit', 40);
120
121
return $this->renderPanel($panel);
122
}
123
124
public function buildRepositoryPanel() {
125
$panel = $this->newQueryPanel()
126
->setName(pht('Active Repositories'))
127
->setProperty('class', 'PhabricatorRepositorySearchEngine')
128
->setProperty('key', 'active')
129
->setProperty('limit', 5);
130
131
return $this->renderPanel($panel);
132
}
133
134
private function newQueryPanel() {
135
$panel_type = id(new PhabricatorDashboardQueryPanelType())
136
->getPanelTypeKey();
137
138
return id(new PhabricatorDashboardPanel())
139
->setPanelType($panel_type);
140
}
141
142
private function renderPanel(PhabricatorDashboardPanel $panel) {
143
$viewer = $this->getViewer();
144
145
return id(new PhabricatorDashboardPanelRenderingEngine())
146
->setViewer($viewer)
147
->setPanel($panel)
148
->setParentPanelPHIDs(array())
149
->renderPanel();
150
}
151
152
}
153
154