diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php index 2ede65d59b..d55e5d3ce9 100644 --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -408,10 +408,15 @@ final class DifferentialRevisionViewController extends DifferentialController { ->setAnchorName('top') ->setNavigationMarker(true); + $collapsed = $user->loadPreferences()->getPreference( + PhabricatorUserPreferences::PREFERENCE_NAV_COLLAPSED, + false); + $nav = id(new DifferentialChangesetFileTreeSideNavBuilder()) ->setAnchorName('top') ->setTitle('D'.$revision->getID()) ->setBaseURI(new PhutilURI('/D'.$revision->getID())) + ->setCollapsed((bool)$collapsed) ->build($changesets); $nav->appendChild( array( diff --git a/src/applications/differential/view/DifferentialChangesetFileTreeSideNavBuilder.php b/src/applications/differential/view/DifferentialChangesetFileTreeSideNavBuilder.php index e13117d2b5..ecb3e80504 100644 --- a/src/applications/differential/view/DifferentialChangesetFileTreeSideNavBuilder.php +++ b/src/applications/differential/view/DifferentialChangesetFileTreeSideNavBuilder.php @@ -5,6 +5,7 @@ final class DifferentialChangesetFileTreeSideNavBuilder { private $title; private $baseURI; private $anchorName; + private $collapsed = false; public function setAnchorName($anchor_name) { $this->anchorName = $anchor_name; @@ -30,12 +31,18 @@ final class DifferentialChangesetFileTreeSideNavBuilder { return $this->title; } + public function setCollapsed($collapsed) { + $this->collapsed = $collapsed; + return $this; + } + public function build(array $changesets) { assert_instances_of($changesets, 'DifferentialChangeset'); $nav = new AphrontSideNavFilterView(); $nav->setBaseURI($this->getBaseURI()); $nav->setFlexible(true); + $nav->setCollapsed($this->collapsed); $anchor = $this->getAnchorName(); diff --git a/src/applications/settings/storage/PhabricatorUserPreferences.php b/src/applications/settings/storage/PhabricatorUserPreferences.php index e5910cf833..1b23ee082d 100644 --- a/src/applications/settings/storage/PhabricatorUserPreferences.php +++ b/src/applications/settings/storage/PhabricatorUserPreferences.php @@ -19,6 +19,7 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO { const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view'; + const PREFERENCE_NAV_COLLAPSED = 'nav-collapsed'; const PREFERENCE_NAV_WIDTH = 'nav-width'; const PREFERENCE_APP_TILES = 'app-tiles'; diff --git a/src/view/layout/AphrontSideNavFilterView.php b/src/view/layout/AphrontSideNavFilterView.php index 1ff467b523..6b17e12024 100644 --- a/src/view/layout/AphrontSideNavFilterView.php +++ b/src/view/layout/AphrontSideNavFilterView.php @@ -21,6 +21,7 @@ final class AphrontSideNavFilterView extends AphrontView { private $baseURI; private $selectedFilter = false; private $flexible; + private $collapsed = false; private $active; private $menu; private $crumbs; @@ -70,6 +71,11 @@ final class AphrontSideNavFilterView extends AphrontView { return $this; } + public function setCollapsed($collapsed) { + $this->collapsed = $collapsed; + return $this; + } + public function getMenuView() { return $this->menu; } @@ -196,7 +202,6 @@ final class AphrontSideNavFilterView extends AphrontView { $main_id = celerity_generate_unique_node_id(); if ($this->flexible) { - $nav_classes[] = 'has-drag-nav'; $drag_id = celerity_generate_unique_node_id(); $flex_bar = phutil_render_tag( 'div', @@ -213,7 +218,10 @@ final class AphrontSideNavFilterView extends AphrontView { if ($this->menu->getItems()) { $local_id = celerity_generate_unique_node_id(); $background_id = celerity_generate_unique_node_id(); - $nav_classes[] = 'has-local-nav'; + + if (!$this->collapsed) { + $nav_classes[] = 'has-local-nav'; + } $menu_background = phutil_render_tag( 'div', @@ -240,7 +248,9 @@ final class AphrontSideNavFilterView extends AphrontView { } if ($this->flexible) { - $nav_classes[] = 'has-drag-nav'; + if (!$this->collapsed) { + $nav_classes[] = 'has-drag-nav'; + } Javelin::initBehavior( 'phabricator-nav', @@ -250,6 +260,7 @@ final class AphrontSideNavFilterView extends AphrontView { 'dragID' => $drag_id, 'contentID' => $content_id, 'backgroundID' => $background_id, + 'collapsed' => $this->collapsed, )); if ($this->active) { diff --git a/webroot/rsrc/js/application/core/behavior-phabricator-nav.js b/webroot/rsrc/js/application/core/behavior-phabricator-nav.js index eae6708061..0df0967279 100644 --- a/webroot/rsrc/js/application/core/behavior-phabricator-nav.js +++ b/webroot/rsrc/js/application/core/behavior-phabricator-nav.js @@ -109,12 +109,15 @@ JX.behavior('phabricator-nav', function(config) { content.style.marginLeft = ''; } - var collapsed = false; + var collapsed = config.collapsed; JX.Stratcom.listen('differential-filetree-toggle', null, function(e) { collapsed = !collapsed; JX.DOM.alterClass(main, 'has-local-nav', !collapsed); JX.DOM.alterClass(main, 'has-drag-nav', !collapsed); resetdrag(); + new JX.Request('/settings/adjust/', JX.Bag) + .setData({ key : 'nav-collapsed', value : (collapsed ? 1 : 0) }) + .send(); });