Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 9fa2525

Browse files
author
epriestley
committed
Improve rendering of history graph in "CommitGraphView"
Summary: Ref T13552. In the new combined "table/list" graph view, tidy up the graph rendering. Test Plan: {F7633504} Maniphest Tasks: T13552 Differential Revision: https://secure.phabricator.com/D21411
1 parent 46695c7 commit 9fa2525

File tree

5 files changed

+71
-38
lines changed

5 files changed

+71
-38
lines changed

resources/celerity/map.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'differential.pkg.css' => '5c459f92',
1616
'differential.pkg.js' => '218fda21',
1717
'diffusion.pkg.css' => '42c75c37',
18-
'diffusion.pkg.js' => 'a98c0bf7',
18+
'diffusion.pkg.js' => '8ee48a4b',
1919
'maniphest.pkg.css' => '35995d6d',
2020
'maniphest.pkg.js' => 'c9308721',
2121
'rsrc/audio/basic/alert.mp3' => '17889334',
@@ -73,7 +73,7 @@
7373
'rsrc/css/application/diffusion/diffusion-icons.css' => '23b31a1b',
7474
'rsrc/css/application/diffusion/diffusion-readme.css' => 'b68a76e4',
7575
'rsrc/css/application/diffusion/diffusion-repository.css' => 'b89e8c6c',
76-
'rsrc/css/application/diffusion/diffusion.css' => 'b54c77b0',
76+
'rsrc/css/application/diffusion/diffusion.css' => 'a54bb336',
7777
'rsrc/css/application/feed/feed.css' => 'd8b6e3f8',
7878
'rsrc/css/application/files/global-drag-and-drop.css' => '1d2713a4',
7979
'rsrc/css/application/flag/flag.css' => '2b77be8d',
@@ -390,7 +390,7 @@
390390
'rsrc/js/application/diffusion/ExternalEditorLinkEngine.js' => '48a8641f',
391391
'rsrc/js/application/diffusion/behavior-audit-preview.js' => 'b7b73831',
392392
'rsrc/js/application/diffusion/behavior-commit-branches.js' => '4b671572',
393-
'rsrc/js/application/diffusion/behavior-commit-graph.js' => 'ef836bf2',
393+
'rsrc/js/application/diffusion/behavior-commit-graph.js' => '3be6ef4f',
394394
'rsrc/js/application/diffusion/behavior-locate-file.js' => '87428eb2',
395395
'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'c715c123',
396396
'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '6a85bc5a',
@@ -567,7 +567,7 @@
567567
'differential-revision-history-css' => '8aa3eac5',
568568
'differential-revision-list-css' => '93d2df7d',
569569
'differential-table-of-contents-css' => 'bba788b9',
570-
'diffusion-css' => 'b54c77b0',
570+
'diffusion-css' => 'a54bb336',
571571
'diffusion-icons-css' => '23b31a1b',
572572
'diffusion-readme-css' => 'b68a76e4',
573573
'diffusion-repository-css' => 'b89e8c6c',
@@ -615,7 +615,7 @@
615615
'javelin-behavior-differential-diff-radios' => '925fe8cd',
616616
'javelin-behavior-differential-populate' => 'b86ef6c2',
617617
'javelin-behavior-diffusion-commit-branches' => '4b671572',
618-
'javelin-behavior-diffusion-commit-graph' => 'ef836bf2',
618+
'javelin-behavior-diffusion-commit-graph' => '3be6ef4f',
619619
'javelin-behavior-diffusion-locate-file' => '87428eb2',
620620
'javelin-behavior-diffusion-pull-lastmodified' => 'c715c123',
621621
'javelin-behavior-document-engine' => '243d6c22',
@@ -1249,6 +1249,11 @@
12491249
'javelin-behavior',
12501250
'phabricator-prefab',
12511251
),
1252+
'3be6ef4f' => array(
1253+
'javelin-behavior',
1254+
'javelin-dom',
1255+
'javelin-stratcom',
1256+
),
12521257
'3dc5ad43' => array(
12531258
'javelin-behavior',
12541259
'javelin-stratcom',
@@ -2173,11 +2178,6 @@
21732178
'ee77366f' => array(
21742179
'aphront-dialog-view-css',
21752180
),
2176-
'ef836bf2' => array(
2177-
'javelin-behavior',
2178-
'javelin-dom',
2179-
'javelin-stratcom',
2180-
),
21812181
'f340a484' => array(
21822182
'javelin-install',
21832183
'javelin-dom',

src/applications/diffusion/view/DiffusionCommitGraphView.php

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,9 @@ private function getRepository() {
8282
}
8383

8484
public function render() {
85-
$viewer = $this->getUser();
86-
87-
$drequest = $this->getDiffusionRequest();
88-
$repository = $drequest->getRepository();
85+
$viewer = $this->getViewer();
8986

9087
require_celerity_resource('diffusion-css');
91-
Javelin::initBehavior('phabricator-tooltips');
9288

9389
$show_builds = $this->shouldShowBuilds();
9490
$show_revisions = $this->shouldShowRevisions();
@@ -107,13 +103,18 @@ public function render() {
107103
$item_date = phabricator_date($item_epoch, $viewer);
108104
if ($item_date !== $last_date) {
109105
$last_date = $item_date;
110-
$content[] = $item_date;
106+
$content[] = phutil_tag(
107+
'div',
108+
array(
109+
'class' => 'diffusion-commit-graph-date-header',
110+
),
111+
$item_date);
111112
}
112113

113114
$commit_description = $this->getCommitDescription($commit);
114-
$commit_link = $this->getCommitURI($commit, $item_hash);
115+
$commit_link = $this->getCommitURI($item_hash);
115116

116-
$short_hash = $this->getCommitObjectName($commit, $item_hash);
117+
$short_hash = $this->getCommitObjectName($item_hash);
117118
$is_disabled = $this->getCommitIsDisabled($commit);
118119

119120
$author_view = $this->getCommitAuthorView($commit);
@@ -156,29 +157,38 @@ public function render() {
156157

157158
$content[] = $view;
158159

159-
$rows[] = array(
160-
$content,
161-
);
160+
$rows[] = $content;
162161
}
163162

164163
$graph = $this->newGraphView();
165-
if ($graph) {
166-
$idx = 0;
167-
foreach ($rows as $key => $row) {
168-
array_unshift($row, $graph[$idx++]);
169-
$rows[$key] = $row;
170-
}
171-
}
172-
173-
foreach ($rows as $key => $row) {
164+
foreach ($rows as $idx => $row) {
174165
$cells = array();
175-
foreach ($row as $cell) {
176-
$cells[] = phutil_tag('td', array(), $cell);
166+
167+
if ($graph) {
168+
$cells[] = phutil_tag(
169+
'td',
170+
array(
171+
'class' => 'diffusion-commit-graph-path-cell',
172+
),
173+
$graph[$idx]);
177174
}
178-
$rows[$key] = phutil_tag('tr', array(), $cells);
175+
176+
$cells[] = phutil_tag(
177+
'td',
178+
array(
179+
'class' => 'diffusion-commit-graph-content-cell',
180+
),
181+
$row);
182+
183+
$rows[$idx] = phutil_tag('tr', array(), $cells);
179184
}
180185

181-
$table = phutil_tag('table', array(), $rows);
186+
$table = phutil_tag(
187+
'table',
188+
array(
189+
'class' => 'diffusion-commit-graph-table',
190+
),
191+
$rows);
182192

183193
return $table;
184194
}
@@ -275,17 +285,18 @@ private function getCommitDescription($commit) {
275285
return $commit->getCommitData()->getSummary();
276286
}
277287

278-
private function getCommitURI($commit, $hash) {
288+
private function getCommitURI($hash) {
279289
$repository = $this->getRepository();
280290

281291
if ($repository) {
282292
return $repository->getCommitURI($hash);
283293
}
284294

295+
$commit = $this->getCommit($hash);
285296
return $commit->getURI();
286297
}
287298

288-
private function getCommitObjectName($commit, $hash) {
299+
private function getCommitObjectName($hash) {
289300
$repository = $this->getRepository();
290301

291302
if ($repository) {
@@ -294,6 +305,7 @@ private function getCommitObjectName($commit, $hash) {
294305
$is_local = true);
295306
}
296307

308+
$commit = $this->getCommit($hash);
297309
return $commit->getDisplayName();
298310
}
299311

src/infrastructure/diff/view/PHUIDiffGraphView.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public function renderGraph(array $parents) {
205205
'diffusion-commit-graph',
206206
array(
207207
'count' => $count,
208+
'autoheight' => true,
208209
));
209210

210211
return $graph;

webroot/rsrc/css/application/diffusion/diffusion.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,17 @@
237237
border-right: none;
238238
border-color: {$thinblueborder};
239239
}
240+
241+
.diffusion-commit-graph-table td.diffusion-commit-graph-path-cell {
242+
padding: 0 4px 0 0;
243+
}
244+
245+
.diffusion-commit-graph-table td.diffusion-commit-graph-path-cell > canvas {
246+
display: block;
247+
}
248+
249+
.diffusion-commit-graph-date-header {
250+
color: {$darkgreytext};
251+
font-weight: bold;
252+
padding: 4px 0;
253+
}

webroot/rsrc/js/application/diffusion/behavior-commit-graph.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ JX.behavior('diffusion-commit-graph', function(config) {
6161
return (col * cell) + (cell / 2);
6262
};
6363

64-
var h = 34;
64+
var h;
65+
if (config.autoheight) {
66+
h = JX.Vector.getDim(nodes[ii].parentNode).y;
67+
} else {
68+
h = 34;
69+
}
70+
6571
var w = cell * config.count;
6672

6773
var canvas = JX.$N('canvas', {width: w, height: h});
@@ -147,7 +153,7 @@ JX.behavior('diffusion-commit-graph', function(config) {
147153
}
148154
}
149155

150-
JX.DOM.setContent(nodes[ii], canvas);
156+
JX.DOM.replace(nodes[ii], canvas);
151157
}
152158

153159

0 commit comments

Comments
 (0)