2011-01-25 20:57:47 +01:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-differential-populate
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-dom
|
2012-03-13 04:04:12 +01:00
|
|
|
* javelin-stratcom
|
|
|
|
* phabricator-tooltip
|
2017-05-08 16:58:02 +02:00
|
|
|
* phabricator-diff-changeset-list
|
2017-05-08 18:52:16 +02:00
|
|
|
* phabricator-diff-changeset
|
2020-04-21 16:33:27 +02:00
|
|
|
* phuix-formation-view
|
2017-05-08 16:58:02 +02:00
|
|
|
* @javelin
|
2011-01-25 20:57:47 +01:00
|
|
|
*/
|
|
|
|
|
2017-05-08 16:58:02 +02:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-08 19:20:59 +02:00
|
|
|
var changeset_list = new JX.DiffChangesetList()
|
2017-05-09 21:09:45 +02:00
|
|
|
.setTranslations(JX.phtize(config.pht))
|
2017-06-15 14:31:42 +02:00
|
|
|
.setInlineURI(config.inlineURI)
|
In Differential standalone views, disable some keyboard shortcuts which don't work
Summary:
Ref T13164. See PHI693. In Differential, you can {nav View Options > View Standalone} to get a standalone view of a single changeset. You can also arrive here via the big changeset list for revisions affecting a huge number of files.
We currently suggest that all the keyboard shortcuts work, but some do not. In particular, the "Next File" and "Previous File" keyboard shortcuts (and some similar shortcuts) do not work. In the main view, the next/previous files are on the same page. In the standalone view, we'd need to actually change the URI.
Ideally, we should do this (and, e.g., put prev/next links on the page). As a first step toward that, hide the nonfunctional shortcuts to stop users from being misled.
Test Plan:
- Viewed a revision in normal and standalone views.
- No changes in normal view, and all keys still work ("N", "P", etc).
- In standalone view, "?" no longer shows nonfunctional key commands.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13164
Differential Revision: https://secure.phabricator.com/D19571
2018-08-13 17:21:16 +02:00
|
|
|
.setInlineListURI(config.inlineListURI)
|
|
|
|
.setIsStandalone(config.isStandalone);
|
2017-05-08 16:58:02 +02:00
|
|
|
|
2020-04-21 16:33:27 +02:00
|
|
|
if (config.formationViewID) {
|
|
|
|
var formation_node = JX.$(config.formationViewID);
|
|
|
|
var formation_view = new JX.PHUIXFormationView(formation_node);
|
|
|
|
changeset_list.setFormationView(formation_view);
|
|
|
|
formation_view.start();
|
|
|
|
}
|
2011-01-25 20:57:47 +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
|
|
|
for (var ii = 0; ii < config.changesetViewIDs.length; ii++) {
|
|
|
|
var id = config.changesetViewIDs[ii];
|
2017-05-08 20:27:11 +02:00
|
|
|
var node = JX.$(id);
|
|
|
|
var changeset = changeset_list.newChangesetForNode(node);
|
|
|
|
if (changeset.shouldAutoload()) {
|
|
|
|
changeset.setStabilize(true).load();
|
2012-03-13 01:06:55 +01:00
|
|
|
}
|
2011-01-25 20:57:47 +01:00
|
|
|
}
|
|
|
|
|
2020-04-21 16:33:27 +02:00
|
|
|
// Install and activate the current page.
|
|
|
|
var page_id = JX.Quicksand.getCurrentPageID();
|
|
|
|
statics.pages[page_id] = [changeset_list];
|
|
|
|
onredraw(page_id);
|
|
|
|
|
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 highlighted = null;
|
|
|
|
var highlight_class = null;
|
|
|
|
|
2012-03-13 04:04:12 +01:00
|
|
|
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.
|
2012-05-05 02:41:06 +02:00
|
|
|
if (!t.className.match(/cov|copy/)) {
|
2012-03-13 04:04:12 +01:00
|
|
|
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;
|
2012-12-21 03:23:35 +01:00
|
|
|
var align = 'W';
|
2012-05-05 02:41:06 +02:00
|
|
|
var sibling = 'previousSibling';
|
2012-08-07 02:17:38 +02:00
|
|
|
var width = 120;
|
2012-03-13 04:04:12 +01:00
|
|
|
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';
|
2012-05-05 02:41:06 +02:00
|
|
|
} else {
|
|
|
|
var match = /new-copy|new-move/.exec(t.className);
|
|
|
|
if (match) {
|
|
|
|
sibling = 'nextSibling';
|
2012-08-07 02:17:38 +02:00
|
|
|
width = 500;
|
2012-05-05 02:41:06 +02:00
|
|
|
msg = JX.Stratcom.getData(t).msg;
|
|
|
|
highlight_class = match[0];
|
|
|
|
}
|
2012-03-13 04:04:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (msg) {
|
2012-08-07 02:17:38 +02:00
|
|
|
JX.Tooltip.show(t, width, align, msg);
|
2012-03-13 04:04:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (highlight_class) {
|
2012-05-05 02:41:06 +02:00
|
|
|
highlighted = t[sibling];
|
2012-03-13 04:04:12 +01:00
|
|
|
JX.DOM.alterClass(highlighted, highlight_class, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2011-01-25 20:57:47 +01:00
|
|
|
});
|