diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 45eb9b6314..e5d7e687d8 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -44,7 +44,7 @@ return array( 'rsrc/css/application/config/config-welcome.css' => '6abd79be', 'rsrc/css/application/config/setup-issue.css' => '22270af2', 'rsrc/css/application/config/unhandled-exception.css' => '37d4f9a2', - 'rsrc/css/application/conpherence/durable-column.css' => '9207426d', + 'rsrc/css/application/conpherence/durable-column.css' => '7abcc3f2', 'rsrc/css/application/conpherence/menu.css' => 'c6ac5299', 'rsrc/css/application/conpherence/message-pane.css' => '5930260a', 'rsrc/css/application/conpherence/notification.css' => '04a6e10a', @@ -353,7 +353,7 @@ return array( 'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18', 'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de', 'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => 'efef202b', - 'rsrc/js/application/conpherence/behavior-durable-column.js' => '1eef9f26', + 'rsrc/js/application/conpherence/behavior-durable-column.js' => 'aa3b6c22', 'rsrc/js/application/conpherence/behavior-menu.js' => 'e476c952', 'rsrc/js/application/conpherence/behavior-pontificate.js' => '21ba5861', 'rsrc/js/application/conpherence/behavior-quicksand-blacklist.js' => '7927a7d3', @@ -515,7 +515,7 @@ return array( 'changeset-view-manager' => '88be0133', 'config-options-css' => '7fedf08b', 'config-welcome-css' => '6abd79be', - 'conpherence-durable-column-view' => '9207426d', + 'conpherence-durable-column-view' => '7abcc3f2', 'conpherence-menu-css' => 'c6ac5299', 'conpherence-message-pane-css' => '5930260a', 'conpherence-notification-css' => '04a6e10a', @@ -586,7 +586,7 @@ return array( 'javelin-behavior-diffusion-locate-file' => '6d3e1947', 'javelin-behavior-diffusion-pull-lastmodified' => '2b228192', 'javelin-behavior-doorkeeper-tag' => 'e5822781', - 'javelin-behavior-durable-column' => '1eef9f26', + 'javelin-behavior-durable-column' => 'aa3b6c22', 'javelin-behavior-error-log' => '6882e80a', 'javelin-behavior-fancy-datepicker' => 'c51ae228', 'javelin-behavior-global-drag-and-drop' => '07f199d8', @@ -956,15 +956,6 @@ return array( 'javelin-dom', 'javelin-reactor-dom', ), - '1eef9f26' => array( - 'javelin-behavior', - 'javelin-dom', - 'javelin-stratcom', - 'javelin-scrollbar', - 'javelin-quicksand', - 'phabricator-keyboard-shortcut', - 'conpherence-thread-manager', - ), '1feea462' => array( 'javelin-install', 'javelin-dom', @@ -1666,6 +1657,15 @@ return array( 'javelin-util', 'phabricator-prefab', ), + 'aa3b6c22' => array( + 'javelin-behavior', + 'javelin-dom', + 'javelin-stratcom', + 'javelin-scrollbar', + 'javelin-quicksand', + 'phabricator-keyboard-shortcut', + 'conpherence-thread-manager', + ), 'b1f0ccee' => array( 'javelin-install', 'javelin-dom', diff --git a/src/applications/conpherence/view/ConpherenceDurableColumnView.php b/src/applications/conpherence/view/ConpherenceDurableColumnView.php index 5fe033c12f..9968ddb09a 100644 --- a/src/applications/conpherence/view/ConpherenceDurableColumnView.php +++ b/src/applications/conpherence/view/ConpherenceDurableColumnView.php @@ -5,6 +5,7 @@ final class ConpherenceDurableColumnView extends AphrontTagView { private $conpherences; private $selectedConpherence; private $transactions; + private $visible; public function setConpherences(array $conpherences) { assert_instances_of($conpherences, 'ConpherenceThread'); @@ -36,16 +37,40 @@ final class ConpherenceDurableColumnView extends AphrontTagView { return $this->transactions; } + public function setVisible($visible) { + $this->visible = $visible; + return $this; + } + + public function getVisible() { + return $this->visible; + } + protected function getTagAttributes() { + if ($this->getVisible()) { + $style = null; + } else { + $style = 'display: none;'; + } + return array( 'id' => 'conpherence-durable-column', 'class' => 'conpherence-durable-column', - 'style' => 'display: none;', + 'style' => $style, 'sigil' => 'conpherence-durable-column', ); } protected function getTagContent() { + $column_key = PhabricatorUserPreferences::PREFERENCE_CONPHERENCE_COLUMN; + + Javelin::initBehavior( + 'durable-column', + array( + 'visible' => $this->getVisible(), + 'settingsURI' => '/settings/adjust/?key='.$column_key, + )); + $classes = array(); $classes[] = 'conpherence-durable-column-header'; $classes[] = 'sprite-main-header'; diff --git a/src/applications/settings/storage/PhabricatorUserPreferences.php b/src/applications/settings/storage/PhabricatorUserPreferences.php index b1d4854d4f..2e1576653b 100644 --- a/src/applications/settings/storage/PhabricatorUserPreferences.php +++ b/src/applications/settings/storage/PhabricatorUserPreferences.php @@ -31,7 +31,8 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO { const PREFERENCE_DIFF_UNIFIED = 'diff-unified'; const PREFERENCE_DIFF_FILETREE = 'diff-filetree'; - const PREFERENCE_CONPH_NOTIFICATIONS = 'conph-notifications'; + const PREFERENCE_CONPH_NOTIFICATIONS = 'conph-notifications'; + const PREFERENCE_CONPHERENCE_COLUMN = 'conpherence-column'; // These are in an unusual order for historic reasons. const MAILTAG_PREFERENCE_NOTIFY = 0; diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php index d2925793f3..091c526679 100644 --- a/src/view/page/PhabricatorStandardPageView.php +++ b/src/view/page/PhabricatorStandardPageView.php @@ -108,16 +108,18 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { return true; } - public function getTitle() { - $use_glyph = true; + public function getDurableColumnVisible() { + $column_key = PhabricatorUserPreferences::PREFERENCE_CONPHERENCE_COLUMN; + return (bool)$this->getUserPreference($column_key, 0); + } - $request = $this->getRequest(); - if ($request) { - $user = $request->getUser(); - if ($user && $user->loadPreferences()->getPreference( - PhabricatorUserPreferences::PREFERENCE_TITLES) !== 'glyph') { - $use_glyph = false; - } + + public function getTitle() { + $glyph_key = PhabricatorUserPreferences::PREFERENCE_TITLES; + if ($this->getUserPreference($glyph_key) == 'text') { + $use_glyph = false; + } else { + $use_glyph = true; } $title = parent::getTitle(); @@ -416,12 +418,11 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { $durable_column = null; if ($this->getShowDurableColumn()) { + $is_visible = $this->getDurableColumnVisible(); $durable_column = id(new ConpherenceDurableColumnView()) ->setSelectedConpherence(null) - ->setUser($user); - Javelin::initBehavior( - 'durable-column', - array()); + ->setUser($user) + ->setVisible($is_visible); } Javelin::initBehavior('quicksand-blacklist', array( @@ -611,4 +612,18 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { return array_mergev($blacklist); } + private function getUserPreference($key, $default = null) { + $request = $this->getRequest(); + if (!$request) { + return $default; + } + + $user = $request->getUser(); + if (!$user) { + return $default; + } + + return $user->loadPreferences()->getPreference($key, $default); + } + } diff --git a/webroot/rsrc/js/application/conpherence/behavior-durable-column.js b/webroot/rsrc/js/application/conpherence/behavior-durable-column.js index 63484821d2..dc7c6a830d 100644 --- a/webroot/rsrc/js/application/conpherence/behavior-durable-column.js +++ b/webroot/rsrc/js/application/conpherence/behavior-durable-column.js @@ -9,7 +9,19 @@ * conpherence-thread-manager */ -JX.behavior('durable-column', function() { +JX.behavior('durable-column', function(config, statics) { + // TODO: Currently, updating the column sends the entire column back. This + // includes the `durable-column` behavior itself, which tries to re-initialize + // the column. Detect this and bail. + // + // If ThreadManager gets separated into a UI part and a thread part (which + // seems likely), responses may no longer ship back the entire column. This + // might let us remove this check. + if (statics.initialized) { + return; + } else { + statics.initialized = true; + } var show = false; var loadThreadID = null; @@ -27,10 +39,7 @@ JX.behavior('durable-column', function() { return JX.DOM.find(column, 'div', 'conpherence-durable-column-main'); } - function _toggleColumn() { - if (window.location.pathname.indexOf('/conpherence/') === 0) { - return; - } + function _toggleColumn(explicit) { show = !show; JX.DOM.alterClass(frame, 'with-durable-column', show); var column = JX.$('conpherence-durable-column'); @@ -42,10 +51,18 @@ JX.behavior('durable-column', function() { } JX.Stratcom.invoke('resize'); JX.Quicksand.setFrame(show ? quick : null); + + // If this was an explicit toggle action from the user, save their + // preference. + if (explicit) { + new JX.Request(config.settingsURI) + .setData({value: (show ? 1 : 0)}) + .send(); + } } new JX.KeyboardShortcut('\\', 'Toggle Conpherence Column') - .setHandler(_toggleColumn) + .setHandler(JX.bind(null, _toggleColumn, true)) .register(); scrollbar = new JX.Scrollbar(_getColumnScrollNode()); @@ -55,6 +72,7 @@ JX.behavior('durable-column', function() { /* Conpherence Thread Manager configuration - lots of display * callbacks. */ + var threadManager = new JX.ConpherenceThreadManager(); threadManager.setMinimalDisplay(true); threadManager.setLoadThreadURI('/conpherence/columnview/'); @@ -216,4 +234,8 @@ JX.behavior('durable-column', function() { 'conpherence-message-form', _sendMessage); + if (config.visible) { + _toggleColumn(false); + } + });