Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
/**
|
|
|
|
* @provides changeset-view-manager
|
|
|
|
* @requires javelin-dom
|
|
|
|
* javelin-util
|
|
|
|
* javelin-stratcom
|
|
|
|
* javelin-install
|
|
|
|
* javelin-workflow
|
|
|
|
* javelin-router
|
|
|
|
* javelin-behavior-device
|
|
|
|
* javelin-vector
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
JX.install('ChangesetViewManager', {
|
|
|
|
|
|
|
|
construct : function(node) {
|
|
|
|
this._node = node;
|
|
|
|
|
|
|
|
var data = this._getNodeData();
|
|
|
|
this._renderURI = data.renderURI;
|
|
|
|
this._ref = data.ref;
|
|
|
|
this._whitespace = data.whitespace;
|
|
|
|
this._renderer = data.renderer;
|
|
|
|
this._highlight = data.highlight;
|
2014-06-20 20:49:41 +02:00
|
|
|
this._encoding = data.encoding;
|
Use ChangesetListView on Differential standalone view
Summary:
Fixes T4452. Ref T2009. There's a hierarchy of changeset rendering power: only low-level calls, use of ChangesetDetailView, then use of ChangesetListView (a list of DetailViews).
Prior to work here, the various changeset rendering controllers got their hands dirty to varying degrees, with some using only the lowest-level rendering pipeline:
- Phriction: no view (lowest level)
- Diffusion: DetailView
- Differential Changeset: DetailView
- Differential Diff: ListView
- Differential Revision: ListView
I brought Phriction up to use DetailView, but want to bring everything all the way up to use ListView. Each composition layer adds more features to diff browsing. In particular, this change enables "Highlight As", switching 1up vs 2up, adding inlines, etc., on the standalone view.
Test Plan:
- Viewed a changeset standalone. Could change highlighting, switch 1up vs 2up, add and edit inlines, etc.
- Viewed a revision; no behavioral changes.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T4452, T2009
Differential Revision: https://secure.phabricator.com/D12012
2015-03-08 12:10:11 +01:00
|
|
|
this._loaded = data.loaded;
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
members: {
|
|
|
|
_node: null,
|
|
|
|
_loaded: false,
|
|
|
|
_sequence: 0,
|
|
|
|
_stabilize: false,
|
|
|
|
|
|
|
|
_renderURI: null,
|
|
|
|
_ref: null,
|
|
|
|
_whitespace: null,
|
|
|
|
_renderer: null,
|
|
|
|
_highlight: null,
|
2014-06-20 20:49:41 +02:00
|
|
|
_encoding: null,
|
2015-03-08 23:27:16 +01:00
|
|
|
_undoTemplates: null,
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Has the content of this changeset been loaded?
|
|
|
|
*
|
|
|
|
* This method returns `true` if a request has been fired, even if the
|
|
|
|
* response has not returned yet.
|
|
|
|
*
|
|
|
|
* @return bool True if the content has been loaded.
|
|
|
|
*/
|
|
|
|
isLoaded: function() {
|
|
|
|
return this._loaded;
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure stabilization of the document position on content load.
|
|
|
|
*
|
|
|
|
* When we dump the changeset into the document, we can try to stabilize
|
|
|
|
* the document scroll position so that the user doesn't feel like they
|
|
|
|
* are jumping around as things load in. This is generally useful when
|
|
|
|
* populating initial changes.
|
|
|
|
*
|
|
|
|
* However, if a user explicitly requests a content load by clicking a
|
|
|
|
* "Load" link or using the dropdown menu, this stabilization generally
|
|
|
|
* feels unnatural, so we don't use it in response to explicit user action.
|
|
|
|
*
|
|
|
|
* @param bool True to stabilize the next content fill.
|
|
|
|
* @return this
|
|
|
|
*/
|
|
|
|
setStabilize: function(stabilize) {
|
|
|
|
this._stabilize = stabilize;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Should this changeset load immediately when the page loads?
|
|
|
|
*
|
|
|
|
* Normally, changes load immediately, but if a diff or commit is very
|
|
|
|
* large we stop doing this and have the user load files explicitly, or
|
|
|
|
* choose to load everything.
|
|
|
|
*
|
|
|
|
* @return bool True if the changeset should load automatically when the
|
|
|
|
* page loads.
|
|
|
|
*/
|
|
|
|
shouldAutoload: function() {
|
|
|
|
return this._getNodeData().autoload;
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load this changeset, if it isn't already loading.
|
|
|
|
*
|
|
|
|
* This fires a request to fill the content of this changeset, provided
|
|
|
|
* there isn't already a request in flight. To force a reload, use
|
|
|
|
* @{method:reload}.
|
|
|
|
*
|
|
|
|
* @return this
|
|
|
|
*/
|
|
|
|
load: function() {
|
|
|
|
if (this._loaded) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.reload();
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reload the changeset content.
|
|
|
|
*
|
|
|
|
* This method always issues a request, even if the content is already
|
|
|
|
* loading. To load conditionally, use @{method:load}.
|
|
|
|
*
|
|
|
|
* @return this
|
|
|
|
*/
|
|
|
|
reload: function() {
|
|
|
|
this._loaded = true;
|
|
|
|
this._sequence++;
|
|
|
|
|
Make "Show Context" persist rendering, whitespace, encoding, etc
Summary:
Ref T2009. Currently, we do not persist view parameters when making context rendering requests.
The big one is the renderer (1up vs 2up). This makes context on unified diffs come in with too many columns.
However, it impacts other parameters too. For example, at HEAD, if you change highlighting to "rainbow" and then load more context, the context uses the original highlighter instead of the rainbow highlighter.
This moves context loads into ChangesetViewManager, which maintains view parameters and can provide them correctly.
- This removes "ref"; it is no longer required, as the ChangesetViewManager tracks it.
- This removes URI management from `behavior-show-more`; it is no longer required, since the ChangesetViewManager knows how to render.
- This removes "whitespace" since this is handled properly by the view manager.
Test Plan:
- Used "Show Top" / "Show All" / "Show Bottom" in 1-up and 2-up views.
- Changed file highlighting to rainbow, loaded stuff, saw rainbow stick.
- Used "Show Entire File" in 1-up and 2-up views.
- Saw loading chrome.
- No loading chrome normally.
- Made inlines, verified `copyRows()` code runs.
- Poked around Diffusion -- it is missing some parameter handling, but works OK.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D11977
2015-03-05 23:03:00 +01:00
|
|
|
var params = this._getViewParameters();
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
|
|
|
|
var workflow = new JX.Workflow(this._renderURI, params)
|
|
|
|
.setHandler(JX.bind(this, this._onresponse, this._sequence));
|
|
|
|
|
Make "Show Context" persist rendering, whitespace, encoding, etc
Summary:
Ref T2009. Currently, we do not persist view parameters when making context rendering requests.
The big one is the renderer (1up vs 2up). This makes context on unified diffs come in with too many columns.
However, it impacts other parameters too. For example, at HEAD, if you change highlighting to "rainbow" and then load more context, the context uses the original highlighter instead of the rainbow highlighter.
This moves context loads into ChangesetViewManager, which maintains view parameters and can provide them correctly.
- This removes "ref"; it is no longer required, as the ChangesetViewManager tracks it.
- This removes URI management from `behavior-show-more`; it is no longer required, since the ChangesetViewManager knows how to render.
- This removes "whitespace" since this is handled properly by the view manager.
Test Plan:
- Used "Show Top" / "Show All" / "Show Bottom" in 1-up and 2-up views.
- Changed file highlighting to rainbow, loaded stuff, saw rainbow stick.
- Used "Show Entire File" in 1-up and 2-up views.
- Saw loading chrome.
- No loading chrome normally.
- Made inlines, verified `copyRows()` code runs.
- Poked around Diffusion -- it is missing some parameter handling, but works OK.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D11977
2015-03-05 23:03:00 +01:00
|
|
|
this._startContentWorkflow(workflow);
|
|
|
|
|
|
|
|
JX.DOM.setContent(
|
|
|
|
this._getContentFrame(),
|
|
|
|
JX.$N(
|
|
|
|
'div',
|
|
|
|
{className: 'differential-loading'},
|
|
|
|
'Loading...'));
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load missing context in a changeset.
|
|
|
|
*
|
|
|
|
* We do this when the user clicks "Show X Lines". We also expand all of
|
|
|
|
* the missing context when they "Show Entire File".
|
|
|
|
*
|
|
|
|
* @param string Line range specification, like "0-40/0-20".
|
|
|
|
* @param node Row where the context should be rendered after loading.
|
|
|
|
* @param bool True if this is a bulk load of multiple context blocks.
|
|
|
|
* @return this
|
|
|
|
*/
|
|
|
|
loadContext: function(range, target, bulk) {
|
|
|
|
var params = this._getViewParameters();
|
|
|
|
params.range = range;
|
|
|
|
|
|
|
|
var container = JX.DOM.scry(target, 'td')[0];
|
|
|
|
// TODO: pht()
|
|
|
|
JX.DOM.setContent(container, 'Loading...');
|
|
|
|
JX.DOM.alterClass(target, 'differential-show-more-loading', true);
|
|
|
|
|
|
|
|
var workflow = new JX.Workflow(this._renderURI, params)
|
|
|
|
.setHandler(JX.bind(this, this._oncontext, target));
|
|
|
|
|
|
|
|
if (bulk) {
|
|
|
|
// If we're loading a bunch of these because the viewer clicked
|
|
|
|
// "Show Entire File Content" or similar, use lower-priority requests
|
|
|
|
// and draw a progress bar.
|
|
|
|
this._startContentWorkflow(workflow);
|
|
|
|
} else {
|
|
|
|
// If this is a single click on a context link, use a higher priority
|
|
|
|
// load without a chrome change.
|
|
|
|
workflow.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
_startContentWorkflow: function(workflow) {
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
var routable = workflow.getRoutable();
|
|
|
|
|
|
|
|
routable
|
|
|
|
.setPriority(500)
|
|
|
|
.setType('content')
|
|
|
|
.setKey(this._getRoutableKey());
|
|
|
|
|
|
|
|
JX.Router.getInstance().queue(routable);
|
Make "Show Context" persist rendering, whitespace, encoding, etc
Summary:
Ref T2009. Currently, we do not persist view parameters when making context rendering requests.
The big one is the renderer (1up vs 2up). This makes context on unified diffs come in with too many columns.
However, it impacts other parameters too. For example, at HEAD, if you change highlighting to "rainbow" and then load more context, the context uses the original highlighter instead of the rainbow highlighter.
This moves context loads into ChangesetViewManager, which maintains view parameters and can provide them correctly.
- This removes "ref"; it is no longer required, as the ChangesetViewManager tracks it.
- This removes URI management from `behavior-show-more`; it is no longer required, since the ChangesetViewManager knows how to render.
- This removes "whitespace" since this is handled properly by the view manager.
Test Plan:
- Used "Show Top" / "Show All" / "Show Bottom" in 1-up and 2-up views.
- Changed file highlighting to rainbow, loaded stuff, saw rainbow stick.
- Used "Show Entire File" in 1-up and 2-up views.
- Saw loading chrome.
- No loading chrome normally.
- Made inlines, verified `copyRows()` code runs.
- Poked around Diffusion -- it is missing some parameter handling, but works OK.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D11977
2015-03-05 23:03:00 +01:00
|
|
|
},
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
|
|
|
|
|
Make "Show Context" persist rendering, whitespace, encoding, etc
Summary:
Ref T2009. Currently, we do not persist view parameters when making context rendering requests.
The big one is the renderer (1up vs 2up). This makes context on unified diffs come in with too many columns.
However, it impacts other parameters too. For example, at HEAD, if you change highlighting to "rainbow" and then load more context, the context uses the original highlighter instead of the rainbow highlighter.
This moves context loads into ChangesetViewManager, which maintains view parameters and can provide them correctly.
- This removes "ref"; it is no longer required, as the ChangesetViewManager tracks it.
- This removes URI management from `behavior-show-more`; it is no longer required, since the ChangesetViewManager knows how to render.
- This removes "whitespace" since this is handled properly by the view manager.
Test Plan:
- Used "Show Top" / "Show All" / "Show Bottom" in 1-up and 2-up views.
- Changed file highlighting to rainbow, loaded stuff, saw rainbow stick.
- Used "Show Entire File" in 1-up and 2-up views.
- Saw loading chrome.
- No loading chrome normally.
- Made inlines, verified `copyRows()` code runs.
- Poked around Diffusion -- it is missing some parameter handling, but works OK.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D11977
2015-03-05 23:03:00 +01:00
|
|
|
/**
|
|
|
|
* Receive a response to a context request.
|
|
|
|
*/
|
|
|
|
_oncontext: function(target, response) {
|
|
|
|
var table = JX.$H(response.changeset).getNode();
|
|
|
|
var root = target.parentNode;
|
|
|
|
this._moveRows(table, root, target);
|
|
|
|
root.removeChild(target);
|
2015-03-08 23:27:16 +01:00
|
|
|
|
|
|
|
this._onchangesetresponse(response);
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
},
|
|
|
|
|
Make "Show Context" persist rendering, whitespace, encoding, etc
Summary:
Ref T2009. Currently, we do not persist view parameters when making context rendering requests.
The big one is the renderer (1up vs 2up). This makes context on unified diffs come in with too many columns.
However, it impacts other parameters too. For example, at HEAD, if you change highlighting to "rainbow" and then load more context, the context uses the original highlighter instead of the rainbow highlighter.
This moves context loads into ChangesetViewManager, which maintains view parameters and can provide them correctly.
- This removes "ref"; it is no longer required, as the ChangesetViewManager tracks it.
- This removes URI management from `behavior-show-more`; it is no longer required, since the ChangesetViewManager knows how to render.
- This removes "whitespace" since this is handled properly by the view manager.
Test Plan:
- Used "Show Top" / "Show All" / "Show Bottom" in 1-up and 2-up views.
- Changed file highlighting to rainbow, loaded stuff, saw rainbow stick.
- Used "Show Entire File" in 1-up and 2-up views.
- Saw loading chrome.
- No loading chrome normally.
- Made inlines, verified `copyRows()` code runs.
- Poked around Diffusion -- it is missing some parameter handling, but works OK.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D11977
2015-03-05 23:03:00 +01:00
|
|
|
_moveRows: function(src, dst, before) {
|
|
|
|
var rows = JX.DOM.scry(src, 'tr');
|
|
|
|
for (var ii = 0; ii < rows.length; ii++) {
|
|
|
|
|
|
|
|
// Find the table this <tr /> belongs to. If it's a sub-table, like a
|
|
|
|
// table in an inline comment, don't copy it.
|
|
|
|
if (JX.DOM.findAbove(rows[ii], 'table') !== src) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (before) {
|
|
|
|
dst.insertBefore(rows[ii], before);
|
|
|
|
} else {
|
|
|
|
dst.appendChild(rows[ii]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get parameters which define the current rendering options.
|
|
|
|
*/
|
|
|
|
_getViewParameters: function() {
|
|
|
|
return {
|
|
|
|
ref: this._ref,
|
|
|
|
whitespace: this._whitespace || '',
|
|
|
|
renderer: this.getRenderer() || '',
|
|
|
|
highlight: this._highlight || '',
|
|
|
|
encoding: this._encoding || ''
|
|
|
|
};
|
|
|
|
},
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the active @{class:JX.Routable} for this changeset.
|
|
|
|
*
|
|
|
|
* After issuing a request with @{method:load} or @{method:reload}, you
|
|
|
|
* can adjust routable settings (like priority) by querying the routable
|
|
|
|
* with this method. Note that there may not be a current routable.
|
|
|
|
*
|
|
|
|
* @return JX.Routable|null Active routable, if one exists.
|
|
|
|
*/
|
|
|
|
getRoutable: function() {
|
|
|
|
return JX.Router.getInstance().getRoutableByKey(this._getRoutableKey());
|
|
|
|
},
|
|
|
|
|
2014-06-20 20:49:41 +02:00
|
|
|
setRenderer: function(renderer) {
|
|
|
|
this._renderer = renderer;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
getRenderer: function() {
|
|
|
|
if (this._renderer !== null) {
|
|
|
|
return this._renderer;
|
|
|
|
}
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
|
|
|
|
// NOTE: If you load the page at one device resolution and then resize to
|
|
|
|
// a different one we don't re-render the diffs, because it's a
|
|
|
|
// complicated mess and you could lose inline comments, cursor positions,
|
|
|
|
// etc.
|
Make "Show Context" persist rendering, whitespace, encoding, etc
Summary:
Ref T2009. Currently, we do not persist view parameters when making context rendering requests.
The big one is the renderer (1up vs 2up). This makes context on unified diffs come in with too many columns.
However, it impacts other parameters too. For example, at HEAD, if you change highlighting to "rainbow" and then load more context, the context uses the original highlighter instead of the rainbow highlighter.
This moves context loads into ChangesetViewManager, which maintains view parameters and can provide them correctly.
- This removes "ref"; it is no longer required, as the ChangesetViewManager tracks it.
- This removes URI management from `behavior-show-more`; it is no longer required, since the ChangesetViewManager knows how to render.
- This removes "whitespace" since this is handled properly by the view manager.
Test Plan:
- Used "Show Top" / "Show All" / "Show Bottom" in 1-up and 2-up views.
- Changed file highlighting to rainbow, loaded stuff, saw rainbow stick.
- Used "Show Entire File" in 1-up and 2-up views.
- Saw loading chrome.
- No loading chrome normally.
- Made inlines, verified `copyRows()` code runs.
- Poked around Diffusion -- it is missing some parameter handling, but works OK.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D11977
2015-03-05 23:03:00 +01:00
|
|
|
return (JX.Device.getDevice() == 'desktop') ? '2up' : '1up';
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
},
|
|
|
|
|
2015-03-08 23:27:16 +01:00
|
|
|
getUndoTemplates: function() {
|
|
|
|
return this._undoTemplates;
|
|
|
|
},
|
|
|
|
|
2014-06-20 20:49:41 +02:00
|
|
|
setEncoding: function(encoding) {
|
|
|
|
this._encoding = encoding;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
getEncoding: function() {
|
|
|
|
return this._encoding;
|
|
|
|
},
|
|
|
|
|
|
|
|
setHighlight: function(highlight) {
|
|
|
|
this._highlight = highlight;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
getHighlight: function() {
|
|
|
|
return this._highlight;
|
|
|
|
},
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
|
|
|
|
_getNodeData: function() {
|
|
|
|
return JX.Stratcom.getData(this._node);
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_onresponse: function(sequence, response) {
|
|
|
|
if (sequence != this._sequence) {
|
|
|
|
// If this isn't the most recent request, ignore it. This normally
|
|
|
|
// means the user changed view settings between the time the page loaded
|
|
|
|
// and the content filled.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// As we populate the changeset list, we try to hold the document scroll
|
|
|
|
// position steady, so that, e.g., users who want to leave a comment on a
|
|
|
|
// diff with a large number of changes don't constantly have the text
|
|
|
|
// area scrolled off the bottom of the screen until the entire diff loads.
|
|
|
|
//
|
|
|
|
// There are two three major cases here:
|
|
|
|
//
|
|
|
|
// - If we're near the top of the document, never scroll.
|
|
|
|
// - If we're near the bottom of the document, always scroll.
|
|
|
|
// - Otherwise, scroll if the changes were above the midline of the
|
|
|
|
// viewport.
|
|
|
|
|
|
|
|
var target = this._node;
|
|
|
|
|
|
|
|
var old_pos = JX.Vector.getScroll();
|
|
|
|
var old_view = JX.Vector.getViewport();
|
|
|
|
var old_dim = JX.Vector.getDocument();
|
|
|
|
|
|
|
|
// Number of pixels away from the top or bottom of the document which
|
|
|
|
// count as "nearby".
|
|
|
|
var sticky = 480;
|
|
|
|
|
|
|
|
var near_top = (old_pos.y <= sticky);
|
|
|
|
var near_bot = ((old_pos.y + old_view.y) >= (old_dim.y - sticky));
|
|
|
|
|
|
|
|
var target_pos = JX.Vector.getPos(target);
|
|
|
|
var target_dim = JX.Vector.getDim(target);
|
|
|
|
var target_mid = (target_pos.y + (target_dim.y / 2));
|
|
|
|
|
|
|
|
var view_mid = (old_pos.y + (old_view.y / 2));
|
|
|
|
var above_mid = (target_mid < view_mid);
|
|
|
|
|
|
|
|
var frame = this._getContentFrame();
|
|
|
|
JX.DOM.setContent(frame, JX.$H(response.changeset));
|
|
|
|
|
|
|
|
if (this._stabilize) {
|
|
|
|
if (!near_top) {
|
|
|
|
if (near_bot || above_mid) {
|
|
|
|
// Figure out how much taller the document got.
|
|
|
|
var delta = (JX.Vector.getDocument().y - old_dim.y);
|
2015-01-25 17:42:40 +01:00
|
|
|
JX.DOM.scrollToPosition(old_pos.x, old_pos.y + delta);
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this._stabilize = false;
|
|
|
|
}
|
|
|
|
|
2015-03-08 23:27:16 +01:00
|
|
|
this._onchangesetresponse(response);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onchangesetresponse: function(response) {
|
|
|
|
// Code shared by autoload and context responses.
|
|
|
|
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
if (response.coverage) {
|
|
|
|
for (var k in response.coverage) {
|
|
|
|
try {
|
|
|
|
JX.DOM.replace(JX.$(k), JX.$H(response.coverage[k]));
|
|
|
|
} catch (ignored) {
|
|
|
|
// Not terribly important.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-08 23:27:16 +01:00
|
|
|
|
|
|
|
if (response.undoTemplates) {
|
|
|
|
this._undoTemplates = response.undoTemplates;
|
|
|
|
}
|
When deleting inline comments, offer "undo" instead of prompting
Summary:
Ref T2009. Ref T1460.
Fixes T2618. When users hit "Delete" on inline comments, delete immediately and offer them "Undo". If they delete indirectly (e.g., by clicking "Delete" from the preview at the bottom of the page), we still prompt them, because the "Undo" action either won't be available or may not be easy to find. This is a "refdelete".
Fixes T6464. This was just a mess. Make it not as much of a mess. It should work now. Pretty sure.
Fixes T4999. We did not refresh these links often enough to find targets for them, so they could race with content. Reevaluate them after loading new changes.
Test Plan:
- Deleted and undid deletion of inlines from main view and preview.
- Clicked "View" on inlines.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T6464, T4999, T2618, T1460, T2009
Differential Revision: https://secure.phabricator.com/D12032
2015-03-10 01:27:51 +01:00
|
|
|
|
|
|
|
JX.Stratcom.invoke('differential-inline-comment-refresh');
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 16:13:22 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
_getContentFrame: function() {
|
|
|
|
return JX.DOM.find(this._node, 'div', 'changeset-view-content');
|
|
|
|
},
|
|
|
|
|
|
|
|
_getRoutableKey: function() {
|
|
|
|
return 'changeset-view.' + this._ref + '.' + this._sequence;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
statics: {
|
|
|
|
getForNode: function(node) {
|
|
|
|
var data = JX.Stratcom.getData(node);
|
|
|
|
if (!data.changesetViewManager) {
|
|
|
|
data.changesetViewManager = new JX.ChangesetViewManager(node);
|
|
|
|
}
|
|
|
|
return data.changesetViewManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|