Commit 5d76fe02 authored by Jeremy Wu's avatar Jeremy Wu Committed by Natalia Tepluhina

Fix 325232 create a global debounce time variable of 250

parent d4df549d
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import { __ } from '~/locale'; import { __ } from '~/locale';
export const SOURCE_EDITOR_INSTANCE_ERROR_NO_EL = __( export const SOURCE_EDITOR_INSTANCE_ERROR_NO_EL = __(
...@@ -5,7 +6,7 @@ export const SOURCE_EDITOR_INSTANCE_ERROR_NO_EL = __( ...@@ -5,7 +6,7 @@ export const SOURCE_EDITOR_INSTANCE_ERROR_NO_EL = __(
); );
export const URI_PREFIX = 'gitlab'; export const URI_PREFIX = 'gitlab';
export const CONTENT_UPDATE_DEBOUNCE = 250; export const CONTENT_UPDATE_DEBOUNCE = DEFAULT_DEBOUNCE_AND_THROTTLE_MS;
export const ERROR_INSTANCE_REQUIRED_FOR_EXTENSION = __( export const ERROR_INSTANCE_REQUIRED_FOR_EXTENSION = __(
'Source Editor instance is required to set up an extension.', 'Source Editor instance is required to set up an extension.',
......
import { throttle } from 'lodash'; import { throttle } from 'lodash';
import { Range } from 'monaco-editor'; import { Range } from 'monaco-editor';
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import Disposable from '../common/disposable'; import Disposable from '../common/disposable';
import DirtyDiffWorker from './diff_worker'; import DirtyDiffWorker from './diff_worker';
...@@ -31,7 +32,7 @@ export default class DirtyDiffController { ...@@ -31,7 +32,7 @@ export default class DirtyDiffController {
this.modelManager = modelManager; this.modelManager = modelManager;
this.decorationsController = decorationsController; this.decorationsController = decorationsController;
this.dirtyDiffWorker = new DirtyDiffWorker(); this.dirtyDiffWorker = new DirtyDiffWorker();
this.throttledComputeDiff = throttle(this.computeDiff, 250); this.throttledComputeDiff = throttle(this.computeDiff, DEFAULT_DEBOUNCE_AND_THROTTLE_MS);
this.decorate = this.decorate.bind(this); this.decorate = this.decorate.bind(this);
this.dirtyDiffWorker.addEventListener('message', this.decorate); this.dirtyDiffWorker.addEventListener('message', this.decorate);
......
export const BYTES_IN_KIB = 1024; export const BYTES_IN_KIB = 1024;
export const DEFAULT_DEBOUNCE_AND_THROTTLE_MS = 250;
export const HIDDEN_CLASS = 'hidden'; export const HIDDEN_CLASS = 'hidden';
export const TRUNCATE_WIDTH_DEFAULT_WIDTH = 80; export const TRUNCATE_WIDTH_DEFAULT_WIDTH = 80;
export const TRUNCATE_WIDTH_DEFAULT_FONT_SIZE = 12; export const TRUNCATE_WIDTH_DEFAULT_FONT_SIZE = 12;
......
...@@ -3,6 +3,7 @@ import { debounce } from 'lodash'; ...@@ -3,6 +3,7 @@ import { debounce } from 'lodash';
import createFlash from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { textColorForBackground } from '~/lib/utils/color_utils'; import { textColorForBackground } from '~/lib/utils/color_utils';
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import { __ } from '~/locale'; import { __ } from '~/locale';
export default () => { export default () => {
...@@ -65,7 +66,7 @@ export default () => { ...@@ -65,7 +66,7 @@ export default () => {
'input', 'input',
debounce(() => { debounce(() => {
reloadPreview(); reloadPreview();
}, 250), }, DEFAULT_DEBOUNCE_AND_THROTTLE_MS),
); );
const updateColorPreview = () => { const updateColorPreview = () => {
......
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
export const VARIABLE_TYPE = 'env_var'; export const VARIABLE_TYPE = 'env_var';
export const FILE_TYPE = 'file'; export const FILE_TYPE = 'file';
export const DEBOUNCE_REFS_SEARCH_MS = 250; export const DEBOUNCE_REFS_SEARCH_MS = DEFAULT_DEBOUNCE_AND_THROTTLE_MS;
export const CONFIG_VARIABLES_TIMEOUT = 5000; export const CONFIG_VARIABLES_TIMEOUT = 5000;
export const BRANCH_REF_TYPE = 'branch'; export const BRANCH_REF_TYPE = 'branch';
export const TAG_REF_TYPE = 'tag'; export const TAG_REF_TYPE = 'tag';
......
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import { __ } from '~/locale'; import { __ } from '~/locale';
export const REF_TYPE_BRANCHES = 'REF_TYPE_BRANCHES'; export const REF_TYPE_BRANCHES = 'REF_TYPE_BRANCHES';
...@@ -7,7 +8,7 @@ export const ALL_REF_TYPES = Object.freeze([REF_TYPE_BRANCHES, REF_TYPE_TAGS, RE ...@@ -7,7 +8,7 @@ export const ALL_REF_TYPES = Object.freeze([REF_TYPE_BRANCHES, REF_TYPE_TAGS, RE
export const X_TOTAL_HEADER = 'x-total'; export const X_TOTAL_HEADER = 'x-total';
export const SEARCH_DEBOUNCE_MS = 250; export const SEARCH_DEBOUNCE_MS = DEFAULT_DEBOUNCE_AND_THROTTLE_MS;
export const DEFAULT_I18N = Object.freeze({ export const DEFAULT_I18N = Object.freeze({
dropdownHeader: __('Select Git revision'), dropdownHeader: __('Select Git revision'),
......
...@@ -4,6 +4,7 @@ import $ from 'jquery'; ...@@ -4,6 +4,7 @@ import $ from 'jquery';
import { escape, throttle } from 'lodash'; import { escape, throttle } from 'lodash';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { getIdenticonBackgroundClass, getIdenticonTitle } from '~/helpers/avatar_helper'; import { getIdenticonBackgroundClass, getIdenticonTitle } from '~/helpers/avatar_helper';
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import { s__, __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
...@@ -343,7 +344,10 @@ export class SearchAutocomplete { ...@@ -343,7 +344,10 @@ export class SearchAutocomplete {
this.searchInput.on('focus', this.onSearchInputFocus); this.searchInput.on('focus', this.onSearchInputFocus);
this.searchInput.on('blur', this.onSearchInputBlur); this.searchInput.on('blur', this.onSearchInputBlur);
this.clearInput.on('click', this.onClearInputClick); this.clearInput.on('click', this.onClearInputClick);
this.dropdownContent.on('scroll', throttle(this.setScrollFade, 250)); this.dropdownContent.on(
'scroll',
throttle(this.setScrollFade, DEFAULT_DEBOUNCE_AND_THROTTLE_MS),
);
this.searchInput.on('click', (e) => { this.searchInput.on('click', (e) => {
e.stopPropagation(); e.stopPropagation();
......
import { IssuableType } from '~/issue_show/constants'; import { IssuableType } from '~/issue_show/constants';
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import epicConfidentialQuery from '~/sidebar/queries/epic_confidential.query.graphql'; import epicConfidentialQuery from '~/sidebar/queries/epic_confidential.query.graphql';
import epicDueDateQuery from '~/sidebar/queries/epic_due_date.query.graphql'; import epicDueDateQuery from '~/sidebar/queries/epic_due_date.query.graphql';
import epicParticipantsQuery from '~/sidebar/queries/epic_participants.query.graphql'; import epicParticipantsQuery from '~/sidebar/queries/epic_participants.query.graphql';
...@@ -35,7 +36,7 @@ import projectIssueMilestoneMutation from './queries/project_issue_milestone.mut ...@@ -35,7 +36,7 @@ import projectIssueMilestoneMutation from './queries/project_issue_milestone.mut
import projectIssueMilestoneQuery from './queries/project_issue_milestone.query.graphql'; import projectIssueMilestoneQuery from './queries/project_issue_milestone.query.graphql';
import projectMilestonesQuery from './queries/project_milestones.query.graphql'; import projectMilestonesQuery from './queries/project_milestones.query.graphql';
export const ASSIGNEES_DEBOUNCE_DELAY = 250; export const ASSIGNEES_DEBOUNCE_DELAY = DEFAULT_DEBOUNCE_AND_THROTTLE_MS;
export const defaultEpicSort = 'TITLE_ASC'; export const defaultEpicSort = 'TITLE_ASC';
......
import { masks } from 'dateformat'; import { masks } from 'dateformat';
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
const { isoDate, mediumDate } = masks; const { isoDate, mediumDate } = masks;
...@@ -24,4 +25,4 @@ export const OFFSET_DATE_BY_ONE = 1; ...@@ -24,4 +25,4 @@ export const OFFSET_DATE_BY_ONE = 1;
export const NO_DRAG_CLASS = 'no-drag'; export const NO_DRAG_CLASS = 'no-drag';
export const DATA_REFETCH_DELAY = 250; export const DATA_REFETCH_DELAY = DEFAULT_DEBOUNCE_AND_THROTTLE_MS;
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import { thWidthClass } from '~/lib/utils/table_utility'; import { thWidthClass } from '~/lib/utils/table_utility';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
...@@ -45,4 +46,4 @@ If you continue, the user will be removed from the %{namespace} ...@@ -45,4 +46,4 @@ If you continue, the user will be removed from the %{namespace}
group and all its subgroups and projects. This action can't be undone.`, group and all its subgroups and projects. This action can't be undone.`,
); );
export const AVATAR_SIZE = 32; export const AVATAR_SIZE = 32;
export const SEARCH_DEBOUNCE_MS = 250; export const SEARCH_DEBOUNCE_MS = DEFAULT_DEBOUNCE_AND_THROTTLE_MS;
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
export const DANGER = 'danger'; export const DANGER = 'danger';
...@@ -18,4 +19,4 @@ export const EDIT_PATH_ID_FORMAT = /\/id\//; ...@@ -18,4 +19,4 @@ export const EDIT_PATH_ID_FORMAT = /\/id\//;
// Check that it matches the format [FILE].y(a)ml@[GROUP]/[PROJECT] // Check that it matches the format [FILE].y(a)ml@[GROUP]/[PROJECT]
export const PIPELINE_CONFIGURATION_PATH_FORMAT = /^([^@]*\.ya?ml)@([^/]*)\/(.*)$/; export const PIPELINE_CONFIGURATION_PATH_FORMAT = /^([^@]*\.ya?ml)@([^/]*)\/(.*)$/;
export const DEBOUNCE_DELAY = 250; export const DEBOUNCE_DELAY = DEFAULT_DEBOUNCE_AND_THROTTLE_MS;
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
export const MESSAGES = { export const MESSAGES = {
...@@ -67,7 +68,7 @@ export const DEFAULT_FILTERS = { statuses: ['TRIGGERED', 'ACKNOWLEDGED'] }; ...@@ -67,7 +68,7 @@ export const DEFAULT_FILTERS = { statuses: ['TRIGGERED', 'ACKNOWLEDGED'] };
export const DOMAIN = 'threat_monitoring'; export const DOMAIN = 'threat_monitoring';
export const DEBOUNCE = 250; export const DEBOUNCE = DEFAULT_DEBOUNCE_AND_THROTTLE_MS;
export const ALL = { key: 'ALL', value: __('All') }; export const ALL = { key: 'ALL', value: __('All') };
......
...@@ -3,6 +3,7 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -3,6 +3,7 @@ import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import BranchesDropdown from '~/projects/commit/components/branches_dropdown.vue'; import BranchesDropdown from '~/projects/commit/components/branches_dropdown.vue';
Vue.use(Vuex); Vue.use(Vuex);
...@@ -82,7 +83,7 @@ describe('BranchesDropdown', () => { ...@@ -82,7 +83,7 @@ describe('BranchesDropdown', () => {
expect(findSearchBoxByType().exists()).toBe(true); expect(findSearchBoxByType().exists()).toBe(true);
expect(findSearchBoxByType().vm.$attrs).toMatchObject({ expect(findSearchBoxByType().vm.$attrs).toMatchObject({
placeholder: 'Search branches', placeholder: 'Search branches',
debounce: 250, debounce: DEFAULT_DEBOUNCE_AND_THROTTLE_MS,
}); });
}); });
}); });
......
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