@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Replace Differential "lint stars" with icons

Summary:
Ref T9764. These stars are inconsistent, not accessible, and generally weird. They predate icons.

Update them to use icons instead.

Test Plan:
{F8545721}

{F8545722}

{F8545723}

Maniphest Tasks: T9764

Differential Revision: https://secure.phabricator.com/D21640

+168 -107
+3 -3
resources/celerity/map.php
··· 12 12 'core.pkg.css' => '0ae696de', 13 13 'core.pkg.js' => 'ab3502fe', 14 14 'dark-console.pkg.js' => '187792c2', 15 - 'differential.pkg.css' => '5c459f92', 15 + 'differential.pkg.css' => 'ffb69e3d', 16 16 'differential.pkg.js' => '5080baf4', 17 17 'diffusion.pkg.css' => '42c75c37', 18 18 'diffusion.pkg.js' => '78c9885d', ··· 67 67 'rsrc/css/application/differential/core.css' => '7300a73e', 68 68 'rsrc/css/application/differential/phui-inline-comment.css' => '9863a85e', 69 69 'rsrc/css/application/differential/revision-comment.css' => '7dbc8d1d', 70 - 'rsrc/css/application/differential/revision-history.css' => '8aa3eac5', 70 + 'rsrc/css/application/differential/revision-history.css' => '237a2979', 71 71 'rsrc/css/application/differential/revision-list.css' => '93d2df7d', 72 72 'rsrc/css/application/differential/table-of-contents.css' => 'bba788b9', 73 73 'rsrc/css/application/diffusion/diffusion-icons.css' => '23b31a1b', ··· 569 569 'differential-core-view-css' => '7300a73e', 570 570 'differential-revision-add-comment-css' => '7e5900d9', 571 571 'differential-revision-comment-css' => '7dbc8d1d', 572 - 'differential-revision-history-css' => '8aa3eac5', 572 + 'differential-revision-history-css' => '237a2979', 573 573 'differential-revision-list-css' => '93d2df7d', 574 574 'differential-table-of-contents-css' => 'bba788b9', 575 575 'diffusion-css' => 'e46232d6',
+36
src/applications/differential/constants/DifferentialConstantsModule.php
··· 17 17 return array( 18 18 $this->renderRevisionStatuses($viewer), 19 19 $this->renderUnitStatuses($viewer), 20 + $this->renderLintStatuses($viewer), 20 21 ); 21 22 } 22 23 ··· 140 141 141 142 return $view; 142 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 + 143 179 144 180 }
+81
src/applications/differential/constants/DifferentialLintStatus.php
··· 9 9 const LINT_SKIP = 4; 10 10 const LINT_AUTO_SKIP = 6; 11 11 12 + private $value; 13 + 14 + public static function newStatusFromValue($value) { 15 + $status = new self(); 16 + $status->value = $value; 17 + return $status; 18 + } 19 + 20 + public function getValue() { 21 + return $this->value; 22 + } 23 + 24 + public function getName() { 25 + $name = $this->getLintStatusProperty('name'); 26 + 27 + if ($name === null) { 28 + $name = pht('Unknown Lint Status ("%s")', $this->getValue()); 29 + } 30 + 31 + return $name; 32 + } 33 + 34 + public function getIconIcon() { 35 + return $this->getLintStatusProperty('icon.icon'); 36 + } 37 + 38 + public function getIconColor() { 39 + return $this->getLintStatusProperty('icon.color'); 40 + } 41 + 42 + public static function getStatusMap() { 43 + $results = array(); 44 + 45 + foreach (self::newLintStatusMap() as $value => $ignored) { 46 + $results[$value] = self::newStatusFromValue($value); 47 + } 48 + 49 + return $results; 50 + } 51 + 52 + private function getLintStatusProperty($key, $default = null) { 53 + $map = self::newLintStatusMap(); 54 + $properties = idx($map, $this->getValue(), array()); 55 + return idx($properties, $key, $default); 56 + } 57 + 58 + private static function newLintStatusMap() { 59 + return array( 60 + self::LINT_NONE => array( 61 + 'name' => pht('No Lint Coverage'), 62 + 'icon.icon' => 'fa-ban', 63 + 'icon.color' => 'grey', 64 + ), 65 + self::LINT_OKAY => array( 66 + 'name' => pht('Lint Passed'), 67 + 'icon.icon' => 'fa-check', 68 + 'icon.color' => 'green', 69 + ), 70 + self::LINT_WARN => array( 71 + 'name' => pht('Lint Warnings'), 72 + 'icon.icon' => 'fa-exclamation-triangle', 73 + 'icon.color' => 'yellow', 74 + ), 75 + self::LINT_FAIL => array( 76 + 'name' => pht('Lint Errors'), 77 + 'icon.icon' => 'fa-times', 78 + 'icon.color' => 'red', 79 + ), 80 + self::LINT_SKIP => array( 81 + 'name' => pht('Lint Skipped'), 82 + 'icon.icon' => 'fa-fast-forward', 83 + 'icon.color' => 'blue', 84 + ), 85 + self::LINT_AUTO_SKIP => array( 86 + 'name' => pht('Lint Not Applicable'), 87 + 'icon.icon' => 'fa-code', 88 + 'icon.color' => 'grey', 89 + ), 90 + ); 91 + } 92 + 12 93 }
+1 -1
src/applications/differential/constants/DifferentialUnitStatus.php
··· 84 84 ), 85 85 self::UNIT_AUTO_SKIP => array( 86 86 'name' => pht('Tests Not Applicable'), 87 - 'icon.icon' => 'fa-upload', 87 + 'icon.icon' => 'fa-code', 88 88 'icon.color' => 'grey', 89 89 ), 90 90 );
+7 -23
src/applications/differential/customfield/DifferentialLintField.php
··· 38 38 protected function getDiffPropertyKeys() { 39 39 return array( 40 40 'arc:lint', 41 - 'arc:lint-excuse', 42 41 ); 43 42 } 44 43 ··· 84 83 DifferentialDiff $diff, 85 84 array $messages) { 86 85 87 - $colors = array( 88 - DifferentialLintStatus::LINT_NONE => 'grey', 89 - DifferentialLintStatus::LINT_OKAY => 'green', 90 - DifferentialLintStatus::LINT_WARN => 'yellow', 91 - DifferentialLintStatus::LINT_FAIL => 'red', 92 - DifferentialLintStatus::LINT_SKIP => 'blue', 93 - DifferentialLintStatus::LINT_AUTO_SKIP => 'blue', 94 - ); 95 - $icon_color = idx($colors, $diff->getLintStatus(), 'grey'); 86 + $status_value = $diff->getLintStatus(); 87 + $status = DifferentialLintStatus::newStatusFromValue($status_value); 96 88 97 - $message = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff); 98 - 99 - $excuse = $diff->getProperty('arc:lint-excuse'); 100 - if (strlen($excuse)) { 101 - $excuse = array( 102 - phutil_tag('strong', array(), pht('Excuse:')), 103 - ' ', 104 - phutil_escape_html_newlines($excuse), 105 - ); 106 - } 89 + $status_icon = $status->getIconIcon(); 90 + $status_color = $status->getIconColor(); 91 + $status_name = $status->getName(); 107 92 108 93 $status = id(new PHUIStatusListView()) 109 94 ->addItem( 110 95 id(new PHUIStatusItemView()) 111 - ->setIcon(PHUIStatusItemView::ICON_STAR, $icon_color) 112 - ->setTarget($message) 113 - ->setNote($excuse)); 96 + ->setIcon($status_icon, $status_color) 97 + ->setTarget($status_name)); 114 98 115 99 return $status; 116 100 }
+40 -75
src/applications/differential/view/DifferentialRevisionUpdateHistoryView.php
··· 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 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 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 }
-5
webroot/rsrc/css/application/differential/revision-history.css
··· 54 54 td.differential-update-history-new { 55 55 background: #aaffaa; 56 56 } 57 - 58 - .lintunit-star { 59 - text-align: center; 60 - padding: 0 16px; 61 - }