Differential D16417 Diff 39574 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 133 Lines • ▼ Show 20 Lines | foreach ($data as $row) { | ||||
if ($row['age']) { | if ($row['age']) { | ||||
$age = phabricator_datetime($row['age'], $this->getUser()); | $age = phabricator_datetime($row['age'], $this->getUser()); | ||||
} else { | } else { | ||||
$age = null; | $age = null; | ||||
} | } | ||||
if ($diff) { | if ($diff) { | ||||
$lint = self::renderDiffLintStar($row['obj']); | $lint_status = $diff->getSummaryLintStatus(); | ||||
$unit_status = $diff->getSummaryUnitStatus(); | |||||
$lint = self::renderDiffLintStar($lint_status); | |||||
$lint = phutil_tag( | $lint = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'lintunit-star', | 'class' => 'lintunit-star', | ||||
'title' => self::getDiffLintMessage($diff), | 'title' => self::getDiffLintMessage($lint_status), | ||||
), | ), | ||||
$lint); | $lint); | ||||
$unit = self::renderDiffUnitStar($row['obj']); | $unit = self::renderDiffUnitStar($unit_status); | ||||
$unit = phutil_tag( | $unit = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'lintunit-star', | 'class' => 'lintunit-star', | ||||
'title' => self::getDiffUnitMessage($diff), | 'title' => self::getDiffUnitMessage($unit_status), | ||||
), | ), | ||||
$unit); | $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 142 Lines • ▼ Show 20 Lines | final class DifferentialRevisionUpdateHistoryView extends AphrontView { | ||||
} | } | ||||
const STAR_NONE = 'none'; | const STAR_NONE = 'none'; | ||||
const STAR_OKAY = 'okay'; | const STAR_OKAY = 'okay'; | ||||
const STAR_WARN = 'warn'; | const STAR_WARN = 'warn'; | ||||
const STAR_FAIL = 'fail'; | const STAR_FAIL = 'fail'; | ||||
const STAR_SKIP = 'skip'; | const STAR_SKIP = 'skip'; | ||||
public static function renderDiffLintStar(DifferentialDiff $diff) { | private static function renderDiffLintStar($status) { | ||||
static $map = array( | static $map = array( | ||||
DifferentialLintStatus::LINT_NONE => self::STAR_NONE, | DifferentialLintStatus::LINT_NONE => self::STAR_NONE, | ||||
DifferentialLintStatus::LINT_OKAY => self::STAR_OKAY, | DifferentialLintStatus::LINT_OKAY => self::STAR_OKAY, | ||||
DifferentialLintStatus::LINT_WARN => self::STAR_WARN, | DifferentialLintStatus::LINT_WARN => self::STAR_WARN, | ||||
DifferentialLintStatus::LINT_FAIL => self::STAR_FAIL, | DifferentialLintStatus::LINT_FAIL => self::STAR_FAIL, | ||||
DifferentialLintStatus::LINT_SKIP => self::STAR_SKIP, | DifferentialLintStatus::LINT_SKIP => self::STAR_SKIP, | ||||
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, $status, self::STAR_FAIL); | ||||
return self::renderDiffStar($star); | return self::renderDiffStar($star); | ||||
} | } | ||||
public static function renderDiffUnitStar(DifferentialDiff $diff) { | private static function renderDiffUnitStar($unit_status) { | ||||
static $map = array( | static $map = array( | ||||
DifferentialUnitStatus::UNIT_NONE => self::STAR_NONE, | DifferentialUnitStatus::UNIT_NONE => self::STAR_NONE, | ||||
DifferentialUnitStatus::UNIT_OKAY => self::STAR_OKAY, | DifferentialUnitStatus::UNIT_OKAY => self::STAR_OKAY, | ||||
DifferentialUnitStatus::UNIT_WARN => self::STAR_WARN, | DifferentialUnitStatus::UNIT_WARN => self::STAR_WARN, | ||||
DifferentialUnitStatus::UNIT_FAIL => self::STAR_FAIL, | DifferentialUnitStatus::UNIT_FAIL => self::STAR_FAIL, | ||||
DifferentialUnitStatus::UNIT_SKIP => self::STAR_SKIP, | DifferentialUnitStatus::UNIT_SKIP => self::STAR_SKIP, | ||||
DifferentialUnitStatus::UNIT_AUTO_SKIP => self::STAR_SKIP, | DifferentialUnitStatus::UNIT_AUTO_SKIP => self::STAR_SKIP, | ||||
); | ); | ||||
$star = idx($map, $diff->getUnitStatus(), self::STAR_FAIL); | |||||
$star = idx($map, $unit_status, self::STAR_FAIL); | |||||
return self::renderDiffStar($star); | return self::renderDiffStar($star); | ||||
} | } | ||||
public static function getDiffLintMessage(DifferentialDiff $diff) { | public static function getDiffLintMessage($status) { | ||||
switch ($diff->getLintStatus()) { | switch ($status) { | ||||
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(DifferentialDiff $diff) { | public static function getDiffUnitMessage($status) { | ||||
switch ($diff->getUnitStatus()) { | switch ($status) { | ||||
case DifferentialUnitStatus::UNIT_NONE: | case DifferentialUnitStatus::UNIT_NONE: | ||||
return pht('No Unit Test Coverage'); | return pht('No Unit Test Coverage'); | ||||
case DifferentialUnitStatus::UNIT_OKAY: | case DifferentialUnitStatus::UNIT_OKAY: | ||||
return pht('Unit Tests OK'); | return pht('Unit Tests OK'); | ||||
case DifferentialUnitStatus::UNIT_WARN: | case DifferentialUnitStatus::UNIT_WARN: | ||||
return pht('Unit Test Warnings'); | return pht('Unit Test Warnings'); | ||||
case DifferentialUnitStatus::UNIT_FAIL: | case DifferentialUnitStatus::UNIT_FAIL: | ||||
return pht('Unit Test Errors'); | return pht('Unit Test Errors'); | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |