mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-02 03:32:42 +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')
|
->setAnchorName('top')
|
||||||
->setNavigationMarker(true);
|
->setNavigationMarker(true);
|
||||||
|
|
||||||
|
$collapsed = $user->loadPreferences()->getPreference(
|
||||||
|
PhabricatorUserPreferences::PREFERENCE_NAV_COLLAPSED,
|
||||||
|
false);
|
||||||
|
|
||||||
$nav = id(new DifferentialChangesetFileTreeSideNavBuilder())
|
$nav = id(new DifferentialChangesetFileTreeSideNavBuilder())
|
||||||
->setAnchorName('top')
|
->setAnchorName('top')
|
||||||
->setTitle('D'.$revision->getID())
|
->setTitle('D'.$revision->getID())
|
||||||
->setBaseURI(new PhutilURI('/D'.$revision->getID()))
|
->setBaseURI(new PhutilURI('/D'.$revision->getID()))
|
||||||
|
->setCollapsed((bool)$collapsed)
|
||||||
->build($changesets);
|
->build($changesets);
|
||||||
$nav->appendChild(
|
$nav->appendChild(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -5,6 +5,7 @@ final class DifferentialChangesetFileTreeSideNavBuilder {
|
||||||
private $title;
|
private $title;
|
||||||
private $baseURI;
|
private $baseURI;
|
||||||
private $anchorName;
|
private $anchorName;
|
||||||
|
private $collapsed = false;
|
||||||
|
|
||||||
public function setAnchorName($anchor_name) {
|
public function setAnchorName($anchor_name) {
|
||||||
$this->anchorName = $anchor_name;
|
$this->anchorName = $anchor_name;
|
||||||
|
@ -30,12 +31,18 @@ final class DifferentialChangesetFileTreeSideNavBuilder {
|
||||||
return $this->title;
|
return $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setCollapsed($collapsed) {
|
||||||
|
$this->collapsed = $collapsed;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function build(array $changesets) {
|
public function build(array $changesets) {
|
||||||
assert_instances_of($changesets, 'DifferentialChangeset');
|
assert_instances_of($changesets, 'DifferentialChangeset');
|
||||||
|
|
||||||
$nav = new AphrontSideNavFilterView();
|
$nav = new AphrontSideNavFilterView();
|
||||||
$nav->setBaseURI($this->getBaseURI());
|
$nav->setBaseURI($this->getBaseURI());
|
||||||
$nav->setFlexible(true);
|
$nav->setFlexible(true);
|
||||||
|
$nav->setCollapsed($this->collapsed);
|
||||||
|
|
||||||
$anchor = $this->getAnchorName();
|
$anchor = $this->getAnchorName();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO {
|
||||||
|
|
||||||
const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view';
|
const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view';
|
||||||
|
|
||||||
|
const PREFERENCE_NAV_COLLAPSED = 'nav-collapsed';
|
||||||
const PREFERENCE_NAV_WIDTH = 'nav-width';
|
const PREFERENCE_NAV_WIDTH = 'nav-width';
|
||||||
const PREFERENCE_APP_TILES = 'app-tiles';
|
const PREFERENCE_APP_TILES = 'app-tiles';
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ final class AphrontSideNavFilterView extends AphrontView {
|
||||||
private $baseURI;
|
private $baseURI;
|
||||||
private $selectedFilter = false;
|
private $selectedFilter = false;
|
||||||
private $flexible;
|
private $flexible;
|
||||||
|
private $collapsed = false;
|
||||||
private $active;
|
private $active;
|
||||||
private $menu;
|
private $menu;
|
||||||
private $crumbs;
|
private $crumbs;
|
||||||
|
@ -70,6 +71,11 @@ final class AphrontSideNavFilterView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setCollapsed($collapsed) {
|
||||||
|
$this->collapsed = $collapsed;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getMenuView() {
|
public function getMenuView() {
|
||||||
return $this->menu;
|
return $this->menu;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +202,6 @@ final class AphrontSideNavFilterView extends AphrontView {
|
||||||
$main_id = celerity_generate_unique_node_id();
|
$main_id = celerity_generate_unique_node_id();
|
||||||
|
|
||||||
if ($this->flexible) {
|
if ($this->flexible) {
|
||||||
$nav_classes[] = 'has-drag-nav';
|
|
||||||
$drag_id = celerity_generate_unique_node_id();
|
$drag_id = celerity_generate_unique_node_id();
|
||||||
$flex_bar = phutil_render_tag(
|
$flex_bar = phutil_render_tag(
|
||||||
'div',
|
'div',
|
||||||
|
@ -213,7 +218,10 @@ final class AphrontSideNavFilterView extends AphrontView {
|
||||||
if ($this->menu->getItems()) {
|
if ($this->menu->getItems()) {
|
||||||
$local_id = celerity_generate_unique_node_id();
|
$local_id = celerity_generate_unique_node_id();
|
||||||
$background_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(
|
$menu_background = phutil_render_tag(
|
||||||
'div',
|
'div',
|
||||||
|
@ -240,7 +248,9 @@ final class AphrontSideNavFilterView extends AphrontView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->flexible) {
|
if ($this->flexible) {
|
||||||
$nav_classes[] = 'has-drag-nav';
|
if (!$this->collapsed) {
|
||||||
|
$nav_classes[] = 'has-drag-nav';
|
||||||
|
}
|
||||||
|
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
'phabricator-nav',
|
'phabricator-nav',
|
||||||
|
@ -250,6 +260,7 @@ final class AphrontSideNavFilterView extends AphrontView {
|
||||||
'dragID' => $drag_id,
|
'dragID' => $drag_id,
|
||||||
'contentID' => $content_id,
|
'contentID' => $content_id,
|
||||||
'backgroundID' => $background_id,
|
'backgroundID' => $background_id,
|
||||||
|
'collapsed' => $this->collapsed,
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($this->active) {
|
if ($this->active) {
|
||||||
|
|
|
@ -109,12 +109,15 @@ JX.behavior('phabricator-nav', function(config) {
|
||||||
content.style.marginLeft = '';
|
content.style.marginLeft = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
var collapsed = false;
|
var collapsed = config.collapsed;
|
||||||
JX.Stratcom.listen('differential-filetree-toggle', null, function(e) {
|
JX.Stratcom.listen('differential-filetree-toggle', null, function(e) {
|
||||||
collapsed = !collapsed;
|
collapsed = !collapsed;
|
||||||
JX.DOM.alterClass(main, 'has-local-nav', !collapsed);
|
JX.DOM.alterClass(main, 'has-local-nav', !collapsed);
|
||||||
JX.DOM.alterClass(main, 'has-drag-nav', !collapsed);
|
JX.DOM.alterClass(main, 'has-drag-nav', !collapsed);
|
||||||
resetdrag();
|
resetdrag();
|
||||||
|
new JX.Request('/settings/adjust/', JX.Bag)
|
||||||
|
.setData({ key : 'nav-collapsed', value : (collapsed ? 1 : 0) })
|
||||||
|
.send();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue