summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/diffs/store
diff options
context:
space:
mode:
authorAndré Luís <me@andr3.net>2018-09-20 08:21:17 +0000
committerPhil Hughes <me@iamphill.com>2018-09-20 08:21:17 +0000
commit38beacc926544725c43220bf7b9b4c90351f7831 (patch)
tree7ae08396f16bd8412e66b69926cd2ee86830743d /app/assets/javascripts/diffs/store
parent3314233588ec13eb16d562702aa281e99b44f825 (diff)
downloadgitlab-ce-38beacc926544725c43220bf7b9b4c90351f7831.tar.gz
Resolve "Link to file in Changes tab of MR no longer works for all files after incremental rendering improvement"
Diffstat (limited to 'app/assets/javascripts/diffs/store')
-rw-r--r--app/assets/javascripts/diffs/store/actions.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js
index 027df2ec841..e60bb9dd7e3 100644
--- a/app/assets/javascripts/diffs/store/actions.js
+++ b/app/assets/javascripts/diffs/store/actions.js
@@ -2,7 +2,7 @@ import Vue from 'vue';
import axios from '~/lib/utils/axios_utils';
import Cookies from 'js-cookie';
import { handleLocationHash, historyPushState } from '~/lib/utils/common_utils';
-import { mergeUrlParams } from '~/lib/utils/url_utility';
+import { mergeUrlParams, getLocationHash } from '~/lib/utils/url_utility';
import { getDiffPositionByLineCode } from './utils';
import * as types from './mutation_types';
import {
@@ -120,6 +120,25 @@ export const loadMoreLines = ({ commit }, options) => {
});
};
+export const scrollToLineIfNeededInline = (_, line) => {
+ const hash = getLocationHash();
+
+ if (hash && line.lineCode === hash) {
+ handleLocationHash();
+ }
+};
+
+export const scrollToLineIfNeededParallel = (_, line) => {
+ const hash = getLocationHash();
+
+ if (
+ hash &&
+ ((line.left && line.left.lineCode === hash) || (line.right && line.right.lineCode === hash))
+ ) {
+ handleLocationHash();
+ }
+};
+
export const loadCollapsedDiff = ({ commit }, file) =>
axios.get(file.loadCollapsedDiffUrl).then(res => {
commit(types.ADD_COLLAPSED_DIFFS, {