mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Make "View" links on Differential inline comment previews work again
Summary: Ref T11114. Recent changes broke the links to jump to inline comments from the previews because they get hooked up with JS. Restore the linking behavior. Test Plan: Clicked "View" on an inline comment preview, jumped to that comment. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114 Differential Revision: https://secure.phabricator.com/D17131
This commit is contained in:
parent
34d279abde
commit
00313094d3
3 changed files with 59 additions and 1 deletions
|
@ -28,6 +28,14 @@ final class PHUIDiffInlineCommentPreviewListView
|
||||||
public function render() {
|
public function render() {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$config = array(
|
||||||
|
'pht' => array(
|
||||||
|
'view' => pht('View'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Javelin::initBehavior('diff-preview-link', $config);
|
||||||
|
|
||||||
$inlines = $this->getInlineComments();
|
$inlines = $this->getInlineComments();
|
||||||
foreach ($inlines as $key => $inline) {
|
foreach ($inlines as $key => $inline) {
|
||||||
$inlines[$key] = DifferentialInlineComment::newFromModernComment(
|
$inlines[$key] = DifferentialInlineComment::newFromModernComment(
|
||||||
|
|
36
webroot/rsrc/js/application/diff/behavior-preview-link.js
Normal file
36
webroot/rsrc/js/application/diff/behavior-preview-link.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
* @provides javelin-behavior-diff-preview-link
|
||||||
|
* @requires javelin-behavior
|
||||||
|
* javelin-stratcom
|
||||||
|
* javelin-dom
|
||||||
|
*/
|
||||||
|
|
||||||
|
JX.behavior('diff-preview-link', function(config, statics) {
|
||||||
|
if (statics.initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
statics.initialized = true;
|
||||||
|
|
||||||
|
var pht = JX.phtize(config.pht);
|
||||||
|
|
||||||
|
// After inline comment previews are rendered, hook up the links to the
|
||||||
|
// comments that are visible on the current page.
|
||||||
|
function link_inline_preview(e) {
|
||||||
|
var root = e.getData().rootNode;
|
||||||
|
var links = JX.DOM.scry(root, 'a', 'differential-inline-preview-jump');
|
||||||
|
|
||||||
|
for (var ii = 0; ii < links.length; ii++) {
|
||||||
|
var data = JX.Stratcom.getData(links[ii]);
|
||||||
|
try {
|
||||||
|
JX.$(data.anchor);
|
||||||
|
links[ii].href = '#' + data.anchor;
|
||||||
|
JX.DOM.setContent(links[ii], pht('view'));
|
||||||
|
} catch (ignored) {
|
||||||
|
// This inline comment isn't visible, e.g. on some other diff.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JX.Stratcom.listen('EditEngine.didCommentPreview', null, link_inline_preview);
|
||||||
|
});
|
|
@ -147,13 +147,27 @@ JX.behavior('comment-actions', function(config) {
|
||||||
if (!response.xactions.length) {
|
if (!response.xactions.length) {
|
||||||
JX.DOM.hide(panel);
|
JX.DOM.hide(panel);
|
||||||
} else {
|
} else {
|
||||||
|
var preview_root = JX.$(config.timelineID);
|
||||||
JX.DOM.setContent(
|
JX.DOM.setContent(
|
||||||
JX.$(config.timelineID),
|
preview_root,
|
||||||
[
|
[
|
||||||
JX.$H(response.xactions.join('')),
|
JX.$H(response.xactions.join('')),
|
||||||
JX.$H(response.previewContent)
|
JX.$H(response.previewContent)
|
||||||
]);
|
]);
|
||||||
JX.DOM.show(panel);
|
JX.DOM.show(panel);
|
||||||
|
|
||||||
|
// NOTE: Resonses are currently processed before associated behaviors are
|
||||||
|
// registered. We need to defer invoking this event so that any behaviors
|
||||||
|
// accompanying the response are registered.
|
||||||
|
var invoke_preview = function() {
|
||||||
|
JX.Stratcom.invoke(
|
||||||
|
'EditEngine.didCommentPreview',
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
rootNode: preview_root
|
||||||
|
});
|
||||||
|
};
|
||||||
|
setTimeout(invoke_preview, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue