diff_state.js 992 Bytes
Newer Older
1 2
import Cookies from 'js-cookie';
import { getParameterValues } from '~/lib/utils/url_utility';
3
import bp from '~/breakpoints';
4
import { parseBoolean } from '~/lib/utils/common_utils';
5
import { INLINE_DIFF_VIEW_TYPE, DIFF_VIEW_COOKIE_NAME, MR_TREE_SHOW_KEY } from '../../constants';
6 7 8 9

const viewTypeFromQueryString = getParameterValues('view')[0];
const viewTypeFromCookie = Cookies.get(DIFF_VIEW_COOKIE_NAME);
const defaultViewType = INLINE_DIFF_VIEW_TYPE;
10
const storedTreeShow = localStorage.getItem(MR_TREE_SHOW_KEY);
11 12 13 14 15 16

export default () => ({
  isLoading: true,
  endpoint: '',
  basePath: '',
  commit: null,
17
  startVersion: null,
18 19
  diffFiles: [],
  mergeRequestDiffs: [],
20
  mergeRequestDiff: null,
21
  diffViewType: viewTypeFromQueryString || viewTypeFromCookie || defaultViewType,
22 23
  tree: [],
  treeEntries: {},
24
  showTreeList:
25
    storedTreeShow === null ? bp.getBreakpointSize() !== 'xs' : parseBoolean(storedTreeShow),
26
  currentDiffFileId: '',
27 28
  projectPath: '',
  commentForms: [],
29
});