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

Make the filetree view width sticky across show/hide and reload

Summary:
Ref T13090. The default width changed recently to become much wider, but the behavior on this control isn't great. Instead:

- Pick a default width somewhere between the two.
- Make the width sticky across show/hide (pressing "f" twice remembers your width instead of resetting it).
- Make the width sticky across reloads (dragging the bar, then reloading the page keeps the bar in the same place).

Test Plan:
- Without settings, loaded page: got medium-width bar.
- Dragged bar wide/narrow, toggled on/off with "f", got persistent width.
- Dragged bar wide/narrow, reloaded page, got persistent width.
- Dragged bar wide/narrow, toggled it off, reloaded page, toggled it on, got persistent width.

Maniphest Tasks: T13090

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

+124 -39
+11 -11
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => 'e68cf1fa', 11 11 'conpherence.pkg.js' => '15191c65', 12 - 'core.pkg.css' => 'e4f098a5', 13 - 'core.pkg.js' => 'bd19de1c', 12 + 'core.pkg.css' => '2fa91e14', 13 + 'core.pkg.js' => 'dc13d4b7', 14 14 'darkconsole.pkg.js' => '1f9a31bc', 15 15 'differential.pkg.css' => '113e692c', 16 16 'differential.pkg.js' => 'f6d809c0', ··· 31 31 'rsrc/css/aphront/multi-column.css' => '84cc6640', 32 32 'rsrc/css/aphront/notification.css' => '457861ec', 33 33 'rsrc/css/aphront/panel-view.css' => '8427b78d', 34 - 'rsrc/css/aphront/phabricator-nav-view.css' => '028126f6', 34 + 'rsrc/css/aphront/phabricator-nav-view.css' => 'a9e3e6d5', 35 35 'rsrc/css/aphront/table-view.css' => '8c9bbafe', 36 36 'rsrc/css/aphront/tokenizer.css' => '15d5ff71', 37 37 'rsrc/css/aphront/tooltip.css' => '173b9431', ··· 498 498 'rsrc/js/core/behavior-more.js' => 'a80d0378', 499 499 'rsrc/js/core/behavior-object-selector.js' => '77c1f0b0', 500 500 'rsrc/js/core/behavior-oncopy.js' => '2926fff2', 501 - 'rsrc/js/core/behavior-phabricator-nav.js' => '81144dfa', 501 + 'rsrc/js/core/behavior-phabricator-nav.js' => '836f966d', 502 502 'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => 'acd29eee', 503 503 'rsrc/js/core/behavior-read-only-warning.js' => 'ba158207', 504 504 'rsrc/js/core/behavior-refresh-csrf.js' => 'ab2f381b', ··· 657 657 'javelin-behavior-phabricator-keyboard-pager' => 'a8da01f0', 658 658 'javelin-behavior-phabricator-keyboard-shortcuts' => '01fca1f0', 659 659 'javelin-behavior-phabricator-line-linker' => '1499a8cb', 660 - 'javelin-behavior-phabricator-nav' => '81144dfa', 660 + 'javelin-behavior-phabricator-nav' => '836f966d', 661 661 'javelin-behavior-phabricator-notification-example' => '8ce821c5', 662 662 'javelin-behavior-phabricator-object-selector' => '77c1f0b0', 663 663 'javelin-behavior-phabricator-oncopy' => '2926fff2', ··· 789 789 'phabricator-keyboard-shortcut' => '1ae869f2', 790 790 'phabricator-keyboard-shortcut-manager' => 'c19dd9b9', 791 791 'phabricator-main-menu-view' => '1802a242', 792 - 'phabricator-nav-view-css' => '028126f6', 792 + 'phabricator-nav-view-css' => 'a9e3e6d5', 793 793 'phabricator-notification' => '008faf9c', 794 794 'phabricator-notification-css' => '457861ec', 795 795 'phabricator-notification-menu-css' => '10685bd4', ··· 1563 1563 'phuix-icon-view', 1564 1564 'phabricator-prefab', 1565 1565 ), 1566 - '81144dfa' => array( 1566 + '834a1173' => array( 1567 + 'javelin-behavior', 1568 + 'javelin-scrollbar', 1569 + ), 1570 + '836f966d' => array( 1567 1571 'javelin-behavior', 1568 1572 'javelin-behavior-device', 1569 1573 'javelin-stratcom', ··· 1572 1576 'javelin-vector', 1573 1577 'javelin-request', 1574 1578 'javelin-util', 1575 - ), 1576 - '834a1173' => array( 1577 - 'javelin-behavior', 1578 - 'javelin-scrollbar', 1579 1579 ), 1580 1580 '8499b6ab' => array( 1581 1581 'javelin-behavior',
+2
src/__phutil_library_map__.php
··· 3046 3046 'PhabricatorFilesOnDiskBuiltinFile' => 'applications/files/builtin/PhabricatorFilesOnDiskBuiltinFile.php', 3047 3047 'PhabricatorFilesOutboundRequestAction' => 'applications/files/action/PhabricatorFilesOutboundRequestAction.php', 3048 3048 'PhabricatorFiletreeVisibleSetting' => 'applications/settings/setting/PhabricatorFiletreeVisibleSetting.php', 3049 + 'PhabricatorFiletreeWidthSetting' => 'applications/settings/setting/PhabricatorFiletreeWidthSetting.php', 3049 3050 'PhabricatorFlag' => 'applications/flag/storage/PhabricatorFlag.php', 3050 3051 'PhabricatorFlagAddFlagHeraldAction' => 'applications/flag/herald/PhabricatorFlagAddFlagHeraldAction.php', 3051 3052 'PhabricatorFlagColor' => 'applications/flag/constants/PhabricatorFlagColor.php', ··· 8613 8614 'PhabricatorFilesOnDiskBuiltinFile' => 'PhabricatorFilesBuiltinFile', 8614 8615 'PhabricatorFilesOutboundRequestAction' => 'PhabricatorSystemAction', 8615 8616 'PhabricatorFiletreeVisibleSetting' => 'PhabricatorInternalSetting', 8617 + 'PhabricatorFiletreeWidthSetting' => 'PhabricatorInternalSetting', 8616 8618 'PhabricatorFlag' => array( 8617 8619 'PhabricatorFlagDAO', 8618 8620 'PhabricatorPolicyInterface',
+4
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 473 473 $collapsed_key = PhabricatorFiletreeVisibleSetting::SETTINGKEY; 474 474 $collapsed_value = $viewer->getUserSetting($collapsed_key); 475 475 476 + $width_key = PhabricatorFiletreeWidthSetting::SETTINGKEY; 477 + $width_value = $viewer->getUserSetting($width_key); 478 + 476 479 $nav = id(new DifferentialChangesetFileTreeSideNavBuilder()) 477 480 ->setTitle($monogram) 478 481 ->setBaseURI(new PhutilURI($revision->getURI())) 479 482 ->setCollapsed((bool)$collapsed_value) 483 + ->setWidth((int)$width_value) 480 484 ->build($changesets); 481 485 } 482 486
+11 -4
src/applications/differential/view/DifferentialChangesetFileTreeSideNavBuilder.php
··· 6 6 private $baseURI; 7 7 private $anchorName; 8 8 private $collapsed = false; 9 + private $width; 9 10 10 11 public function setAnchorName($anchor_name) { 11 12 $this->anchorName = $anchor_name; ··· 36 37 return $this; 37 38 } 38 39 40 + public function setWidth($width) { 41 + $this->width = $width; 42 + return $this; 43 + } 44 + 39 45 public function build(array $changesets) { 40 46 assert_instances_of($changesets, 'DifferentialChangeset'); 41 47 42 - $nav = new AphrontSideNavFilterView(); 43 - $nav->setBaseURI($this->getBaseURI()); 44 - $nav->setFlexible(true); 45 - $nav->setCollapsed($this->collapsed); 48 + $nav = id(new AphrontSideNavFilterView()) 49 + ->setBaseURI($this->getBaseURI()) 50 + ->setFlexible(true) 51 + ->setCollapsed($this->collapsed) 52 + ->setWidth($this->width); 46 53 47 54 $anchor = $this->getAnchorName(); 48 55
+8 -4
src/applications/diffusion/controller/DiffusionCommitController.php
··· 415 415 PhabricatorShowFiletreeSetting::SETTINGKEY, 416 416 PhabricatorShowFiletreeSetting::VALUE_ENABLE_FILETREE); 417 417 418 - $pref_collapse = PhabricatorFiletreeVisibleSetting::SETTINGKEY; 419 - $collapsed = $viewer->getUserSetting($pref_collapse); 420 - 421 418 $nav = null; 422 419 if ($show_changesets && $filetree_on) { 420 + $pref_collapse = PhabricatorFiletreeVisibleSetting::SETTINGKEY; 421 + $collapsed = $viewer->getUserSetting($pref_collapse); 422 + 423 + $pref_width = PhabricatorFiletreeWidthSetting::SETTINGKEY; 424 + $width = $viewer->getUserSetting($pref_width); 425 + 423 426 $nav = id(new DifferentialChangesetFileTreeSideNavBuilder()) 424 427 ->setTitle($commit->getDisplayName()) 425 428 ->setBaseURI(new PhutilURI($commit->getURI())) 426 429 ->build($changesets) 427 430 ->setCrumbs($crumbs) 428 - ->setCollapsed((bool)$collapsed); 431 + ->setCollapsed((bool)$collapsed) 432 + ->setWidth((int)$width); 429 433 } 430 434 431 435 $view = id(new PHUITwoColumnView())
+12
src/applications/settings/setting/PhabricatorFiletreeWidthSetting.php
··· 1 + <?php 2 + 3 + final class PhabricatorFiletreeWidthSetting 4 + extends PhabricatorInternalSetting { 5 + 6 + const SETTINGKEY = 'filetree.width'; 7 + 8 + public function getSettingName() { 9 + return pht('Filetree Width'); 10 + } 11 + 12 + }
+41 -14
src/view/layout/AphrontSideNavFilterView.php
··· 30 30 private $mainID; 31 31 private $isProfileMenu; 32 32 private $footer = array(); 33 + private $width; 33 34 34 35 public function setMenuID($menu_id) { 35 36 $this->menuID = $menu_id; ··· 79 80 80 81 public function setCollapsed($collapsed) { 81 82 $this->collapsed = $collapsed; 83 + return $this; 84 + } 85 + 86 + public function setWidth($width) { 87 + $this->width = $width; 82 88 return $this; 83 89 } 84 90 ··· 216 222 $local_menu = null; 217 223 $main_id = $this->getMainID(); 218 224 225 + $width = $this->width; 226 + if ($width) { 227 + $width = min($width, 600); 228 + $width = max($width, 150); 229 + } else { 230 + $width = null; 231 + } 232 + 233 + if ($width && !$this->collapsed) { 234 + $width_drag_style = 'left: '.$width.'px'; 235 + $width_panel_style = 'width: '.$width.'px'; 236 + $width_margin_style = 'margin-left: '.($width + 7).'px'; 237 + } else { 238 + $width_drag_style = null; 239 + $width_panel_style = null; 240 + $width_margin_style = null; 241 + } 242 + 219 243 if ($this->flexible) { 220 244 $drag_id = celerity_generate_unique_node_id(); 221 245 $flex_bar = phutil_tag( ··· 223 247 array( 224 248 'class' => 'phabricator-nav-drag', 225 249 'id' => $drag_id, 250 + 'style' => $width_drag_style, 226 251 ), 227 252 ''); 228 253 } else { ··· 238 263 $nav_classes[] = 'has-local-nav'; 239 264 } 240 265 241 - $local_menu = 242 - phutil_tag( 243 - 'div', 244 - array( 245 - 'class' => 'phabricator-nav-local phabricator-side-menu', 246 - 'id' => $local_id, 247 - ), 248 - $this->menu->setID($this->getMenuID())); 266 + $local_menu = phutil_tag( 267 + 'div', 268 + array( 269 + 'class' => 'phabricator-nav-local phabricator-side-menu', 270 + 'id' => $local_id, 271 + 'style' => $width_panel_style, 272 + ), 273 + $this->menu->setID($this->getMenuID())); 249 274 } 250 275 251 276 $crumbs = null; ··· 264 289 Javelin::initBehavior( 265 290 'phabricator-nav', 266 291 array( 267 - 'mainID' => $main_id, 268 - 'localID' => $local_id, 269 - 'dragID' => $drag_id, 270 - 'contentID' => $content_id, 271 - 'backgroundID' => $background_id, 272 - 'collapsed' => $this->collapsed, 292 + 'mainID' => $main_id, 293 + 'localID' => $local_id, 294 + 'dragID' => $drag_id, 295 + 'contentID' => $content_id, 296 + 'backgroundID' => $background_id, 297 + 'collapsed' => $this->collapsed, 298 + 'width' => $width, 273 299 )); 274 300 275 301 if ($this->active) { ··· 297 323 array( 298 324 'class' => 'phabricator-nav-content plb', 299 325 'id' => $content_id, 326 + 'style' => $width_margin_style, 300 327 ), 301 328 array( 302 329 $crumbs,
+3 -3
webroot/rsrc/css/aphront/phabricator-nav-view.css
··· 44 44 position: fixed; 45 45 top: 0; 46 46 bottom: 0; 47 - left: 410px; 47 + left: 310px; 48 48 width: 7px; 49 49 50 50 cursor: col-resize; ··· 66 66 67 67 .device-desktop .phabricator-standard-page-body .has-drag-nav 68 68 .phabricator-nav-content { 69 - margin-left: 417px; 69 + margin-left: 317px; 70 70 } 71 71 72 72 .device-desktop .phabricator-standard-page-body .has-drag-nav ··· 81 81 } 82 82 83 83 .device-desktop .phui-navigation-shell .has-drag-nav .phabricator-nav-local { 84 - width: 410px; 84 + width: 310px; 85 85 padding: 0; 86 86 background: transparent; 87 87 }
+32 -3
webroot/rsrc/js/core/behavior-phabricator-nav.js
··· 18 18 var main = JX.$(config.mainID); 19 19 var drag = JX.$(config.dragID); 20 20 21 - 22 21 // - Flexible Navigation Column ------------------------------------------------ 23 22 24 23 ··· 98 97 } 99 98 JX.DOM.alterClass(document.body, 'jx-drag-col', false); 100 99 dragging = false; 100 + 101 + new JX.Request('/settings/adjust/', JX.bag) 102 + .setData( 103 + { 104 + key: 'filetree.width', 105 + value: JX.$V(drag).x 106 + }) 107 + .send(); 101 108 }); 102 109 103 110 104 - function resetdrag() { 111 + var saved_width = config.width; 112 + function savedrag() { 113 + saved_width = JX.$V(drag).x; 114 + 105 115 local.style.width = ''; 106 116 drag.style.left = ''; 107 117 content.style.marginLeft = ''; 108 118 } 109 119 120 + function restoredrag() { 121 + if (!saved_width) { 122 + return; 123 + } 124 + 125 + local.style.width = saved_width + 'px'; 126 + drag.style.left = saved_width + 'px'; 127 + content.style.marginLeft = (saved_width + JX.Vector.getDim(drag).x) + 'px'; 128 + } 129 + 110 130 var collapsed = config.collapsed; 111 131 JX.Stratcom.listen('differential-filetree-toggle', null, function() { 112 132 collapsed = !collapsed; 133 + 134 + if (collapsed) { 135 + savedrag(); 136 + } 137 + 113 138 JX.DOM.alterClass(main, 'has-local-nav', !collapsed); 114 139 JX.DOM.alterClass(main, 'has-drag-nav', !collapsed); 115 140 JX.DOM.alterClass(main, 'has-closed-nav', collapsed); 116 - resetdrag(); 141 + 142 + if (!collapsed) { 143 + restoredrag(); 144 + } 145 + 117 146 new JX.Request('/settings/adjust/', JX.bag) 118 147 .setData({ key : 'nav-collapsed', value : (collapsed ? 1 : 0) }) 119 148 .send();