Differential D21639 Diff 51501 src/applications/differential/view/DifferentialRevisionUpdateHistoryView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/view/DifferentialRevisionUpdateHistoryView.php
Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | foreach ($data as $row) { | ||||
$lint = phutil_tag( | $lint = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'lintunit-star', | 'class' => 'lintunit-star', | ||||
'title' => self::getDiffLintMessage($diff), | 'title' => self::getDiffLintMessage($diff), | ||||
), | ), | ||||
$lint); | $lint); | ||||
$unit = self::renderDiffUnitStar($unit_status); | $status = DifferentialUnitStatus::newStatusFromValue($unit_status); | ||||
$unit = phutil_tag( | |||||
'div', | $unit_icon = $status->getIconIcon(); | ||||
$unit_color = $status->getIconColor(); | |||||
$unit_name = $status->getName(); | |||||
$unit = id(new PHUIIconView()) | |||||
->setIcon($unit_icon, $unit_color) | |||||
->addSigil('has-tooltip') | |||||
->setMetadata( | |||||
array( | array( | ||||
'class' => 'lintunit-star', | 'tip' => $unit_name, | ||||
'title' => self::getDiffUnitMessage($unit_status), | )); | ||||
), | |||||
$unit); | |||||
$base = $this->renderBaseRevision($diff); | $base = $this->renderBaseRevision($diff); | ||||
} else { | } else { | ||||
$lint = null; | $lint = null; | ||||
$unit = null; | $unit = null; | ||||
$base = null; | $base = null; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | static $map = array( | ||||
DifferentialLintStatus::LINT_AUTO_SKIP => self::STAR_SKIP, | DifferentialLintStatus::LINT_AUTO_SKIP => self::STAR_SKIP, | ||||
); | ); | ||||
$star = idx($map, $diff->getLintStatus(), self::STAR_FAIL); | $star = idx($map, $diff->getLintStatus(), self::STAR_FAIL); | ||||
return self::renderDiffStar($star); | return self::renderDiffStar($star); | ||||
} | } | ||||
private static function renderDiffUnitStar($unit_status) { | |||||
static $map = array( | |||||
DifferentialUnitStatus::UNIT_NONE => self::STAR_NONE, | |||||
DifferentialUnitStatus::UNIT_OKAY => self::STAR_OKAY, | |||||
DifferentialUnitStatus::UNIT_WARN => self::STAR_WARN, | |||||
DifferentialUnitStatus::UNIT_FAIL => self::STAR_FAIL, | |||||
DifferentialUnitStatus::UNIT_SKIP => self::STAR_SKIP, | |||||
DifferentialUnitStatus::UNIT_AUTO_SKIP => self::STAR_SKIP, | |||||
); | |||||
$star = idx($map, $unit_status, self::STAR_FAIL); | |||||
return self::renderDiffStar($star); | |||||
} | |||||
public static function getDiffLintMessage(DifferentialDiff $diff) { | public static function getDiffLintMessage(DifferentialDiff $diff) { | ||||
switch ($diff->getLintStatus()) { | switch ($diff->getLintStatus()) { | ||||
case DifferentialLintStatus::LINT_NONE: | case DifferentialLintStatus::LINT_NONE: | ||||
return pht('No Linters Available'); | return pht('No Linters Available'); | ||||
case DifferentialLintStatus::LINT_OKAY: | case DifferentialLintStatus::LINT_OKAY: | ||||
return pht('Lint OK'); | return pht('Lint OK'); | ||||
case DifferentialLintStatus::LINT_WARN: | case DifferentialLintStatus::LINT_WARN: | ||||
return pht('Lint Warnings'); | return pht('Lint Warnings'); | ||||
case DifferentialLintStatus::LINT_FAIL: | case DifferentialLintStatus::LINT_FAIL: | ||||
return pht('Lint Errors'); | return pht('Lint Errors'); | ||||
case DifferentialLintStatus::LINT_SKIP: | case DifferentialLintStatus::LINT_SKIP: | ||||
return pht('Lint Skipped'); | return pht('Lint Skipped'); | ||||
case DifferentialLintStatus::LINT_AUTO_SKIP: | case DifferentialLintStatus::LINT_AUTO_SKIP: | ||||
return pht('Automatic diff as part of commit; lint not applicable.'); | return pht('Automatic diff as part of commit; lint not applicable.'); | ||||
} | } | ||||
return pht('Unknown'); | return pht('Unknown'); | ||||
} | } | ||||
public static function getDiffUnitMessage($unit_status) { | |||||
switch ($unit_status) { | |||||
case DifferentialUnitStatus::UNIT_NONE: | |||||
return pht('No Unit Test Coverage'); | |||||
case DifferentialUnitStatus::UNIT_OKAY: | |||||
return pht('Unit Tests OK'); | |||||
case DifferentialUnitStatus::UNIT_WARN: | |||||
return pht('Unit Test Warnings'); | |||||
case DifferentialUnitStatus::UNIT_FAIL: | |||||
return pht('Unit Test Errors'); | |||||
case DifferentialUnitStatus::UNIT_SKIP: | |||||
return pht('Unit Tests Skipped'); | |||||
case DifferentialUnitStatus::UNIT_AUTO_SKIP: | |||||
return pht( | |||||
'Automatic diff as part of commit; unit tests not applicable.'); | |||||
} | |||||
return pht('Unknown'); | |||||
} | |||||
private static function renderDiffStar($star) { | private static function renderDiffStar($star) { | ||||
$class = 'diff-star-'.$star; | $class = 'diff-star-'.$star; | ||||
return phutil_tag( | return phutil_tag( | ||||
'span', | 'span', | ||||
array('class' => $class), | array('class' => $class), | ||||
"\xE2\x98\x85"); | "\xE2\x98\x85"); | ||||
} | } | ||||
Show All 40 Lines |