@@ -139,34 +139,8 @@ public function render() {
139
139
}
140
140
141
141
if ($ diff ) {
142
- $ unit_status = idx (
143
- $ this ->unitStatus ,
144
- $ diff ->getPHID (),
145
- $ diff ->getUnitStatus ());
146
-
147
- $ lint = self ::renderDiffLintStar ($ row ['obj ' ]);
148
- $ lint = phutil_tag (
149
- 'div ' ,
150
- array (
151
- 'class ' => 'lintunit-star ' ,
152
- 'title ' => self ::getDiffLintMessage ($ diff ),
153
- ),
154
- $ lint );
155
-
156
- $ status = DifferentialUnitStatus::newStatusFromValue ($ unit_status );
157
-
158
- $ unit_icon = $ status ->getIconIcon ();
159
- $ unit_color = $ status ->getIconColor ();
160
- $ unit_name = $ status ->getName ();
161
-
162
- $ unit = id (new PHUIIconView ())
163
- ->setIcon ($ unit_icon , $ unit_color )
164
- ->addSigil ('has-tooltip ' )
165
- ->setMetadata (
166
- array (
167
- 'tip ' => $ unit_name ,
168
- ));
169
-
142
+ $ lint = $ this ->newLintStatusView ($ diff );
143
+ $ unit = $ this ->newUnitStatusView ($ diff );
170
144
$ base = $ this ->renderBaseRevision ($ diff );
171
145
} else {
172
146
$ lint = null ;
@@ -287,53 +261,6 @@ public function render() {
287
261
return $ content ;
288
262
}
289
263
290
- const STAR_NONE = 'none ' ;
291
- const STAR_OKAY = 'okay ' ;
292
- const STAR_WARN = 'warn ' ;
293
- const STAR_FAIL = 'fail ' ;
294
- const STAR_SKIP = 'skip ' ;
295
-
296
- private static function renderDiffLintStar (DifferentialDiff $ diff ) {
297
- static $ map = array (
298
- DifferentialLintStatus::LINT_NONE => self ::STAR_NONE ,
299
- DifferentialLintStatus::LINT_OKAY => self ::STAR_OKAY ,
300
- DifferentialLintStatus::LINT_WARN => self ::STAR_WARN ,
301
- DifferentialLintStatus::LINT_FAIL => self ::STAR_FAIL ,
302
- DifferentialLintStatus::LINT_SKIP => self ::STAR_SKIP ,
303
- DifferentialLintStatus::LINT_AUTO_SKIP => self ::STAR_SKIP ,
304
- );
305
-
306
- $ star = idx ($ map , $ diff ->getLintStatus (), self ::STAR_FAIL );
307
-
308
- return self ::renderDiffStar ($ star );
309
- }
310
-
311
- public static function getDiffLintMessage (DifferentialDiff $ diff ) {
312
- switch ($ diff ->getLintStatus ()) {
313
- case DifferentialLintStatus::LINT_NONE :
314
- return pht ('No Linters Available ' );
315
- case DifferentialLintStatus::LINT_OKAY :
316
- return pht ('Lint OK ' );
317
- case DifferentialLintStatus::LINT_WARN :
318
- return pht ('Lint Warnings ' );
319
- case DifferentialLintStatus::LINT_FAIL :
320
- return pht ('Lint Errors ' );
321
- case DifferentialLintStatus::LINT_SKIP :
322
- return pht ('Lint Skipped ' );
323
- case DifferentialLintStatus::LINT_AUTO_SKIP :
324
- return pht ('Automatic diff as part of commit; lint not applicable. ' );
325
- }
326
- return pht ('Unknown ' );
327
- }
328
-
329
- private static function renderDiffStar ($ star ) {
330
- $ class = 'diff-star- ' .$ star ;
331
- return phutil_tag (
332
- 'span ' ,
333
- array ('class ' => $ class ),
334
- "\xE2\x98\x85" );
335
- }
336
-
337
264
private function renderBaseRevision (DifferentialDiff $ diff ) {
338
265
switch ($ diff ->getSourceControlSystem ()) {
339
266
case 'git ' :
@@ -373,4 +300,42 @@ private function renderBaseRevision(DifferentialDiff $diff) {
373
300
}
374
301
return $ link ;
375
302
}
303
+
304
+ private function newLintStatusView (DifferentialDiff $ diff ) {
305
+ $ value = $ diff ->getLintStatus ();
306
+ $ status = DifferentialLintStatus::newStatusFromValue ($ value );
307
+
308
+ $ icon = $ status ->getIconIcon ();
309
+ $ color = $ status ->getIconColor ();
310
+ $ name = $ status ->getName ();
311
+
312
+ return $ this ->newDiffStatusIconView ($ icon , $ color , $ name );
313
+ }
314
+
315
+ private function newUnitStatusView (DifferentialDiff $ diff ) {
316
+ $ value = $ diff ->getUnitStatus ();
317
+
318
+ // NOTE: We may be overriding the value on the diff with a value from
319
+ // Harbormaster.
320
+ $ value = idx ($ this ->unitStatus , $ diff ->getPHID (), $ value );
321
+
322
+ $ status = DifferentialUnitStatus::newStatusFromValue ($ value );
323
+
324
+ $ icon = $ status ->getIconIcon ();
325
+ $ color = $ status ->getIconColor ();
326
+ $ name = $ status ->getName ();
327
+
328
+ return $ this ->newDiffStatusIconView ($ icon , $ color , $ name );
329
+ }
330
+
331
+ private function newDiffStatusIconView ($ icon , $ color , $ name ) {
332
+ return id (new PHUIIconView ())
333
+ ->setIcon ($ icon , $ color )
334
+ ->addSigil ('has-tooltip ' )
335
+ ->setMetadata (
336
+ array (
337
+ 'tip ' => $ name ,
338
+ ));
339
+ }
340
+
376
341
}
0 commit comments