@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.

Truncate package names in diff table of contents views

Summary:
Ref T13151. See PHI654. Depends on D19477. If you have long package names, the table of contents (e.g., in Differential) can end up expanding to be gigantic.

Getting tables to behave nicely is hard (or, at least, I can't figure it out after spending a decent amount of time on it; see also `AphrontTableView::renderSingleDisplayLine()`). I tried a bunch of things and Googled for a bit but didn't make any progress on finding a CSS solution. Just truncate the package names to get reasonable behavior without falling down any kind of CSS rabbit hole.

Test Plan:
- Created a package named "Very long package name...".
- Created a package named "MMMMMMMMMMMMMMMMMMMMMM...".
- Had them own a file in a Differential revision, viewed that revision.
- Before: table is pushed out to several times the browser window width and everything is kind of a mess.
- After: package names get truncated to something reasonable.

{F5652953}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13151

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

+35 -2
+15
src/applications/phid/view/PHUIHandleListView.php
··· 14 14 private $asInline; 15 15 private $asText; 16 16 private $showStateIcons; 17 + private $glyphLimit; 17 18 18 19 public function setHandleList(PhabricatorHandleList $list) { 19 20 $this->handleList = $list; ··· 47 48 return $this->showStateIcons; 48 49 } 49 50 51 + public function setGlyphLimit($glyph_limit) { 52 + $this->glyphLimit = $glyph_limit; 53 + return $this; 54 + } 55 + 56 + public function getGlyphLimit() { 57 + return $this->glyphLimit; 58 + } 59 + 50 60 protected function getTagName() { 51 61 if ($this->getAsText()) { 52 62 return null; ··· 61 71 $list = $this->handleList; 62 72 63 73 $show_state_icons = $this->getShowStateIcons(); 74 + $glyph_limit = $this->getGlyphLimit(); 64 75 65 76 $items = array(); 66 77 foreach ($list as $handle) { ··· 70 81 71 82 if ($show_state_icons) { 72 83 $view->setShowStateIcon(true); 84 + } 85 + 86 + if ($glyph_limit) { 87 + $view->setGlyphLimit($glyph_limit); 73 88 } 74 89 75 90 $items[] = $view;
+18 -1
src/applications/phid/view/PHUIHandleView.php
··· 18 18 private $useShortName; 19 19 private $showHovercard; 20 20 private $showStateIcon; 21 + private $glyphLimit; 21 22 22 23 public function setHandleList(PhabricatorHandleList $list) { 23 24 $this->handleList = $list; ··· 58 59 return $this->showStateIcon; 59 60 } 60 61 62 + public function setGlyphLimit($glyph_limit) { 63 + $this->glyphLimit = $glyph_limit; 64 + return $this; 65 + } 66 + 67 + public function getGlyphLimit() { 68 + return $this->glyphLimit; 69 + } 70 + 61 71 public function render() { 62 72 $handle = $this->handleList[$this->handlePHID]; 63 73 ··· 78 88 if ($this->useShortName) { 79 89 $name = $handle->getName(); 80 90 } else { 81 - $name = null; 91 + $name = $handle->getLinkName(); 92 + } 93 + 94 + $glyph_limit = $this->getGlyphLimit(); 95 + if ($glyph_limit) { 96 + $name = id(new PhutilUTF8StringTruncator()) 97 + ->setMaximumGlyphs($glyph_limit) 98 + ->truncateString($name); 82 99 } 83 100 84 101 if ($this->showHovercard) {
+2 -1
src/infrastructure/diff/view/PHUIDiffTableOfContentsItemView.php
··· 294 294 $viewer = $this->getUser(); 295 295 $package_phids = mpull($packages, 'getPHID'); 296 296 297 - return $viewer->renderHandleList($package_phids); 297 + return $viewer->renderHandleList($package_phids) 298 + ->setGlyphLimit(48); 298 299 } 299 300 300 301 private function renderRename($self, $other, $arrow) {