mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 18:22:41 +01:00
Make collapsed navigation sticky
Summary: This is the most requested feature in FB by far. Test Plan: Toggled, verified that data are saved. Reloaded, toggled, toggled, toggled, verified that data are saved. Reloaded. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4812
This commit is contained in:
parent
1322e9eda2
commit
0bb62d0c31
5 changed files with 31 additions and 4 deletions
|
@ -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(
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue