Commit 25ffe5ac authored by Paul Slaughter's avatar Paul Slaughter Committed by Jose Vargas

Move max MR files to open count to constant

- Previously this was just a magic number
- Now its encapsulated
parent 25d9884f
...@@ -107,3 +107,7 @@ export const SIDE_RIGHT = 'right'; ...@@ -107,3 +107,7 @@ export const SIDE_RIGHT = 'right';
// Live Preview feature // Live Preview feature
export const LIVE_PREVIEW_DEBOUNCE = 2000; export const LIVE_PREVIEW_DEBOUNCE = 2000;
// This is the maximum number of files to auto open when opening the Web IDE
// from a Merge Request
export const MAX_MR_FILES_AUTO_OPEN = 10;
import { deprecatedCreateFlash as flash } from '~/flash'; import { deprecatedCreateFlash as flash } from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { leftSidebarViews, PERMISSION_READ_MR } from '../../constants'; import { leftSidebarViews, PERMISSION_READ_MR, MAX_MR_FILES_AUTO_OPEN } from '../../constants';
import service from '../../services'; import service from '../../services';
import * as types from '../mutation_types'; import * as types from '../mutation_types';
...@@ -152,7 +152,9 @@ export const openMergeRequestChanges = async ({ dispatch, getters, state, commit ...@@ -152,7 +152,9 @@ export const openMergeRequestChanges = async ({ dispatch, getters, state, commit
.map((change) => ({ entry: state.entries[change.new_path], change })) .map((change) => ({ entry: state.entries[change.new_path], change }))
.filter((x) => x.entry); .filter((x) => x.entry);
const pathsToOpen = entryChanges.slice(0, 10).map(({ change }) => change.new_path); const pathsToOpen = entryChanges
.slice(0, MAX_MR_FILES_AUTO_OPEN)
.map(({ change }) => change.new_path);
// If there are no changes with entries, do nothing. // If there are no changes with entries, do nothing.
if (!entryChanges.length) { if (!entryChanges.length) {
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { range } from 'lodash'; import { range } from 'lodash';
import testAction from 'helpers/vuex_action_helper';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import { leftSidebarViews, PERMISSION_READ_MR } from '~/ide/constants'; import { leftSidebarViews, PERMISSION_READ_MR, MAX_MR_FILES_AUTO_OPEN } from '~/ide/constants';
import service from '~/ide/services'; import service from '~/ide/services';
import { createStore } from '~/ide/stores'; import { createStore } from '~/ide/stores';
import { import {
...@@ -395,7 +395,7 @@ describe('IDE store merge request actions', () => { ...@@ -395,7 +395,7 @@ describe('IDE store merge request actions', () => {
(acc, { path }) => Object.assign(acc, { [path]: path, type: 'blob' }), (acc, { path }) => Object.assign(acc, { [path]: path, type: 'blob' }),
{}, {},
); );
const pathsToOpen = changes.slice(0, 10).map((x) => x.new_path); const pathsToOpen = changes.slice(0, MAX_MR_FILES_AUTO_OPEN).map((x) => x.new_path);
return testAction({ return testAction({
action: openMergeRequestChanges, action: openMergeRequestChanges,
......
import { basename } from 'path'; import { basename } from 'path';
import { useOverclockTimers } from 'test_helpers/utils/overclock_timers';
import { getMergeRequests, getMergeRequestWithChanges } from 'test_helpers/fixtures'; import { getMergeRequests, getMergeRequestWithChanges } from 'test_helpers/fixtures';
import { useOverclockTimers } from 'test_helpers/utils/overclock_timers';
import * as ideHelper from './helpers/ide_helper'; import * as ideHelper from './helpers/ide_helper';
import startWebIDE from './helpers/start'; import startWebIDE from './helpers/start';
......
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