diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 56ee3d5d45..e0bb41b8aa 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -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', diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php index a28d24abf5..24f0fe7a07 100644 --- a/src/applications/differential/editor/DifferentialTransactionEditor.php +++ b/src/applications/differential/editor/DifferentialTransactionEditor.php @@ -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; diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php index 7b67dc27ef..f11cbef7e0 100644 --- a/src/applications/differential/storage/DifferentialRevision.php +++ b/src/applications/differential/storage/DifferentialRevision.php @@ -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)) { diff --git a/src/applications/differential/view/DifferentialRevisionListView.php b/src/applications/differential/view/DifferentialRevisionListView.php index 49f4c5b882..5f14a6b975 100644 --- a/src/applications/differential/view/DifferentialRevisionListView.php +++ b/src/applications/differential/view/DifferentialRevisionListView.php @@ -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); + } + } diff --git a/webroot/rsrc/css/phui/object-item/phui-oi-list-view.css b/webroot/rsrc/css/phui/object-item/phui-oi-list-view.css index ff79a8d70b..9436d171df 100644 --- a/webroot/rsrc/css/phui/object-item/phui-oi-list-view.css +++ b/webroot/rsrc/css/phui/object-item/phui-oi-list-view.css @@ -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}; +} diff --git a/webroot/rsrc/css/phui/phui-icon.css b/webroot/rsrc/css/phui/phui-icon.css index acc7818765..4108074b08 100644 --- a/webroot/rsrc/css/phui/phui-icon.css +++ b/webroot/rsrc/css/phui/phui-icon.css @@ -49,6 +49,10 @@ img.phui-image-disabled { color: {$bluetext}; } +.phui-icon-view.invisible { + visibility: hidden; +} + /* - Icon in a Circle ------------------------------------------------------- */ .phui-icon-circle {