2011-01-31 20:38:13 -08:00
|
|
|
/**
|
|
|
|
|
* @provides javelin-behavior-differential-show-more
|
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-03 15:11:55 -07:00
|
|
|
* @requires javelin-behavior
|
|
|
|
|
* javelin-dom
|
2011-07-16 07:09:19 -07:00
|
|
|
* javelin-workflow
|
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-03 15:11:55 -07:00
|
|
|
* javelin-util
|
|
|
|
|
* javelin-stratcom
|
2011-01-31 20:38:13 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
JX.behavior('differential-show-more', function(config) {
|
|
|
|
|
|
2012-01-05 20:29:16 -08:00
|
|
|
function onresponse(context, response) {
|
2012-03-12 20:04:12 -07:00
|
|
|
var div = JX.$N('div', {}, JX.$H(response.changeset));
|
2012-01-05 20:29:16 -08:00
|
|
|
var root = context.parentNode;
|
|
|
|
|
copyRows(root, div, context);
|
|
|
|
|
root.removeChild(context);
|
2011-01-31 20:38:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
|
'click',
|
|
|
|
|
'show-more',
|
|
|
|
|
function(e) {
|
2012-01-05 20:29:16 -08:00
|
|
|
var event_data = {
|
|
|
|
|
context : e.getNodes()['context-target'],
|
|
|
|
|
show : e.getNodes()['show-more']
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
JX.Stratcom.invoke('differential-reveal-context', null, event_data);
|
|
|
|
|
e.kill();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
|
'differential-reveal-context',
|
|
|
|
|
null,
|
|
|
|
|
function(e) {
|
|
|
|
|
var context = e.getData().context;
|
|
|
|
|
var data = JX.Stratcom.getData(e.getData().show);
|
|
|
|
|
|
2012-08-29 16:34:52 -07:00
|
|
|
var container = JX.DOM.scry(context, 'td')[0];
|
2011-01-31 20:38:13 -08:00
|
|
|
JX.DOM.setContent(container, 'Loading...');
|
|
|
|
|
JX.DOM.alterClass(context, 'differential-show-more-loading', true);
|
Fix whitespace and unchanged file shields
Summary:
Fixes T181. I actually have no idea what the original issue in T181 was, but this fixes several problems:
- The code for figuring out whitespace-only changes was extremely confusing and probably buggy (the code for figuring out unchanged files was equally confusing but probably less buggy).
- When rendering a whitespace shield, we did not offer a "Show Changes" link. Instead, show the "Show Changes" link: we can always render the content beneath this link.
- When clicking "Show Changes", we used the current whitespace mode, which might result in a diff with no changes. Instead, force "show all" whitespace mode.
- We never offered a "show changes" link for unchanged files. Instead, offer this link if we can service it.
- When clicking "Show Changes", we pierced the shield but didn't force file content, which would fold the entire file even if it was available. Instead, force the file content.
Test Plan: Generated whitespace-only and no-change diffs. Clicked shield links, or verified no shield link available in no-change-with-no-content. Generated an "@generated" change, verified shield worked correctly.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T181, T2009
Differential Revision: https://secure.phabricator.com/D4407
2013-01-11 15:27:42 -08:00
|
|
|
|
|
|
|
|
if (!data['whitespace']) {
|
|
|
|
|
data['whitespace'] = config.whitespace;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-16 07:09:19 -07:00
|
|
|
new JX.Workflow(config.uri, data)
|
2012-01-05 20:29:16 -08:00
|
|
|
.setHandler(JX.bind(null, onresponse, context))
|
2011-07-16 07:09:19 -07:00
|
|
|
.start();
|
2011-01-31 20:38:13 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function copyRows(dst, src, before) {
|
|
|
|
|
var rows = JX.DOM.scry(src, 'tr');
|
|
|
|
|
for (var ii = 0; ii < rows.length; ii++) {
|
|
|
|
|
if (before) {
|
|
|
|
|
dst.insertBefore(rows[ii], before);
|
|
|
|
|
} else {
|
|
|
|
|
dst.appendChild(rows[ii]);
|
|
|
|
|
}
|
|
|
|
|
}
|
Add "Undo" for editing Differential inline comments
Summary:
When a user hits 'cancel' on a 'new', 'edit', or 'reply' operation, add a little
"Changes discarded. __Undo__" insert so they can get their change back. No undo
for delete since there's an explicit prompt. Once this lands we can make
'escape' work again to close dialogs.
This change started feeling really good when I was merging all the duplicate
code and making things more consistent, but by the time I started writing client
rendering it felt gross. I'm not really thrilled with it but I guess it's a step
forward? The feature seems pretty OK in practice. Let me know how much barfing
this causes and I can try to remedy the most acute concerns.
This also fixes a bug where replies always (?) appear on the 'new' side of the
diff (I think?).
Test Plan:
Applied 'new', 'edit', 'delete' and 'reply' operations, pressed 'cancel' and
'okay' in each case, with and without changing text where relevant. All
behaviors seem to conform with expectations, except that canceling out of 'edit'
without changing the text gives you an option to undo when it shouldn't really.
There's no super easy way to get at the original text right now.
Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen
CC: simpkins, aran, epriestley
Differential Revision: 406
2011-06-07 16:11:10 -07:00
|
|
|
return rows;
|
2011-01-31 20:38:13 -08:00
|
|
|
}
|