mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Make durable column sticky across requests
Summary: When you open the column, keep it open on future requests. Test Plan: Opened column, clicked to Conpherence (no column), clicked elsewhere (column again), reloaded page (column), closed column, clicked something (no column). Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D12038
This commit is contained in:
parent
6fa507987d
commit
88b46063b4
5 changed files with 97 additions and 34 deletions
|
@ -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',
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -32,6 +32,7 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO {
|
|||
const PREFERENCE_DIFF_FILETREE = 'diff-filetree';
|
||||
|
||||
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;
|
||||
|
|
|
@ -108,16 +108,18 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
$use_glyph = true;
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request) {
|
||||
$user = $request->getUser();
|
||||
if ($user && $user->loadPreferences()->getPreference(
|
||||
PhabricatorUserPreferences::PREFERENCE_TITLES) !== 'glyph') {
|
||||
$use_glyph = false;
|
||||
public function getDurableColumnVisible() {
|
||||
$column_key = PhabricatorUserPreferences::PREFERENCE_CONPHERENCE_COLUMN;
|
||||
return (bool)$this->getUserPreference($column_key, 0);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue