Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/constants/DifferentialConstantsModule.php
12256 views
1
<?php
2
3
final class DifferentialConstantsModule
4
extends PhabricatorConfigModule {
5
6
public function getModuleKey() {
7
return 'constants.differential';
8
}
9
10
public function getModuleName() {
11
return pht('Constants: Differential');
12
}
13
14
public function renderModuleStatus(AphrontRequest $request) {
15
$viewer = $request->getViewer();
16
17
return array(
18
$this->renderRevisionStatuses($viewer),
19
$this->renderUnitStatuses($viewer),
20
$this->renderLintStatuses($viewer),
21
);
22
}
23
24
private function renderRevisionStatuses(PhabricatorUser $viewer) {
25
$statuses = DifferentialRevisionStatus::getAll();
26
27
$rows = array();
28
foreach ($statuses as $status) {
29
$icon = id(new PHUIIconView())
30
->setIcon(
31
$status->getIcon(),
32
$status->getIconColor());
33
34
$timeline_icon = $status->getTimelineIcon();
35
if ($timeline_icon !== null) {
36
$timeline_view = id(new PHUIIconView())
37
->setIcon(
38
$status->getTimelineIcon(),
39
$status->getTimelineColor());
40
} else {
41
$timeline_view = null;
42
}
43
44
if ($status->isClosedStatus()) {
45
$is_open = pht('Closed');
46
} else {
47
$is_open = pht('Open');
48
}
49
50
$tag_color = $status->getTagColor();
51
if ($tag_color !== null) {
52
$tag_view = id(new PHUIIconView())
53
->seticon('fa-tag', $tag_color);
54
} else {
55
$tag_view = null;
56
}
57
58
$ansi_color = $status->getAnsiColor();
59
if ($ansi_color !== null) {
60
$web_color = PHUIColor::getWebColorFromANSIColor($ansi_color);
61
$ansi_view = id(new PHUIIconView())
62
->setIcon('fa-stop', $web_color);
63
} else {
64
$ansi_view = null;
65
}
66
67
68
$rows[] = array(
69
$status->getKey(),
70
$status->getLegacyKey(),
71
$icon,
72
$timeline_view,
73
$tag_view,
74
$ansi_view,
75
$is_open,
76
$status->getDisplayName(),
77
);
78
}
79
80
$table = id(new AphrontTableView($rows))
81
->setHeaders(
82
array(
83
pht('Value'),
84
pht('Legacy Value'),
85
pht('Icon'),
86
pht('Timeline Icon'),
87
pht('Tag Color'),
88
pht('ANSI Color'),
89
pht('Open/Closed'),
90
pht('Name'),
91
))
92
->setColumnClasses(
93
array(
94
null,
95
null,
96
null,
97
null,
98
null,
99
null,
100
null,
101
'wide pri',
102
));
103
104
$view = id(new PHUIObjectBoxView())
105
->setHeaderText(pht('Differential Revision Statuses'))
106
->setTable($table);
107
108
return $view;
109
}
110
111
private function renderUnitStatuses(PhabricatorUser $viewer) {
112
$statuses = DifferentialUnitStatus::getStatusMap();
113
114
$rows = array();
115
foreach ($statuses as $status) {
116
$rows[] = array(
117
$status->getValue(),
118
id(new PHUIIconView())
119
->setIcon($status->getIconIcon(), $status->getIconColor()),
120
$status->getName(),
121
);
122
}
123
124
$table = id(new AphrontTableView($rows))
125
->setHeaders(
126
array(
127
pht('Value'),
128
pht('Icon'),
129
pht('Name'),
130
))
131
->setColumnClasses(
132
array(
133
null,
134
null,
135
'wide pri',
136
));
137
138
$view = id(new PHUIObjectBoxView())
139
->setHeaderText(pht('Differential Unit Statuses'))
140
->setTable($table);
141
142
return $view;
143
}
144
145
private function renderLintStatuses(PhabricatorUser $viewer) {
146
$statuses = DifferentialLintStatus::getStatusMap();
147
148
$rows = array();
149
foreach ($statuses as $status) {
150
$rows[] = array(
151
$status->getValue(),
152
id(new PHUIIconView())
153
->setIcon($status->getIconIcon(), $status->getIconColor()),
154
$status->getName(),
155
);
156
}
157
158
$table = id(new AphrontTableView($rows))
159
->setHeaders(
160
array(
161
pht('Value'),
162
pht('Icon'),
163
pht('Name'),
164
))
165
->setColumnClasses(
166
array(
167
null,
168
null,
169
'wide pri',
170
));
171
172
$view = id(new PHUIObjectBoxView())
173
->setHeaderText(pht('Differential Lint Statuses'))
174
->setTable($table);
175
176
return $view;
177
}
178
179
180
}
181
182