1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Improve rendering of commit branching graph

Summary:
Fixes T9323. Two minor fixes:

  - On the first commit, don't render a downward line.
  - Clean up a 1px spacing issue that had cropped up a while ago when we added icons or something, I think.

Test Plan:
Before:

{F1057248}

After:

{F1057249}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9323

Differential Revision: https://secure.phabricator.com/D14974
This commit is contained in:
epriestley 2016-01-08 11:41:49 -08:00
parent d1fb2f7fb9
commit c7520cd9f2
5 changed files with 40 additions and 17 deletions

View file

@ -13,7 +13,7 @@ return array(
'differential.pkg.css' => '2de124c9', 'differential.pkg.css' => '2de124c9',
'differential.pkg.js' => '64e69521', 'differential.pkg.js' => '64e69521',
'diffusion.pkg.css' => 'f45955ed', 'diffusion.pkg.css' => 'f45955ed',
'diffusion.pkg.js' => 'ca1c8b5a', 'diffusion.pkg.js' => '3a9a8bfa',
'maniphest.pkg.css' => '4845691a', 'maniphest.pkg.css' => '4845691a',
'maniphest.pkg.js' => '949a7498', 'maniphest.pkg.js' => '949a7498',
'rsrc/css/aphront/aphront-bars.css' => '231ac33c', 'rsrc/css/aphront/aphront-bars.css' => '231ac33c',
@ -391,7 +391,7 @@ return array(
'rsrc/js/application/diffusion/DiffusionLocateFileSource.js' => 'b42eddc7', 'rsrc/js/application/diffusion/DiffusionLocateFileSource.js' => 'b42eddc7',
'rsrc/js/application/diffusion/behavior-audit-preview.js' => 'd835b03a', 'rsrc/js/application/diffusion/behavior-audit-preview.js' => 'd835b03a',
'rsrc/js/application/diffusion/behavior-commit-branches.js' => 'bdaf4d04', 'rsrc/js/application/diffusion/behavior-commit-branches.js' => 'bdaf4d04',
'rsrc/js/application/diffusion/behavior-commit-graph.js' => '9007c197', 'rsrc/js/application/diffusion/behavior-commit-graph.js' => '5a0b1a64',
'rsrc/js/application/diffusion/behavior-jump-to.js' => '73d09eef', 'rsrc/js/application/diffusion/behavior-jump-to.js' => '73d09eef',
'rsrc/js/application/diffusion/behavior-load-blame.js' => '42126667', 'rsrc/js/application/diffusion/behavior-load-blame.js' => '42126667',
'rsrc/js/application/diffusion/behavior-locate-file.js' => '6d3e1947', 'rsrc/js/application/diffusion/behavior-locate-file.js' => '6d3e1947',
@ -598,7 +598,7 @@ return array(
'javelin-behavior-differential-toggle-files' => 'ca3f91eb', 'javelin-behavior-differential-toggle-files' => 'ca3f91eb',
'javelin-behavior-differential-user-select' => 'a8d8459d', 'javelin-behavior-differential-user-select' => 'a8d8459d',
'javelin-behavior-diffusion-commit-branches' => 'bdaf4d04', 'javelin-behavior-diffusion-commit-branches' => 'bdaf4d04',
'javelin-behavior-diffusion-commit-graph' => '9007c197', 'javelin-behavior-diffusion-commit-graph' => '5a0b1a64',
'javelin-behavior-diffusion-jump-to' => '73d09eef', 'javelin-behavior-diffusion-jump-to' => '73d09eef',
'javelin-behavior-diffusion-locate-file' => '6d3e1947', 'javelin-behavior-diffusion-locate-file' => '6d3e1947',
'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc', 'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc',
@ -1218,6 +1218,11 @@ return array(
'javelin-vector', 'javelin-vector',
'javelin-dom', 'javelin-dom',
), ),
'5a0b1a64' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
),
'5b2e3e2b' => array( '5b2e3e2b' => array(
'javelin-stratcom', 'javelin-stratcom',
'javelin-request', 'javelin-request',
@ -1523,11 +1528,6 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-workflow', 'javelin-workflow',
), ),
'9007c197' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
),
'901935ef' => array( '901935ef' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',

View file

@ -52,6 +52,7 @@ final class DiffusionHistoryController extends DiffusionController {
if ($show_graph) { if ($show_graph) {
$history_table->setParents($history_results['parents']); $history_table->setParents($history_results['parents']);
$history_table->setIsHead(!$pager->getOffset()); $history_table->setIsHead(!$pager->getOffset());
$history_table->setIsTail(!$pager->getHasMorePages());
} }
$history_panel = new PHUIObjectBoxView(); $history_panel = new PHUIObjectBoxView();

View file

@ -6,6 +6,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
private $revisions = array(); private $revisions = array();
private $handles = array(); private $handles = array();
private $isHead; private $isHead;
private $isTail;
private $parents; private $parents;
public function setHistory(array $history) { public function setHistory(array $history) {
@ -60,6 +61,11 @@ final class DiffusionHistoryTableView extends DiffusionView {
return $this; return $this;
} }
public function setIsTail($is_tail) {
$this->isTail = $is_tail;
return $this;
}
public function render() { public function render() {
$drequest = $this->getDiffusionRequest(); $drequest = $this->getDiffusionRequest();
@ -344,6 +350,16 @@ final class DiffusionHistoryTableView extends DiffusionView {
); );
} }
// If this is the last page in history, replace the "o" with an "x" so we
// do not draw a connecting line downward, and replace "^" with an "X" for
// repositories with exactly one commit.
if ($this->isTail && $graph) {
$last = array_pop($graph);
$last['line'] = str_replace('o', 'x', $last['line']);
$last['line'] = str_replace('^', 'X', $last['line']);
$graph[] = $last;
}
// Render into tags for the behavior. // Render into tags for the behavior.
foreach ($graph as $k => $meta) { foreach ($graph as $k => $meta) {

View file

@ -58,6 +58,10 @@ final class PHUIPagerView extends AphrontView {
return $this->hasMorePages; return $this->hasMorePages;
} }
public function getHasMorePages() {
return $this->hasMorePages;
}
public function setSurroundingPages($pages) { public function setSurroundingPages($pages) {
$this->surroundingPages = max(0, $pages); $this->surroundingPages = max(0, $pages);
return $this; return $this;

View file

@ -37,6 +37,7 @@ JX.behavior('diffusion-commit-graph', function(config) {
// Stroke with fill (for commit circles). // Stroke with fill (for commit circles).
function fstroke(c) { function fstroke(c) {
cxt.lineWidth = 1;
cxt.fillStyle = color(c); cxt.fillStyle = color(c);
cxt.strokeStyle = '#ffffff'; cxt.strokeStyle = '#ffffff';
cxt.fill(); cxt.fill();
@ -52,7 +53,7 @@ JX.behavior('diffusion-commit-graph', function(config) {
return (col * cell) + (cell / 2); return (col * cell) + (cell / 2);
}; };
var h = 30; var h = 32;
var w = cell * config.count; var w = cell * config.count;
var canvas = JX.$N('canvas', {width: w, height: h}); var canvas = JX.$N('canvas', {width: w, height: h});
@ -117,16 +118,17 @@ JX.behavior('diffusion-commit-graph', function(config) {
case 'o': case 'o':
case '^': case '^':
case '|': case '|':
if (c == 'o' || c == '^') { case 'x':
origin = xpos(jj); case 'X':
}
if (c !== 'X') {
cxt.beginPath(); cxt.beginPath();
cxt.moveTo(xpos(jj), (c == '^' ? h/2 : 0)); cxt.moveTo(xpos(jj), (c == '^' ? h/2 : 0));
cxt.lineTo(xpos(jj), h); cxt.lineTo(xpos(jj), (c == 'x' ? h/2 : h));
lstroke(jj); lstroke(jj);
}
if (c == 'o' || c == '^') { if (c == 'o' || c == '^' || c == 'x' || c == 'X') {
cxt.beginPath(); cxt.beginPath();
cxt.arc(xpos(jj), h/2, 3, 0, 2 * Math.PI, true); cxt.arc(xpos(jj), h/2, 3, 0, 2 * Math.PI, true);
fstroke(jj); fstroke(jj);