mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 10:12:41 +01:00
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
This commit is contained in:
parent
2951e0c86b
commit
7acda7e94e
3 changed files with 35 additions and 2 deletions
|
@ -14,6 +14,7 @@ final class PHUIHandleListView
|
|||
private $asInline;
|
||||
private $asText;
|
||||
private $showStateIcons;
|
||||
private $glyphLimit;
|
||||
|
||||
public function setHandleList(PhabricatorHandleList $list) {
|
||||
$this->handleList = $list;
|
||||
|
@ -47,6 +48,15 @@ final class PHUIHandleListView
|
|||
return $this->showStateIcons;
|
||||
}
|
||||
|
||||
public function setGlyphLimit($glyph_limit) {
|
||||
$this->glyphLimit = $glyph_limit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGlyphLimit() {
|
||||
return $this->glyphLimit;
|
||||
}
|
||||
|
||||
protected function getTagName() {
|
||||
if ($this->getAsText()) {
|
||||
return null;
|
||||
|
@ -61,6 +71,7 @@ final class PHUIHandleListView
|
|||
$list = $this->handleList;
|
||||
|
||||
$show_state_icons = $this->getShowStateIcons();
|
||||
$glyph_limit = $this->getGlyphLimit();
|
||||
|
||||
$items = array();
|
||||
foreach ($list as $handle) {
|
||||
|
@ -72,6 +83,10 @@ final class PHUIHandleListView
|
|||
$view->setShowStateIcon(true);
|
||||
}
|
||||
|
||||
if ($glyph_limit) {
|
||||
$view->setGlyphLimit($glyph_limit);
|
||||
}
|
||||
|
||||
$items[] = $view;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ final class PHUIHandleView
|
|||
private $useShortName;
|
||||
private $showHovercard;
|
||||
private $showStateIcon;
|
||||
private $glyphLimit;
|
||||
|
||||
public function setHandleList(PhabricatorHandleList $list) {
|
||||
$this->handleList = $list;
|
||||
|
@ -58,6 +59,15 @@ final class PHUIHandleView
|
|||
return $this->showStateIcon;
|
||||
}
|
||||
|
||||
public function setGlyphLimit($glyph_limit) {
|
||||
$this->glyphLimit = $glyph_limit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGlyphLimit() {
|
||||
return $this->glyphLimit;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$handle = $this->handleList[$this->handlePHID];
|
||||
|
||||
|
@ -78,7 +88,14 @@ final class PHUIHandleView
|
|||
if ($this->useShortName) {
|
||||
$name = $handle->getName();
|
||||
} else {
|
||||
$name = null;
|
||||
$name = $handle->getLinkName();
|
||||
}
|
||||
|
||||
$glyph_limit = $this->getGlyphLimit();
|
||||
if ($glyph_limit) {
|
||||
$name = id(new PhutilUTF8StringTruncator())
|
||||
->setMaximumGlyphs($glyph_limit)
|
||||
->truncateString($name);
|
||||
}
|
||||
|
||||
if ($this->showHovercard) {
|
||||
|
|
|
@ -294,7 +294,8 @@ final class PHUIDiffTableOfContentsItemView extends AphrontView {
|
|||
$viewer = $this->getUser();
|
||||
$package_phids = mpull($packages, 'getPHID');
|
||||
|
||||
return $viewer->renderHandleList($package_phids);
|
||||
return $viewer->renderHandleList($package_phids)
|
||||
->setGlyphLimit(48);
|
||||
}
|
||||
|
||||
private function renderRename($self, $other, $arrow) {
|
||||
|
|
Loading…
Reference in a new issue