mirror of
https://we.phorge.it/source/phorge.git
synced 2024-09-22 18:28:47 +02:00
404fe482d9
Summary: Ref T12616. Ref T8047. Ref T11093. We currently have several bugs where diff state sticks across Quicksand pages. Add a new top-level object to handle this, with `sleep()` and `wake()` methods. In `sleep()`, future changes will remove/deacivate all the reticles/editors/etc. See T12616 for high-level discussion of plans here. This general idea is likely to become more formal eventually (e.g. for "sheets" or whatever we call them, in T10469) but I think this is probably a reasonable place to draw a line for now. Test Plan: - Added some logging to sleep(), wake() and construct(). - Viewed changes in Differential. - With Quicksand on, browsed around; saw state change logs fire properly. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12616, T11093, T8047 Differential Revision: https://secure.phabricator.com/D17840
170 lines
4.3 KiB
JavaScript
170 lines
4.3 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-differential-populate
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* javelin-stratcom
|
|
* phabricator-tooltip
|
|
* changeset-view-manager
|
|
* phabricator-diff-changeset-list
|
|
* @javelin
|
|
*/
|
|
|
|
JX.behavior('differential-populate', function(config, statics) {
|
|
|
|
// When we perform a Quicksand navigation, deactivate the changeset lists on
|
|
// the current page and activate the changeset lists on the new page.
|
|
var onredraw = function(page_id) {
|
|
// If the current page is already active, we don't need to do anything.
|
|
if (statics.pageID === page_id) {
|
|
return;
|
|
}
|
|
|
|
var ii;
|
|
|
|
// Put the old lists to sleep.
|
|
var old_lists = get_lists(statics.pageID);
|
|
for (ii = 0; ii < old_lists.length; ii++) {
|
|
old_lists[ii].sleep();
|
|
}
|
|
statics.pageID = null;
|
|
|
|
// Awaken the new lists, if they exist.
|
|
if (statics.pages.hasOwnProperty(page_id)) {
|
|
var new_lists = get_lists(page_id);
|
|
for (ii = 0; ii < new_lists.length; ii++) {
|
|
new_lists[ii].wake();
|
|
}
|
|
|
|
statics.pageID = page_id;
|
|
}
|
|
};
|
|
|
|
// Get changeset lists on the current page.
|
|
var get_lists = function(page_id) {
|
|
if (page_id === null) {
|
|
return [];
|
|
}
|
|
|
|
return statics.pages[page_id] || [];
|
|
};
|
|
|
|
if (!statics.installed) {
|
|
statics.installed = true;
|
|
statics.pages = {};
|
|
statics.pageID = null;
|
|
|
|
JX.Stratcom.listen('quicksand-redraw', null, function(e) {
|
|
onredraw(e.getData().newResponseID);
|
|
});
|
|
}
|
|
|
|
var changeset_list = new JX.DiffChangesetList();
|
|
|
|
// Install and activate the current page.
|
|
var page_id = JX.Quicksand.getCurrentPageID();
|
|
statics.pages[page_id] = [changeset_list];
|
|
onredraw(page_id);
|
|
|
|
|
|
|
|
for (var ii = 0; ii < config.changesetViewIDs.length; ii++) {
|
|
var id = config.changesetViewIDs[ii];
|
|
var view = JX.ChangesetViewManager.getForNode(JX.$(id));
|
|
if (view.shouldAutoload()) {
|
|
view.setStabilize(true).load();
|
|
}
|
|
}
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'differential-load',
|
|
function(e) {
|
|
var meta = e.getNodeData('differential-load');
|
|
var changeset = JX.$(meta.id);
|
|
var view = JX.ChangesetViewManager.getForNode(changeset);
|
|
|
|
view.load();
|
|
var routable = view.getRoutable();
|
|
if (routable) {
|
|
routable.setPriority(2000);
|
|
}
|
|
|
|
if (meta.kill) {
|
|
e.kill();
|
|
}
|
|
});
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'show-more',
|
|
function(e) {
|
|
e.kill();
|
|
|
|
var changeset = e.getNode('differential-changeset');
|
|
var view = JX.ChangesetViewManager.getForNode(changeset);
|
|
var data = e.getNodeData('show-more');
|
|
var target = e.getNode('context-target');
|
|
|
|
view.loadContext(data.range, target);
|
|
});
|
|
|
|
var highlighted = null;
|
|
var highlight_class = null;
|
|
|
|
JX.Stratcom.listen(
|
|
['mouseover', 'mouseout'],
|
|
['differential-changeset', 'tag:td'],
|
|
function(e) {
|
|
var t = e.getTarget();
|
|
|
|
// NOTE: Using className is not best practice, but the diff UI is perf
|
|
// sensitive.
|
|
if (!t.className.match(/cov|copy/)) {
|
|
return;
|
|
}
|
|
|
|
if (e.getType() == 'mouseout') {
|
|
JX.Tooltip.hide();
|
|
if (highlighted) {
|
|
JX.DOM.alterClass(highlighted, highlight_class, false);
|
|
highlighted = null;
|
|
}
|
|
} else {
|
|
highlight_class = null;
|
|
var msg;
|
|
var align = 'W';
|
|
var sibling = 'previousSibling';
|
|
var width = 120;
|
|
if (t.className.match(/cov-C/)) {
|
|
msg = 'Covered';
|
|
highlight_class = 'source-cov-C';
|
|
} else if (t.className.match(/cov-U/)) {
|
|
msg = 'Not Covered';
|
|
highlight_class = 'source-cov-U';
|
|
} else if (t.className.match(/cov-N/)) {
|
|
msg = 'Not Executable';
|
|
highlight_class = 'source-cov-N';
|
|
} else {
|
|
var match = /new-copy|new-move/.exec(t.className);
|
|
if (match) {
|
|
sibling = 'nextSibling';
|
|
width = 500;
|
|
msg = JX.Stratcom.getData(t).msg;
|
|
highlight_class = match[0];
|
|
}
|
|
}
|
|
|
|
if (msg) {
|
|
JX.Tooltip.show(t, width, align, msg);
|
|
}
|
|
|
|
if (highlight_class) {
|
|
highlighted = t[sibling];
|
|
JX.DOM.alterClass(highlighted, highlight_class, true);
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
|
|
});
|