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:
authorFatih Acet <acetfatih@gmail.com>2016-11-01 23:31:04 +0300
committerFatih Acet <acetfatih@gmail.com>2016-11-01 23:31:04 +0300
commit3981f9f96893f52901c17015fecf97d97d46f7a0 (patch)
tree18276ed137201931b4a9408a85c5b35d1ae19c90 /app/assets/javascripts/merge_request_tabs.js
parent2cd6fdd6486608ecb98eb71708c3a0407fe56716 (diff)
parentd2ee380816fa161d94da54c1f7e594c9a2ba2241 (diff)
Merge branch '21633-permalink-to-collapsed-diff-line-does-not-work' into 'master'
Fixed anchoring diff lines in collapsed diffs ## What does this MR do? This MR adds the ability to `forceLoad` a collapsed diff from instantiation, on top of this, if it is force loaded, we can pass a callback function to be invoked when the content is loaded. Now when a MR is loaded, we check for a diff line anchor that is currently within a collapsed diff, we re-instantiate the `singleFileDiff` with the `forceLoad` option. We also pass a callback function that in responsible for highlighting and scrolling to the specified anchor. ## Are there points in the code the reviewer needs to double check? ## Why was this MR needed? We currently cannot anchor link to collapsed diff lines as the do not auto-expand. ## Screenshots (if relevant) https://youtu.be/fZVLlP6kchw ## Does this MR meet the acceptance criteria? - [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [ ] API support added - Tests - [ ] Added for this feature/bug - [ ] All builds are passing - [ ] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? Closes #21633 See merge request !6285
Diffstat (limited to 'app/assets/javascripts/merge_request_tabs.js')
-rw-r--r--app/assets/javascripts/merge_request_tabs.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js
index 6658e4811ce..860ee5df57e 100644
--- a/app/assets/javascripts/merge_request_tabs.js
+++ b/app/assets/javascripts/merge_request_tabs.js
@@ -238,8 +238,11 @@
_this.expandViewContainer();
}
_this.diffsLoaded = true;
- _this.scrollToElement("#diffs");
- _this.highlighSelectedLine();
+ var anchoredDiff = gl.utils.getLocationHash();
+ if (anchoredDiff) _this.openAnchoredDiff(anchoredDiff, function() {
+ _this.scrollToElement("#diffs");
+ _this.highlighSelectedLine();
+ });
_this.filesCommentButton = $('.files .diff-file').filesCommentButton();
return $(document).off('click', '.diff-line-num a').on('click', '.diff-line-num a', function(e) {
e.preventDefault();
@@ -252,6 +255,17 @@
});
};
+ MergeRequestTabs.prototype.openAnchoredDiff = function(anchoredDiff, cb) {
+ var diffTitle = $('#file-path-' + anchoredDiff);
+ var diffFile = diffTitle.closest('.diff-file');
+ var nothingHereBlock = $('.nothing-here-block:visible', diffFile);
+ if (nothingHereBlock.length) {
+ diffFile.singleFileDiff(true, cb);
+ } else {
+ cb();
+ }
+ };
+
MergeRequestTabs.prototype.highlighSelectedLine = function() {
var $diffLine, diffLineTop, hashClassString, locationHash, navBarHeight;
$('.hll').removeClass('hll');