Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-05-12 13:19:32 +0300
committerEric Eastwood <contact@ericeastwood.com>2017-05-13 01:48:29 +0300
commit16da7f2365fe67c078a2f10766662b93fe8576fc (patch)
tree2a55472efc4a5190b7541904882459f67445ca03 /app/assets/javascripts/merge_request_tabs.js
parent1ccf101eef7db401317838a453795fa1c28ec036 (diff)
Fix linking to resolved note in diff
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/32125
Diffstat (limited to 'app/assets/javascripts/merge_request_tabs.js')
-rw-r--r--app/assets/javascripts/merge_request_tabs.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js
index 93c30c54a8e..efbfdbcee0c 100644
--- a/app/assets/javascripts/merge_request_tabs.js
+++ b/app/assets/javascripts/merge_request_tabs.js
@@ -1,6 +1,7 @@
/* eslint-disable no-new, class-methods-use-this */
/* global Breakpoints */
/* global Flash */
+/* global notes */
import Cookies from 'js-cookie';
import './breakpoints';
@@ -251,7 +252,8 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion';
this.ajaxGet({
url: `${urlPathname}.json${location.search}`,
success: (data) => {
- $('#diffs').html(data.html);
+ const $container = $('#diffs');
+ $container.html(data.html);
if (typeof gl.diffNotesCompileComponents !== 'undefined') {
gl.diffNotesCompileComponents();
@@ -278,6 +280,20 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion';
})
.init();
});
+
+ // Scroll any linked note into view
+ // Similar to `toggler_behavior` in the discussion tab
+ const hash = window.gl.utils.getLocationHash();
+ const anchor = hash && $container.find(`[id="${hash}"]`);
+ if (anchor) {
+ const notesContent = anchor.closest('.notes_content');
+ const lineType = notesContent.hasClass('new') ? 'new' : 'old';
+ notes.addDiffNote(anchor, lineType, false);
+ anchor[0].scrollIntoView();
+ // We have multiple elements on the page with `#note_xxx`
+ // (discussion and diff tabs) and `:target` only applies to the first
+ anchor.addClass('target');
+ }
},
});
}