@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.

Restore "h" to hide or show files, and modernize file visibility toggling

Summary:
Ref T12616. This puts "h" back to collapse or expand the current file.

This removes some very complicated/messy code around following links in the table of contents and getting files auto-expanded. I suspect no one will miss this, but we can restore it if ayone notices.

Test Plan: Pressed "h" to collapse/expand a file. Also used the menu items.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12616

Differential Revision: https://secure.phabricator.com/D17940

+114 -177
+25 -34
resources/celerity/map.php
··· 12 12 'core.pkg.css' => 'a5a2d647', 13 13 'core.pkg.js' => '0f87a6eb', 14 14 'darkconsole.pkg.js' => '1f9a31bc', 15 - 'differential.pkg.css' => 'ea471cb0', 16 - 'differential.pkg.js' => '31e1b646', 15 + 'differential.pkg.css' => '697405d4', 16 + 'differential.pkg.js' => '07c56ffc', 17 17 'diffusion.pkg.css' => 'b93d9b8c', 18 18 'diffusion.pkg.js' => '84c8f8fd', 19 19 'favicon.ico' => '30672e08', ··· 64 64 'rsrc/css/application/dashboard/dashboard.css' => 'fe5b1869', 65 65 'rsrc/css/application/diff/inline-comment-summary.css' => '51efda3a', 66 66 'rsrc/css/application/differential/add-comment.css' => 'c47f8c40', 67 - 'rsrc/css/application/differential/changeset-view.css' => '6a77323e', 67 + 'rsrc/css/application/differential/changeset-view.css' => '15be1064', 68 68 'rsrc/css/application/differential/core.css' => '5b7b8ff4', 69 69 'rsrc/css/application/differential/phui-inline-comment.css' => 'ffd1a542', 70 70 'rsrc/css/application/differential/revision-comment.css' => '14b8565a', ··· 390 390 'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => '408bf173', 391 391 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '453c5375', 392 392 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63', 393 - 'rsrc/js/application/diff/DiffChangeset.js' => 'ec32b333', 394 - 'rsrc/js/application/diff/DiffChangesetList.js' => '796922e0', 393 + 'rsrc/js/application/diff/DiffChangeset.js' => '731125f3', 394 + 'rsrc/js/application/diff/DiffChangesetList.js' => '59d1ceb1', 395 395 'rsrc/js/application/diff/DiffInline.js' => '3337c065', 396 396 'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832', 397 397 'rsrc/js/application/differential/behavior-comment-preview.js' => 'b064af76', 398 398 'rsrc/js/application/differential/behavior-diff-radios.js' => 'e1ff79b1', 399 399 'rsrc/js/application/differential/behavior-populate.js' => '5e41c819', 400 - 'rsrc/js/application/differential/behavior-toggle-files.js' => 'ca3f91eb', 401 400 'rsrc/js/application/differential/behavior-user-select.js' => 'a8d8459d', 402 401 'rsrc/js/application/diffusion/DiffusionLocateFileSource.js' => 'c93358e3', 403 402 'rsrc/js/application/diffusion/behavior-audit-preview.js' => 'd835b03a', ··· 566 565 'conpherence-thread-manager' => '4d863052', 567 566 'conpherence-transaction-css' => '85129c68', 568 567 'd3' => 'a11a5ff2', 569 - 'differential-changeset-view-css' => '6a77323e', 568 + 'differential-changeset-view-css' => '15be1064', 570 569 'differential-core-view-css' => '5b7b8ff4', 571 570 'differential-revision-add-comment-css' => 'c47f8c40', 572 571 'differential-revision-comment-css' => '14b8565a', ··· 620 619 'javelin-behavior-differential-diff-radios' => 'e1ff79b1', 621 620 'javelin-behavior-differential-feedback-preview' => 'b064af76', 622 621 'javelin-behavior-differential-populate' => '5e41c819', 623 - 'javelin-behavior-differential-toggle-files' => 'ca3f91eb', 624 622 'javelin-behavior-differential-user-select' => 'a8d8459d', 625 623 'javelin-behavior-diffusion-browse-file' => '054a0f0b', 626 624 'javelin-behavior-diffusion-commit-branches' => 'bdaf4d04', ··· 777 775 'phabricator-darklog' => 'c8e1ffe3', 778 776 'phabricator-darkmessage' => 'c48cccdd', 779 777 'phabricator-dashboard-css' => 'fe5b1869', 780 - 'phabricator-diff-changeset' => 'ec32b333', 781 - 'phabricator-diff-changeset-list' => '796922e0', 778 + 'phabricator-diff-changeset' => '731125f3', 779 + 'phabricator-diff-changeset-list' => '59d1ceb1', 782 780 'phabricator-diff-inline' => '3337c065', 783 781 'phabricator-drag-and-drop-file-upload' => '58dea2fa', 784 782 'phabricator-draggable-list' => 'bea6e7f4', ··· 1000 998 'javelin-stratcom', 1001 999 'javelin-dom', 1002 1000 'javelin-history', 1001 + ), 1002 + '15be1064' => array( 1003 + 'phui-inline-comment-view-css', 1003 1004 ), 1004 1005 '17bb8539' => array( 1005 1006 'javelin-behavior', ··· 1348 1349 'javelin-vector', 1349 1350 'javelin-dom', 1350 1351 ), 1352 + '59d1ceb1' => array( 1353 + 'javelin-install', 1354 + ), 1351 1355 '5c54cbf3' => array( 1352 1356 'javelin-behavior', 1353 1357 'javelin-stratcom', ··· 1409 1413 '69adf288' => array( 1410 1414 'javelin-install', 1411 1415 ), 1412 - '6a77323e' => array( 1413 - 'phui-inline-comment-view-css', 1414 - ), 1415 1416 '6ad39b6f' => array( 1416 1417 'javelin-install', 1417 1418 'javelin-event', ··· 1449 1450 'javelin-workflow', 1450 1451 'phabricator-draggable-list', 1451 1452 ), 1453 + '731125f3' => array( 1454 + 'javelin-dom', 1455 + 'javelin-util', 1456 + 'javelin-stratcom', 1457 + 'javelin-install', 1458 + 'javelin-workflow', 1459 + 'javelin-router', 1460 + 'javelin-behavior-device', 1461 + 'javelin-vector', 1462 + 'phabricator-diff-inline', 1463 + ), 1452 1464 '7319e029' => array( 1453 1465 'javelin-behavior', 1454 1466 'javelin-dom', ··· 1481 1493 '7927a7d3' => array( 1482 1494 'javelin-behavior', 1483 1495 'javelin-quicksand', 1484 - ), 1485 - '796922e0' => array( 1486 - 'javelin-install', 1487 1496 ), 1488 1497 '7a68dda3' => array( 1489 1498 'owners-path-editor', ··· 1960 1969 'phabricator-shaped-request', 1961 1970 'conpherence-thread-manager', 1962 1971 ), 1963 - 'ca3f91eb' => array( 1964 - 'javelin-behavior', 1965 - 'javelin-dom', 1966 - 'javelin-stratcom', 1967 - 'phabricator-phtize', 1968 - ), 1969 1972 'caade6f2' => array( 1970 1973 'javelin-behavior', 1971 1974 'javelin-request', ··· 2130 2133 'javelin-workflow', 2131 2134 'javelin-dom', 2132 2135 'phabricator-draggable-list', 2133 - ), 2134 - 'ec32b333' => array( 2135 - 'javelin-dom', 2136 - 'javelin-util', 2137 - 'javelin-stratcom', 2138 - 'javelin-install', 2139 - 'javelin-workflow', 2140 - 'javelin-router', 2141 - 'javelin-behavior-device', 2142 - 'javelin-vector', 2143 - 'phabricator-diff-inline', 2144 2136 ), 2145 2137 'eded9ee8' => array( 2146 2138 'javelin-behavior', ··· 2418 2410 'javelin-behavior-phabricator-object-selector', 2419 2411 'javelin-behavior-repository-crossreference', 2420 2412 'javelin-behavior-load-blame', 2421 - 'javelin-behavior-differential-toggle-files', 2422 2413 'javelin-behavior-differential-user-select', 2423 2414 'javelin-behavior-aphront-more', 2424 2415 'phabricator-diff-inline',
-1
resources/celerity/packages.php
··· 200 200 'javelin-behavior-repository-crossreference', 201 201 'javelin-behavior-load-blame', 202 202 203 - 'javelin-behavior-differential-toggle-files', 204 203 'javelin-behavior-differential-user-select', 205 204 'javelin-behavior-aphront-more', 206 205
+9 -7
src/applications/differential/view/DifferentialChangesetListView.php
··· 131 131 132 132 $changesets = $this->changesets; 133 133 134 - Javelin::initBehavior('differential-toggle-files', array( 135 - 'pht' => array( 136 - 'undo' => pht('Undo'), 137 - 'collapsed' => pht('This file content has been collapsed.'), 138 - ), 139 - )); 140 - 141 134 $renderer = DifferentialChangesetParser::getDefaultRendererForViewer( 142 135 $viewer); 143 136 ··· 271 264 pht('Jump to next inline comment, including hidden comments.'), 272 265 'Jump to previous inline comment, including hidden comments.' => 273 266 pht('Jump to previous inline comment, including hidden comments.'), 267 + 268 + 'This file content has been collapsed.' => 269 + pht('This file content has been collapsed.'), 270 + 'Show Content' => pht('Show Content'), 271 + 272 + 'Hide or show the current file.' => 273 + pht('Hide or show the current file.'), 274 + 'You must select a file to hide or show.' => 275 + pht('You must select a file to hide or show.'), 274 276 ), 275 277 )); 276 278
+1
webroot/rsrc/css/application/differential/changeset-view.css
··· 325 325 border: 1px solid {$blue}; 326 326 text-align: center; 327 327 background-color: {$lightblue}; 328 + margin: 8px; 328 329 } 329 330 330 331 .differential-collapse-undo a {
+60 -1
webroot/rsrc/js/application/diff/DiffChangeset.js
··· 55 55 _rightID: null, 56 56 57 57 _inlines: null, 58 + _visible: true, 59 + 60 + _undoNode: null, 58 61 59 62 getLeftChangesetID: function() { 60 63 return this._leftID; ··· 345 348 } 346 349 }); 347 350 351 + if (!this._visible) { 352 + return items; 353 + } 354 + 348 355 var rows = JX.DOM.scry(this._node, 'tr'); 349 356 350 357 var blocks = []; ··· 635 642 // them to this Changeset's list of inlines. 636 643 this.getInlineForRow(row); 637 644 } 638 - } 645 + }, 646 + 647 + toggleVisibility: function() { 648 + this._visible = !this._visible; 649 + 650 + var diff = JX.DOM.find(this._node, 'table', 'differential-diff'); 651 + var undo = this._getUndoNode(); 652 + 653 + if (this._visible) { 654 + JX.DOM.show(diff); 655 + JX.DOM.remove(undo); 656 + } else { 657 + JX.DOM.hide(diff); 658 + JX.DOM.appendContent(diff.parentNode, undo); 659 + } 660 + 661 + JX.Stratcom.invoke('resize'); 662 + }, 663 + 664 + _getUndoNode: function() { 665 + if (!this._undoNode) { 666 + var pht = this.getChangesetList().getTranslations(); 667 + 668 + var link_attributes = { 669 + href: '#' 670 + }; 671 + 672 + var undo_link = JX.$N('a', link_attributes, pht('Show Content')); 673 + 674 + var onundo = JX.bind(this, this._onundo); 675 + JX.DOM.listen(undo_link, 'click', null, onundo); 676 + 677 + var node_attributes = { 678 + className: 'differential-collapse-undo' 679 + }; 639 680 681 + var node_content = [ 682 + pht('This file content has been collapsed.'), 683 + ' ', 684 + undo_link 685 + ]; 686 + 687 + var undo_node = JX.$N('div', node_attributes, node_content); 688 + 689 + this._undoNode = undo_node; 690 + } 691 + 692 + return this._undoNode; 693 + }, 694 + 695 + _onundo: function(e) { 696 + e.kill(); 697 + this.toggleVisibility(); 698 + } 640 699 }, 641 700 642 701 statics: {
+19 -6
webroot/rsrc/js/application/diff/DiffChangesetList.js
··· 161 161 'Jump to previous inline comment, including hidden comments.'); 162 162 this._installJumpKey('P', label, -1, 'comment', true); 163 163 164 + label = pht('Hide or show the current file.'); 165 + this._installKey('h', label, this._onkeytogglefile); 166 + 164 167 label = pht('Jump to the table of contents.'); 165 168 this._installKey('t', label, this._ontoc); 166 169 ··· 385 388 this._warnUser(pht('You must select a comment to mark done.')); 386 389 }, 387 390 391 + _onkeytogglefile: function() { 392 + var cursor = this._cursorItem; 393 + 394 + if (cursor) { 395 + if (cursor.type == 'file') { 396 + cursor.changeset.toggleVisibility(); 397 + return; 398 + } 399 + } 400 + 401 + var pht = this.getTranslations(); 402 + this._warnUser(pht('You must select a file to hide or show.')); 403 + }, 404 + 388 405 _onkeyhide: function() { 389 406 var cursor = this._cursorItem; 390 407 ··· 616 633 617 634 var visible_item = new JX.PHUIXActionView() 618 635 .setHandler(function(e) { 619 - var diff = JX.DOM.scry( 620 - JX.$(data.containerID), 621 - 'table', 622 - 'differential-diff'); 623 - 624 - JX.Stratcom.invoke('differential-toggle-file', null, {diff: diff}); 625 636 e.prevent(); 626 637 menu.close(); 638 + 639 + changeset.toggleVisibility(); 627 640 }); 628 641 list.addItem(visible_item); 629 642
-128
webroot/rsrc/js/application/differential/behavior-toggle-files.js
··· 1 - /** 2 - * @provides javelin-behavior-differential-toggle-files 3 - * @requires javelin-behavior 4 - * javelin-dom 5 - * javelin-stratcom 6 - * phabricator-phtize 7 - */ 8 - 9 - JX.behavior('differential-toggle-files', function(config) { 10 - var pht = JX.phtize(config.pht); 11 - 12 - JX.Stratcom.listen( 13 - 'differential-toggle-file', 14 - null, 15 - function(e) { 16 - if (e.getData().diff.length != 1) { 17 - return; 18 - } 19 - 20 - var diff = e.getData().diff[0], 21 - data = JX.Stratcom.getData(diff); 22 - if (data.hidden) { 23 - data.hidden = false; 24 - JX.DOM.show(diff); 25 - JX.DOM.remove(data.undo); 26 - data.undo = null; 27 - } else { 28 - data.hidden = true; 29 - data.undo = render_collapse_undo(); 30 - JX.DOM.hide(diff); 31 - JX.DOM.listen( 32 - data.undo, 33 - 'click', 34 - 'differential-collapse-undo', 35 - function(e) { 36 - e.kill(); 37 - data.hidden = false; 38 - JX.DOM.show(diff); 39 - JX.DOM.remove(data.undo); 40 - data.undo = null; 41 - }); 42 - JX.DOM.appendContent(diff.parentNode, data.undo); 43 - } 44 - JX.Stratcom.invoke('differential-toggle-file-toggled'); 45 - }); 46 - 47 - JX.Stratcom.listen( 48 - 'differential-toggle-file-request', 49 - null, 50 - function(e) { 51 - var elt = e.getData().element; 52 - while (elt !== document.body) { 53 - if (JX.Stratcom.hasSigil(elt, 'differential-changeset')) { 54 - var diffs = JX.DOM.scry(elt, 'table', 'differential-diff'); 55 - var invoked = false; 56 - for (var i = 0; i < diffs.length; ++i) { 57 - if (JX.Stratcom.getData(diffs[i]).hidden) { 58 - JX.Stratcom.invoke('differential-toggle-file', null, { 59 - diff: [ diffs[i] ] 60 - }); 61 - invoked = true; 62 - } 63 - } 64 - if (!invoked) { 65 - e.prevent(); 66 - } 67 - return; 68 - } 69 - elt = elt.parentNode; 70 - } 71 - e.prevent(); 72 - }); 73 - 74 - JX.Stratcom.listen( 75 - 'click', 76 - 'tag:a', 77 - function(e) { 78 - var link = e.getNode('tag:a'); 79 - var id = link.getAttribute('href'); 80 - if (!id || !id.match(/^#.+/)) { 81 - return; 82 - } 83 - var raw = e.getRawEvent(); 84 - if (raw.altKey || raw.ctrlKey || raw.metaKey || raw.shiftKey) { 85 - return; 86 - } 87 - // The target may have either a matching name or a matching id. 88 - var target; 89 - try { 90 - target = JX.$(id.substr(1)); 91 - } catch(err) { 92 - var named = document.getElementsByName(id.substr(1)); 93 - for (var i = 0; i < named.length; ++i) { 94 - if (named[i].tagName.toLowerCase() == 'a') { 95 - if (target) { 96 - return; 97 - } 98 - target = named[i]; 99 - } 100 - } 101 - if (!target) { 102 - return; 103 - } 104 - } 105 - var event = JX.Stratcom.invoke('differential-toggle-file-request', null, { 106 - element: target 107 - }); 108 - if (!event.getPrevented()) { 109 - // This event is processed after the hash has changed, so it doesn't 110 - // automatically jump there like we want. 111 - JX.DOM.scrollTo(target); 112 - } 113 - }); 114 - 115 - var render_collapse_undo = function() { 116 - var link = JX.$N( 117 - 'a', 118 - {href: '#', sigil: 'differential-collapse-undo'}, 119 - pht('undo')); 120 - 121 - return JX.$N( 122 - 'div', 123 - {className: 'differential-collapse-undo', 124 - sigil: 'differential-collapse-undo-div'}, 125 - [pht('collapsed'), ' ', link]); 126 - }; 127 - 128 - });