mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Show revision sizes using a perplexing, inexplicable symbol code
Summary: Ref T13110. See PHI230. Show revision sizes on a roughly logarithmic scale from 1-7 stars. See D16322 for theorycrafting on this element. Test Plan: Looked at some revisions, saw plausible-looking size markers. Maniphest Tasks: T13110 Differential Revision: https://secure.phabricator.com/D19294
This commit is contained in:
parent
e40aec0210
commit
e70c9f72a4
6 changed files with 136 additions and 6 deletions
|
@ -9,7 +9,7 @@ return array(
|
|||
'names' => array(
|
||||
'conpherence.pkg.css' => 'e68cf1fa',
|
||||
'conpherence.pkg.js' => '15191c65',
|
||||
'core.pkg.css' => '1dd5fa4b',
|
||||
'core.pkg.css' => '49b87886',
|
||||
'core.pkg.js' => '1ea38af8',
|
||||
'differential.pkg.css' => '113e692c',
|
||||
'differential.pkg.js' => 'f6d809c0',
|
||||
|
@ -132,7 +132,7 @@ return array(
|
|||
'rsrc/css/phui/object-item/phui-oi-color.css' => 'cd2b9b77',
|
||||
'rsrc/css/phui/object-item/phui-oi-drag-ui.css' => '08f4ccc3',
|
||||
'rsrc/css/phui/object-item/phui-oi-flush-ui.css' => '9d9685d6',
|
||||
'rsrc/css/phui/object-item/phui-oi-list-view.css' => '6ae18df0',
|
||||
'rsrc/css/phui/object-item/phui-oi-list-view.css' => 'ae1404ba',
|
||||
'rsrc/css/phui/object-item/phui-oi-simple-ui.css' => 'a8beebea',
|
||||
'rsrc/css/phui/phui-action-list.css' => '0bcd9a45',
|
||||
'rsrc/css/phui/phui-action-panel.css' => 'b4798122',
|
||||
|
@ -158,7 +158,7 @@ return array(
|
|||
'rsrc/css/phui/phui-header-view.css' => '31dc6c72',
|
||||
'rsrc/css/phui/phui-hovercard.css' => 'f0592bcf',
|
||||
'rsrc/css/phui/phui-icon-set-selector.css' => '87db8fee',
|
||||
'rsrc/css/phui/phui-icon.css' => '5c4a5de6',
|
||||
'rsrc/css/phui/phui-icon.css' => 'cf24ceec',
|
||||
'rsrc/css/phui/phui-image-mask.css' => 'a8498f9c',
|
||||
'rsrc/css/phui/phui-info-view.css' => 'e929f98c',
|
||||
'rsrc/css/phui/phui-invisible-character-view.css' => '6993d9f0',
|
||||
|
@ -833,7 +833,7 @@ return array(
|
|||
'phui-hovercard' => '1bd28176',
|
||||
'phui-hovercard-view-css' => 'f0592bcf',
|
||||
'phui-icon-set-selector-css' => '87db8fee',
|
||||
'phui-icon-view-css' => '5c4a5de6',
|
||||
'phui-icon-view-css' => 'cf24ceec',
|
||||
'phui-image-mask-css' => 'a8498f9c',
|
||||
'phui-info-view-css' => 'e929f98c',
|
||||
'phui-inline-comment-view-css' => '65ae3bc2',
|
||||
|
@ -846,7 +846,7 @@ return array(
|
|||
'phui-oi-color-css' => 'cd2b9b77',
|
||||
'phui-oi-drag-ui-css' => '08f4ccc3',
|
||||
'phui-oi-flush-ui-css' => '9d9685d6',
|
||||
'phui-oi-list-view-css' => '6ae18df0',
|
||||
'phui-oi-list-view-css' => 'ae1404ba',
|
||||
'phui-oi-simple-ui-css' => 'a8beebea',
|
||||
'phui-pager-css' => 'edcbc226',
|
||||
'phui-pinboard-view-css' => '2495140e',
|
||||
|
|
|
@ -568,7 +568,7 @@ final class DifferentialTransactionEditor
|
|||
|
||||
if ($show_lines) {
|
||||
$count = new PhutilNumber($object->getLineCount());
|
||||
$action = pht('%s, %s line(s)', $action, $count);
|
||||
$action = pht('%s] [%s', $action, $object->getRevisionScaleGlyphs());
|
||||
}
|
||||
|
||||
return $action;
|
||||
|
|
|
@ -742,6 +742,50 @@ final class DifferentialRevision extends DifferentialDAO
|
|||
return $this->getProperty(self::PROPERTY_LINES_REMOVED);
|
||||
}
|
||||
|
||||
public function getRevisionScaleGlyphs() {
|
||||
$add = $this->getAddedLineCount();
|
||||
$rem = $this->getRemovedLineCount();
|
||||
$all = ($add + $rem);
|
||||
|
||||
if (!$all) {
|
||||
return ' ';
|
||||
}
|
||||
|
||||
$map = array(
|
||||
20 => 2,
|
||||
50 => 3,
|
||||
150 => 4,
|
||||
375 => 5,
|
||||
1000 => 6,
|
||||
2500 => 7,
|
||||
);
|
||||
|
||||
$n = 1;
|
||||
foreach ($map as $size => $count) {
|
||||
if ($size <= $all) {
|
||||
$n = $count;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$add_n = (int)ceil(($add / $all) * $n);
|
||||
$rem_n = (int)ceil(($rem / $all) * $n);
|
||||
|
||||
while ($add_n + $rem_n > $n) {
|
||||
if ($add_n > 1) {
|
||||
$add_n--;
|
||||
} else {
|
||||
$rem_n--;
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
str_repeat('+', $add_n).
|
||||
str_repeat('-', $rem_n).
|
||||
str_repeat(' ', (7 - $n));
|
||||
}
|
||||
|
||||
public function getBuildableStatus($phid) {
|
||||
$buildables = $this->getProperty(self::PROPERTY_BUILDABLES);
|
||||
if (!is_array($buildables)) {
|
||||
|
|
|
@ -109,6 +109,8 @@ final class DifferentialRevisionListView extends AphrontView {
|
|||
$item->setHeader($revision->getTitle());
|
||||
$item->setHref($revision->getURI());
|
||||
|
||||
$item->addAttribute($this->renderRevisionSize($revision));
|
||||
|
||||
if ($revision->getHasDraft($viewer)) {
|
||||
$draft = id(new PHUIIconView())
|
||||
->setIcon('fa-comment yellow')
|
||||
|
@ -190,4 +192,55 @@ final class DifferentialRevisionListView extends AphrontView {
|
|||
return $list;
|
||||
}
|
||||
|
||||
private function renderRevisionSize(DifferentialRevision $revision) {
|
||||
$size = array();
|
||||
|
||||
$glyphs = $revision->getRevisionScaleGlyphs();
|
||||
$plus_count = 0;
|
||||
for ($ii = 0; $ii < 7; $ii++) {
|
||||
$c = $glyphs[$ii];
|
||||
|
||||
switch ($c) {
|
||||
case '+':
|
||||
$size[] = id(new PHUIIconView())
|
||||
->setIcon('fa-plus');
|
||||
$plus_count++;
|
||||
break;
|
||||
case '-':
|
||||
$size[] = id(new PHUIIconView())
|
||||
->setIcon('fa-minus');
|
||||
break;
|
||||
default:
|
||||
$size[] = id(new PHUIIconView())
|
||||
->setIcon('fa-square-o invisible');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$n = $revision->getAddedLineCount() + $revision->getRemovedLineCount();
|
||||
|
||||
$classes = array();
|
||||
$classes[] = 'differential-revision-size';
|
||||
|
||||
if ($plus_count <= 1) {
|
||||
$classes[] = 'differential-revision-small';
|
||||
}
|
||||
|
||||
if ($plus_count >= 4) {
|
||||
$classes[] = 'differential-revision-large';
|
||||
}
|
||||
|
||||
return javelin_tag(
|
||||
'span',
|
||||
array(
|
||||
'class' => implode(' ', $classes),
|
||||
'sigil' => 'has-tooltip',
|
||||
'meta' => array(
|
||||
'tip' => pht('%s Lines', new PhutilNumber($n)),
|
||||
'align' => 'E',
|
||||
),
|
||||
),
|
||||
$size);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -687,3 +687,32 @@ ul.phui-oi-list-view .phui-oi-selectable
|
|||
.phui-oi-frame {
|
||||
border-color: {$blueborder};
|
||||
}
|
||||
|
||||
.differential-revision-size {
|
||||
padding: 0 4px;
|
||||
border-radius: 4px;
|
||||
background: {$lightgreybackground};
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.differential-revision-size .phui-icon-view {
|
||||
margin: 0 1px 0 1px;
|
||||
font-size: smaller;
|
||||
color: {$blueborder};
|
||||
}
|
||||
|
||||
.differential-revision-large {
|
||||
background: {$sh-redbackground};
|
||||
}
|
||||
|
||||
.differential-revision-large .phui-icon-view {
|
||||
color: {$red};
|
||||
}
|
||||
|
||||
.differential-revision-small {
|
||||
background: {$sh-greenbackground};
|
||||
}
|
||||
|
||||
.differential-revision-small .phui-icon-view {
|
||||
color: {$green};
|
||||
}
|
||||
|
|
|
@ -49,6 +49,10 @@ img.phui-image-disabled {
|
|||
color: {$bluetext};
|
||||
}
|
||||
|
||||
.phui-icon-view.invisible {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* - Icon in a Circle ------------------------------------------------------- */
|
||||
|
||||
.phui-icon-circle {
|
||||
|
|
Loading…
Reference in a new issue