@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add Success/Fail states to PHUIObjectList

Summary:
A number of interfaces could use a more consice looking ObjectItemList for showing pass/fail/warn states.

- Added a new "State" for PHUIObjectItemListView
- Updated UIExamples
- Implemented in Herald (next Harmormaster)

Test Plan: UIExamples / Herald, desktop and mobile

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

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

+163 -44
+5 -5
resources/celerity/map.php
··· 7 7 return array( 8 8 'names' => 9 9 array( 10 - 'core.pkg.css' => 'b39b2afb', 10 + 'core.pkg.css' => 'a762d94d', 11 11 'core.pkg.js' => '417722ff', 12 12 'darkconsole.pkg.js' => 'ca8671ce', 13 13 'differential.pkg.css' => '8a064eb7', ··· 106 106 'rsrc/css/application/tokens/tokens.css' => '5f7bca25', 107 107 'rsrc/css/application/uiexample/example.css' => '528b19de', 108 108 'rsrc/css/core/core.css' => 'da26ddb2', 109 - 'rsrc/css/core/remarkup.css' => 'f27ecac4', 109 + 'rsrc/css/core/remarkup.css' => '98a7627b', 110 110 'rsrc/css/core/syntax.css' => '3c18c1cb', 111 111 'rsrc/css/core/z-index.css' => '0d89d53c', 112 112 'rsrc/css/diviner/diviner-shared.css' => '38813222', ··· 137 137 'rsrc/css/phui/phui-info-panel.css' => '27ea50a1', 138 138 'rsrc/css/phui/phui-list.css' => 'ef8035b6', 139 139 'rsrc/css/phui/phui-object-box.css' => 'ce92d8ec', 140 - 'rsrc/css/phui/phui-object-item-list-view.css' => '8b459abe', 140 + 'rsrc/css/phui/phui-object-item-list-view.css' => 'c11ec980', 141 141 'rsrc/css/phui/phui-pinboard-view.css' => '4b346c2a', 142 142 'rsrc/css/phui/phui-property-list-view.css' => 'c4d44192', 143 143 'rsrc/css/phui/phui-remarkup-preview.css' => '19ad512b', ··· 711 711 'phabricator-prefab' => '0326e5d0', 712 712 'phabricator-profile-css' => '33e6f703', 713 713 'phabricator-project-tag-css' => '095c9404', 714 - 'phabricator-remarkup-css' => 'f27ecac4', 714 + 'phabricator-remarkup-css' => '98a7627b', 715 715 'phabricator-search-results-css' => 'f240504c', 716 716 'phabricator-settings-css' => 'ea8f5915', 717 717 'phabricator-shaped-request' => 'dfa181a4', ··· 759 759 'phui-info-panel-css' => '27ea50a1', 760 760 'phui-list-view-css' => 'ef8035b6', 761 761 'phui-object-box-css' => 'ce92d8ec', 762 - 'phui-object-item-list-view-css' => '8b459abe', 762 + 'phui-object-item-list-view-css' => 'c11ec980', 763 763 'phui-pinboard-view-css' => '4b346c2a', 764 764 'phui-property-list-view-css' => 'c4d44192', 765 765 'phui-remarkup-preview-css' => '19ad512b',
+18 -37
src/applications/herald/controller/HeraldTranscriptController.php
··· 294 294 $rule_type_global = HeraldRuleTypeConfig::RULE_TYPE_GLOBAL; 295 295 $action_names = $adapter->getActionNameMap($rule_type_global); 296 296 297 - $rows = array(); 297 + $list = new PHUIObjectItemListView(); 298 + $list->setStates(true); 299 + $list->setNoDataString(pht('No actions were taken.')); 298 300 foreach ($xscript->getApplyTranscripts() as $apply_xscript) { 299 301 300 302 $target = $apply_xscript->getTarget(); 301 303 switch ($apply_xscript->getAction()) { 302 304 case HeraldAdapter::ACTION_NOTHING: 303 - $target = ''; 305 + $target = null; 304 306 break; 305 307 case HeraldAdapter::ACTION_FLAG: 306 308 $target = PhabricatorFlagColor::getColorName($target); ··· 316 318 $target[$k] = $handles[$phid]->getName(); 317 319 } 318 320 } 319 - $target = implode("\n", $target); 321 + $target = implode(", ", $target); 320 322 } else { 321 323 $target = '<empty>'; 322 324 } 323 325 break; 324 326 } 325 327 328 + $item = new PHUIObjectItemView(); 329 + 326 330 if ($apply_xscript->getApplied()) { 327 - $outcome = phutil_tag( 328 - 'span', 329 - array('class' => 'outcome-success'), 330 - pht('SUCCESS')); 331 + $item->setState(PHUIObjectItemView::STATE_SUCCESS); 331 332 } else { 332 - $outcome = phutil_tag( 333 - 'span', 334 - array('class' => 'outcome-failure'), 335 - pht('FAILURE')); 333 + $item->setState(PHUIObjectItemView::STATE_FAIL); 336 334 } 337 335 338 - $rows[] = array( 339 - idx($action_names, $apply_xscript->getAction(), pht('Unknown')), 340 - $target, 341 - hsprintf( 342 - '<strong>Taken because:</strong> %s<br />'. 343 - '<strong>Outcome:</strong> %s %s', 344 - $apply_xscript->getReason(), 345 - $outcome, 346 - $apply_xscript->getAppliedReason()), 347 - ); 336 + $rule = idx($action_names, $apply_xscript->getAction(), pht('Unknown')); 337 + 338 + $item->setHeader(pht('%s: %s', $rule, $target)); 339 + $item->addAttribute($apply_xscript->getReason()); 340 + $item->addAttribute( 341 + pht('Outcome: %s', $apply_xscript->getAppliedReason())); 342 + 343 + $list->addItem($item); 348 344 } 349 345 350 - $table = new AphrontTableView($rows); 351 - $table->setNoDataString(pht('No actions were taken.')); 352 - $table->setHeaders( 353 - array( 354 - pht('Action'), 355 - pht('Target'), 356 - pht('Details'), 357 - )); 358 - $table->setColumnClasses( 359 - array( 360 - '', 361 - '', 362 - 'wide', 363 - )); 364 - 365 346 $box = new PHUIObjectBoxView(); 366 347 $box->setHeaderText(pht('Actions Taken')); 367 - $box->appendChild($table); 348 + $box->appendChild($list); 368 349 369 350 return $box; 370 351 }
+2 -1
src/applications/uiexample/controller/PhabricatorUIExampleRenderController.php
··· 45 45 46 46 $header = id(new PHUIHeaderView()) 47 47 ->setHeader(pht('%s (%s)', $example->getName(), get_class($example))) 48 - ->setSubheader($example->getDescription()); 48 + ->setSubheader($example->getDescription()) 49 + ->setNoBackground(true); 49 50 50 51 $nav->appendChild( 51 52 array(
+44
src/applications/uiexample/examples/PHUIObjectItemListExample.php
··· 360 360 361 361 $out[] = array($head, $list); 362 362 363 + $head = id(new PHUIHeaderView()) 364 + ->setHeader(pht('States')); 365 + 366 + $list = id(new PHUIObjectItemListView()) 367 + ->setStates(true); 368 + 369 + $list->addItem( 370 + id(new PHUIObjectItemView()) 371 + ->setObjectName('X1200') 372 + ->setHeader(pht('Action Passed')) 373 + ->addAttribute(pht('That went swimmingly, go you')) 374 + ->setHref('#') 375 + ->setState(PHUIObjectItemView::STATE_SUCCESS)); 376 + 377 + $list->addItem( 378 + id(new PHUIObjectItemView()) 379 + ->setObjectName('X1201') 380 + ->setHeader(pht('Action Failed')) 381 + ->addAttribute(pht('Whoopsies, might want to fix that')) 382 + ->setHref('#') 383 + ->setState(PHUIObjectItemView::STATE_FAIL)); 384 + 385 + $list->addItem( 386 + id(new PHUIObjectItemView()) 387 + ->setObjectName('X1202') 388 + ->setHeader(pht('Action Warning')) 389 + ->addAttribute(pht('We need to talk about things')) 390 + ->setHref('#') 391 + ->setState(PHUIObjectItemView::STATE_WARN)); 392 + 393 + $list->addItem( 394 + id(new PHUIObjectItemView()) 395 + ->setObjectName('X1203') 396 + ->setHeader(pht('Action Noted')) 397 + ->addAttribute(pht('The weather seems nice today')) 398 + ->setHref('#') 399 + ->setState(PHUIObjectItemView::STATE_NOTE)); 400 + 401 + $box = id(new PHUIObjectBoxView()) 402 + ->setHeaderText('Test Things') 403 + ->appendChild($list); 404 + 405 + $out[] = array($head, $box); 406 + 363 407 return $out; 364 408 } 365 409 }
+9
src/view/phui/PHUIObjectItemListView.php
··· 11 11 private $flush; 12 12 private $plain; 13 13 private $allowEmptyList; 14 + private $states; 14 15 15 16 16 17 public function setAllowEmptyList($allow_empty_list) { ··· 62 63 return $this; 63 64 } 64 65 66 + public function setStates($states) { 67 + $this->states = $states; 68 + return $this; 69 + } 70 + 65 71 protected function getTagName() { 66 72 return 'ul'; 67 73 } ··· 75 81 } 76 82 if ($this->cards) { 77 83 $classes[] = 'phui-object-list-cards'; 84 + } 85 + if ($this->states) { 86 + $classes[] = 'phui-object-list-states'; 78 87 } 79 88 if ($this->flush) { 80 89 $classes[] = 'phui-object-list-flush';
+47 -1
src/view/phui/PHUIObjectItemView.php
··· 19 19 private $headIcons = array(); 20 20 private $disabled; 21 21 private $imageURI; 22 + private $state; 23 + private $fontIcon; 22 24 23 25 const AGE_FRESH = 'fresh'; 24 26 const AGE_STALE = 'stale'; 25 27 const AGE_OLD = 'old'; 28 + 29 + const STATE_SUCCESS = 'green'; 30 + const STATE_FAIL = 'red'; 31 + const STATE_WARN = 'yellow'; 32 + const STATE_NOTE = 'blue'; 26 33 27 34 public function setDisabled($disabled) { 28 35 $this->disabled = $disabled; ··· 107 114 return $this->imageURI; 108 115 } 109 116 117 + public function setState($state) { 118 + $this->state = $state; 119 + switch ($state) { 120 + case self::STATE_SUCCESS: 121 + $fi = 'fa-check-circle green'; 122 + break; 123 + case self::STATE_FAIL: 124 + $fi = 'fa-times-circle red'; 125 + break; 126 + case self::STATE_WARN: 127 + $fi = 'fa-exclamation-circle yellow'; 128 + break; 129 + case self::STATE_NOTE: 130 + $fi = 'fa-info-circle blue'; 131 + break; 132 + } 133 + $this->fontIcon = id(new PHUIIconView()) 134 + ->setIconFont($fi.' fa-2x'); 135 + return $this; 136 + } 137 + 110 138 public function setEpoch($epoch, $age = self::AGE_FRESH) { 111 139 $date = phabricator_datetime($epoch, $this->getUser()); 112 140 ··· 234 262 $item_classes[] = 'phui-object-item-disabled'; 235 263 } 236 264 265 + if ($this->state) { 266 + $item_classes[] = 'phui-object-item-state-'.$this->state; 267 + } 268 + 237 269 switch ($this->effect) { 238 270 case 'highlighted': 239 271 $item_classes[] = 'phui-object-item-highlighted'; ··· 251 283 $item_classes[] = 'phui-object-item-grippable'; 252 284 } 253 285 254 - if ($this->getImageuRI()) { 286 + if ($this->getImageURI()) { 255 287 $item_classes[] = 'phui-object-item-with-image'; 288 + } 289 + 290 + if ($this->fontIcon) { 291 + $item_classes[] = 'phui-object-item-with-ficon'; 256 292 } 257 293 258 294 return array( ··· 492 528 'style' => 'background-image: url('.$this->getImageURI().')', 493 529 ), 494 530 ''); 531 + } 532 + 533 + $ficon = null; 534 + if ($this->fontIcon) { 535 + $image = phutil_tag( 536 + 'div', 537 + array( 538 + 'class' => 'phui-object-item-ficon', 539 + ), 540 + $this->fontIcon); 495 541 } 496 542 497 543 $box = phutil_tag(
+38
webroot/rsrc/css/phui/phui-object-item-list-view.css
··· 598 598 .phui-object-item-with-image .phui-object-item-content-box { 599 599 margin-left: 54px; 600 600 } 601 + 602 + /* - State --------------------------------------------------------------------- 603 + 604 + Provides a list of object status or states, success or fail, etc 605 + 606 + */ 607 + 608 + .phui-object-item-ficon { 609 + width: 26px; 610 + height: 26px; 611 + margin: 7px 9px 7px 0; 612 + position: absolute; 613 + } 614 + 615 + .phui-object-item-with-ficon .phui-object-item-content-box { 616 + margin-left: 24px; 617 + } 618 + 619 + .phui-object-box .phui-object-list-states { 620 + padding: 8px 12px 0 12px; 621 + } 622 + 623 + .phui-object-box .phui-object-list-states li:last-child .phui-object-item-frame { 624 + border: none; 625 + } 626 + 627 + .phui-object-list-states .phui-object-item-frame { 628 + border: none; 629 + border-bottom: 1px solid {$thinblueborder}; 630 + } 631 + 632 + .phui-object-list-states .phui-object-item { 633 + border: none; 634 + } 635 + 636 + .phui-object-list-states .phui-object-item-frame { 637 + min-height: 44px; 638 + }