2012-01-05 01:52:13 +01:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-differential-dropdown-menus
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-dom
|
2012-01-05 23:41:11 +01:00
|
|
|
* javelin-util
|
2012-01-05 01:52:13 +01:00
|
|
|
* javelin-stratcom
|
2014-05-05 19:56:14 +02:00
|
|
|
* phuix-dropdown-menu
|
|
|
|
* phuix-action-list-view
|
|
|
|
* phuix-action-view
|
2013-04-23 20:09:23 +02:00
|
|
|
* phabricator-phtize
|
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
|
|
|
* changeset-view-manager
|
2012-01-05 01:52:13 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
JX.behavior('differential-dropdown-menus', function(config) {
|
2013-04-23 20:09:23 +02:00
|
|
|
var pht = JX.phtize(config.pht);
|
|
|
|
|
2012-05-30 03:20:11 +02:00
|
|
|
function show_more(container) {
|
|
|
|
var nodes = JX.DOM.scry(container, 'tr', 'context-target');
|
|
|
|
for (var ii = 0; ii < nodes.length; ii++) {
|
|
|
|
var show = JX.DOM.scry(nodes[ii], 'a', 'show-more');
|
|
|
|
for (var jj = 0; jj < show.length; jj++) {
|
|
|
|
if (JX.Stratcom.getData(show[jj]).type != 'all') {
|
|
|
|
continue;
|
2012-01-06 05:29:16 +01:00
|
|
|
}
|
2012-05-30 03:20:11 +02:00
|
|
|
var event_data = {
|
|
|
|
context : nodes[ii],
|
|
|
|
show : show[jj]
|
|
|
|
};
|
|
|
|
JX.Stratcom.invoke('differential-reveal-context', null, event_data);
|
2012-01-06 05:29:16 +01:00
|
|
|
}
|
|
|
|
}
|
2012-05-30 03:20:11 +02:00
|
|
|
}
|
|
|
|
|
2014-05-05 19:56:14 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'differential-reveal-all',
|
|
|
|
function(e) {
|
|
|
|
var containers = JX.DOM.scry(
|
|
|
|
JX.$('differential-review-stage'),
|
|
|
|
'div',
|
|
|
|
'differential-changeset');
|
|
|
|
for (var i=0; i < containers.length; i++) {
|
|
|
|
show_more(containers[i]);
|
|
|
|
}
|
|
|
|
e.kill();
|
2012-06-12 00:59:26 +02:00
|
|
|
});
|
2012-03-20 03:57:41 +01:00
|
|
|
|
2014-05-05 19:56:14 +02:00
|
|
|
var buildmenu = function(e) {
|
|
|
|
var button = e.getNode('differential-view-options');
|
|
|
|
var data = JX.Stratcom.getData(button);
|
2012-03-20 03:57:41 +01:00
|
|
|
|
2014-05-05 19:56:14 +02:00
|
|
|
if (data.menu) {
|
|
|
|
return;
|
2012-01-16 06:18:07 +01:00
|
|
|
}
|
2012-03-20 03:57:41 +01:00
|
|
|
|
2014-05-05 19:56:14 +02:00
|
|
|
e.prevent();
|
2012-03-20 03:57:41 +01:00
|
|
|
|
2014-05-05 19:56:14 +02:00
|
|
|
var menu = new JX.PHUIXDropdownMenu(button);
|
|
|
|
var list = new JX.PHUIXActionListView();
|
2012-03-20 03:57:41 +01:00
|
|
|
|
2014-05-05 19:56:14 +02:00
|
|
|
var add_link = function(icon, name, href, local) {
|
|
|
|
if (!href) {
|
|
|
|
return;
|
|
|
|
}
|
2012-06-12 00:59:26 +02:00
|
|
|
|
2014-05-05 19:56:14 +02:00
|
|
|
var link = new JX.PHUIXActionView()
|
|
|
|
.setIcon(icon)
|
|
|
|
.setName(name)
|
|
|
|
.setHref(href)
|
|
|
|
.setHandler(function(e) {
|
|
|
|
if (local) {
|
|
|
|
window.location.assign(href);
|
2012-06-20 00:56:42 +02:00
|
|
|
} else {
|
2014-05-05 19:56:14 +02:00
|
|
|
window.open(href);
|
2012-06-20 00:56:42 +02:00
|
|
|
}
|
2014-05-05 19:56:14 +02:00
|
|
|
menu.close();
|
|
|
|
e.prevent();
|
|
|
|
});
|
|
|
|
|
|
|
|
list.addItem(link);
|
|
|
|
return link;
|
|
|
|
};
|
|
|
|
|
|
|
|
var reveal_item = new JX.PHUIXActionView()
|
2014-05-19 01:10:54 +02:00
|
|
|
.setIcon('fa-eye');
|
2014-05-05 19:56:14 +02:00
|
|
|
list.addItem(reveal_item);
|
|
|
|
|
|
|
|
var visible_item = new JX.PHUIXActionView()
|
|
|
|
.setHandler(function(e) {
|
|
|
|
var diff = JX.DOM.scry(
|
|
|
|
JX.$(data.containerID),
|
|
|
|
'table',
|
|
|
|
'differential-diff');
|
|
|
|
|
|
|
|
JX.Stratcom.invoke('differential-toggle-file', null, {diff: diff});
|
|
|
|
e.prevent();
|
|
|
|
menu.close();
|
2012-01-06 05:29:16 +01:00
|
|
|
});
|
2014-05-05 19:56:14 +02:00
|
|
|
list.addItem(visible_item);
|
|
|
|
|
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
|
|
|
add_link('fa-file-text', pht('Browse in Diffusion'), data.diffusionURI);
|
2014-05-19 01:10:54 +02:00
|
|
|
add_link('fa-file-o', pht('View Standalone'), data.standaloneURI);
|
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 up_item = new JX.PHUIXActionView()
|
|
|
|
.setHandler(function(e) {
|
|
|
|
var changeset = JX.DOM.findAbove(
|
|
|
|
button,
|
|
|
|
'div',
|
|
|
|
'differential-changeset');
|
|
|
|
|
|
|
|
var view = JX.ChangesetViewManager.getForNode(changeset);
|
|
|
|
view.reload();
|
|
|
|
|
|
|
|
e.prevent();
|
|
|
|
menu.close();
|
|
|
|
});
|
|
|
|
list.addItem(up_item);
|
|
|
|
|
2014-05-19 01:10:54 +02:00
|
|
|
add_link('fa-arrow-left', pht('Show Raw File (Left)'), data.leftURI);
|
|
|
|
add_link('fa-arrow-right', pht('Show Raw File (Right)'), data.rightURI);
|
|
|
|
add_link('fa-pencil', pht('Open in Editor'), data.editor, true);
|
|
|
|
add_link('fa-wrench', pht('Configure Editor'), data.editorConfigure);
|
2014-05-05 19:56:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
menu.setContent(list.getNode());
|
|
|
|
|
|
|
|
menu.listen('open', function() {
|
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 changeset = JX.DOM.findAbove(
|
|
|
|
button,
|
|
|
|
'div',
|
|
|
|
'differential-changeset');
|
|
|
|
|
|
|
|
var view = JX.ChangesetViewManager.getForNode(changeset);
|
2014-05-05 19:56:14 +02:00
|
|
|
|
|
|
|
// When the user opens the menu, check if there are any "Show More"
|
|
|
|
// links in the changeset body. If there aren't, disable the "Show
|
|
|
|
// Entire File" menu item since it won't change anything.
|
|
|
|
|
|
|
|
var nodes = JX.DOM.scry(JX.$(data.containerID), 'a', 'show-more');
|
|
|
|
if (nodes.length) {
|
|
|
|
reveal_item
|
|
|
|
.setDisabled(false)
|
|
|
|
.setName(pht('Show Entire File'))
|
2014-05-19 01:10:54 +02:00
|
|
|
.setIcon('fa-file-o')
|
2014-05-05 19:56:14 +02:00
|
|
|
.setHandler(function(e) {
|
|
|
|
show_more(JX.$(data.containerID));
|
|
|
|
e.prevent();
|
|
|
|
menu.close();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
reveal_item
|
|
|
|
.setDisabled(true)
|
2014-05-19 01:10:54 +02:00
|
|
|
.setIcon('fa-file')
|
2014-05-05 19:56:14 +02:00
|
|
|
.setName(pht('Entire File Shown'))
|
|
|
|
.setHandler(function(e) { e.prevent(); });
|
|
|
|
}
|
2012-01-05 01:52:13 +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
|
|
|
// TODO: This is temporary and just makes testing easier. It will do
|
|
|
|
// some mojo soon.
|
|
|
|
if (view.isLoaded()) {
|
|
|
|
up_item
|
|
|
|
.setIcon('fa-refresh')
|
|
|
|
.setName('Reload');
|
|
|
|
} else {
|
|
|
|
up_item
|
|
|
|
.setIcon('fa-refresh')
|
|
|
|
.setName('Load');
|
|
|
|
}
|
|
|
|
|
|
|
|
visible_item
|
|
|
|
.setDisabled(true)
|
|
|
|
.setIcon('fa-expand')
|
|
|
|
.setName(pht("Can't Toggle Unloaded File"));
|
2014-05-05 19:56:14 +02:00
|
|
|
var diffs = JX.DOM.scry(
|
|
|
|
JX.$(data.containerID),
|
|
|
|
'table',
|
|
|
|
'differential-diff');
|
|
|
|
|
|
|
|
if (diffs.length > 1) {
|
|
|
|
JX.$E(
|
|
|
|
'More than one node with sigil "differential-diff" was found in "'+
|
|
|
|
data.containerID+'."');
|
|
|
|
} else if (diffs.length == 1) {
|
|
|
|
diff = diffs[0];
|
|
|
|
visible_item.setDisabled(false);
|
|
|
|
if (JX.Stratcom.getData(diff).hidden) {
|
|
|
|
visible_item
|
|
|
|
.setName(pht('Expand File'))
|
2014-05-19 01:10:54 +02:00
|
|
|
.setIcon('fa-expand');
|
2014-05-05 19:56:14 +02:00
|
|
|
} else {
|
|
|
|
visible_item
|
|
|
|
.setName(pht('Collapse File'))
|
2014-05-19 01:10:54 +02:00
|
|
|
.setIcon('fa-compress');
|
2014-05-05 19:56:14 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Do nothing when there is no diff shown in the table. For example,
|
|
|
|
// the file is binary.
|
2012-05-30 03:20:11 +02:00
|
|
|
}
|
2014-05-05 19:56:14 +02:00
|
|
|
|
2012-05-30 03:20:11 +02:00
|
|
|
});
|
2014-05-05 19:56:14 +02:00
|
|
|
data.menu = menu;
|
|
|
|
menu.open();
|
|
|
|
};
|
2012-05-30 03:20:11 +02:00
|
|
|
|
2014-05-05 19:56:14 +02:00
|
|
|
JX.Stratcom.listen('click', 'differential-view-options', buildmenu);
|
2012-01-05 01:52:13 +01:00
|
|
|
});
|