Commit 36a4862b authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/allowVirtualScrollingToBeDisabled' into 'master'

Allows for virtual scrolling to be disabled by a URL param

See merge request gitlab-org/gitlab!66249
parents ac4dcbe0 06a35867
...@@ -2,6 +2,7 @@ import Cookies from 'js-cookie'; ...@@ -2,6 +2,7 @@ import Cookies from 'js-cookie';
import Vue from 'vue'; import Vue from 'vue';
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import { getParameterValues } from '~/lib/utils/url_utility';
import FindFile from '~/vue_shared/components/file_finder/index.vue'; import FindFile from '~/vue_shared/components/file_finder/index.vue';
import eventHub from '../notes/event_hub'; import eventHub from '../notes/event_hub';
import diffsApp from './components/app.vue'; import diffsApp from './components/app.vue';
...@@ -115,6 +116,11 @@ export default function initDiffsApp(store) { ...@@ -115,6 +116,11 @@ export default function initDiffsApp(store) {
trackClick: false, trackClick: false,
}); });
} }
const vScrollingParam = getParameterValues('virtual_scrolling')[0];
if (vScrollingParam === 'false' || vScrollingParam === 'true') {
Cookies.set('diffs_virtual_scrolling', vScrollingParam);
}
}, },
methods: { methods: {
...mapActions('diffs', ['setRenderTreeList', 'setShowWhitespace']), ...mapActions('diffs', ['setRenderTreeList', 'setShowWhitespace']),
......
import Cookies from 'js-cookie';
import { getParameterValues } from '~/lib/utils/url_utility'; import { getParameterValues } from '~/lib/utils/url_utility';
import { __, n__ } from '~/locale'; import { __, n__ } from '~/locale';
import { import {
...@@ -173,7 +174,16 @@ export function suggestionCommitMessage(state, _, rootState) { ...@@ -173,7 +174,16 @@ export function suggestionCommitMessage(state, _, rootState) {
}); });
} }
export const isVirtualScrollingEnabled = (state) => export const isVirtualScrollingEnabled = (state) => {
const vSrollerCookie = Cookies.get('diffs_virtual_scrolling');
if (vSrollerCookie) {
return vSrollerCookie === 'true';
}
return (
!state.viewDiffsFileByFile && !state.viewDiffsFileByFile &&
(window.gon?.features?.diffsVirtualScrolling || (window.gon?.features?.diffsVirtualScrolling ||
getParameterValues('virtual_scrolling')[0] === 'true'); getParameterValues('virtual_scrolling')[0] === 'true')
);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment