@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Only table of contents are shown for large diffs by default.

Summary:
Differential used to only show diffs for the first 100 files. Now all
the files are shown in the table of contents and there is a link to
the standalone view for every file. The inline diffs can still be
seen, if user clicks "Show All Files Inline".

Inline comments can also be added in the standalone view, but there is
no form to submit them. The revision page must be reloaded to able to
submit the inline comment.

Test Plan:
Changed the limit to three for testing purposes and checked that a diff of
mine with 5 files had the links to the standalone views. Made sure that
adding a comment in a standalone view worked and that after reloading the
revision page the comment was visible. Changed the limit back to 100 and
made sure that my diff had all the files inline and that the anchor links
were working.

Reviewed By: jungejason
Reviewers: jungejason
CC: epriestley, simpkins, jungejason, tuomaspelkonen
Differential Revision: 147

+85 -13
+1
src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php
··· 169 169 $detail = new DifferentialChangesetDetailView(); 170 170 $detail->setChangeset($changeset); 171 171 $detail->appendChild($output); 172 + $detail->setRevisionID($request->getInt('revision_id')); 172 173 173 174 $output = 174 175 '<div class="differential-primary-pane">'.
+8 -5
src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php
··· 99 99 $warning->setSeverity(AphrontErrorView::SEVERITY_WARNING); 100 100 $warning->setWidth(AphrontErrorView::WIDTH_WIDE); 101 101 $warning->appendChild( 102 - "<p>This diff is very large and affects {$count} files. Only ". 103 - "the first {$limit} files are shown. ". 102 + "<p>This diff is very large and affects {$count} files. Use ". 103 + "Table of Contents to open files in a standalone view. ". 104 104 "<strong>". 105 105 phutil_render_tag( 106 106 'a', 107 107 array( 108 108 'href' => $request_uri->alter('large', 'true'), 109 109 ), 110 - 'Show All Files'). 110 + 'Show All Files Inline'). 111 111 "</strong>"); 112 112 $warning = $warning->render(); 113 113 114 - $visible_changesets = array_slice($changesets, 0, $limit, true); 114 + $visible_changesets = array(); 115 115 } else { 116 116 $warning = null; 117 117 $visible_changesets = $changesets; ··· 176 176 177 177 $toc_view = new DifferentialDiffTableOfContentsView(); 178 178 $toc_view->setChangesets($changesets); 179 + $toc_view->setStandaloneViewLink(empty($visible_changesets)); 180 + $toc_view->setVsMap($vs_map); 181 + $toc_view->setRevisionID($revision->getID()); 179 182 180 183 $changeset_view = new DifferentialChangesetListView(); 181 184 $changeset_view->setChangesets($visible_changesets); ··· 205 208 $revision_detail->render(). 206 209 $comment_view->render(). 207 210 $diff_history->render(). 208 - $toc_view->render(). 209 211 $warning. 212 + $toc_view->render(). 210 213 $changeset_view->render(). 211 214 $comment_form->render(). 212 215 '</div>',
+18 -1
src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php
··· 20 20 21 21 private $changeset; 22 22 private $buttons = array(); 23 + private $revisionID; 23 24 24 25 public function setChangeset($changeset) { 25 26 $this->changeset = $changeset; ··· 31 32 return $this; 32 33 } 33 34 35 + public function setRevisionID($revision_id) { 36 + $this->revisionID = $revision_id; 37 + return $this; 38 + } 39 + 34 40 public function render() { 35 41 require_celerity_resource('differential-changeset-view-css'); 36 42 require_celerity_resource('syntax-highlighting-css'); 37 43 38 - $edit = false; // TODO 44 + if ($this->revisionID) { 45 + $edit = true; 46 + } else { 47 + $edit = false; 48 + } 39 49 40 50 $changeset = $this->changeset; 41 51 $class = 'differential-changeset'; ··· 64 74 '<h1>'.phutil_escape_html($display_filename).'</h1>'. 65 75 '<div style="clear: both;"></div>'. 66 76 $this->renderChildren()); 77 + 78 + if ($edit) { 79 + Javelin::initBehavior( 80 + 'differential-edit-inline-comments', array( 81 + 'uri' => '/differential/comment/inline/edit/'.$this->revisionID.'/', 82 + )); 83 + } 67 84 68 85 return $output; 69 86 }
+1
src/applications/differential/view/changesetdetailview/__init__.php
··· 7 7 8 8 9 9 phutil_require_module('phabricator', 'infrastructure/celerity/api'); 10 + phutil_require_module('phabricator', 'infrastructure/javelin/api'); 10 11 phutil_require_module('phabricator', 'infrastructure/javelin/markup'); 11 12 phutil_require_module('phabricator', 'view/base'); 12 13
+55 -7
src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php
··· 19 19 final class DifferentialDiffTableOfContentsView extends AphrontView { 20 20 21 21 private $changesets = array(); 22 + private $standaloneViewLink = null; 23 + private $renderURI = '/differential/changeset/'; 24 + private $revisionID; 22 25 23 26 public function setChangesets($changesets) { 24 27 $this->changesets = $changesets; 25 28 return $this; 26 29 } 30 + 31 + public function setStandaloneViewLink($standalone_view_link) { 32 + $this->standaloneViewLink = $standalone_view_link; 33 + return $this; 34 + } 35 + 36 + public function setVsMap(array $vs_map) { 37 + $this->vsMap = $vs_map; 38 + return $this; 39 + } 40 + 41 + public function setRevisionID($revision_id) { 42 + $this->revisionID = $revision_id; 43 + return $this; 44 + } 45 + 27 46 28 47 public function render() { 29 48 ··· 62 81 } 63 82 } 64 83 } else { 65 - $link = phutil_render_tag( 66 - 'a', 67 - array( 68 - 'href' => '#'.$changeset->getAnchorName(), 69 - ), 70 - phutil_escape_html($display_file)); 84 + 85 + if ($this->standaloneViewLink) { 86 + $id = $changeset->getID(); 87 + if ($id) { 88 + $vs_id = idx($this->vsMap, $id); 89 + } else { 90 + $vs_id = null; 91 + } 92 + $ref = $changeset->getRenderingReference(); 93 + $detail_uri = new PhutilURI($this->renderURI); 94 + $detail_uri->setQueryParams( 95 + array( 96 + 'id' => $ref, 97 + 'vs' => $vs_id, 98 + 'whitespace' => 'TODO', 99 + 'revision_id' => $this->revisionID, 100 + )); 101 + 102 + $link = phutil_render_tag( 103 + 'a', 104 + array( 105 + 'href' => $detail_uri, 106 + 'target' => '_blank', 107 + ), 108 + phutil_escape_html($display_file)); 109 + } else { 110 + $link = phutil_render_tag( 111 + 'a', 112 + array( 113 + 'href' => '#'.$changeset->getAnchorName(), 114 + ), 115 + phutil_escape_html($display_file)); 116 + } 117 + 71 118 if ($type == DifferentialChangeType::TYPE_MOVE_HERE) { 72 119 $meta = 'Moved from '.phutil_escape_html($changeset->getOldFile()); 73 120 } else if ($type == DifferentialChangeType::TYPE_COPY_HERE) { ··· 99 146 100 147 $rows[] = 101 148 '<tr>'. 102 - '<td class="differential-toc-char" title='.$chartitle.'>'.$char.'</td>'. 149 + '<td class="differential-toc-char" title='.$chartitle.'>'.$char. 150 + '</td>'. 103 151 '<td class="differential-toc-prop">'.$pchar.'</td>'. 104 152 '<td class="differential-toc-ftype">'.$desc.'</td>'. 105 153 '<td class="differential-toc-file">'.$link.$lines.'</td>'.
+2
src/applications/differential/view/difftableofcontents/__init__.php
··· 11 11 phutil_require_module('phabricator', 'view/base'); 12 12 13 13 phutil_require_module('phutil', 'markup'); 14 + phutil_require_module('phutil', 'parser/uri'); 15 + phutil_require_module('phutil', 'utils'); 14 16 15 17 16 18 phutil_require_source('DifferentialDiffTableOfContentsView.php');