Commit 2a3163e7 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'lm-replace-lodash-ide' into 'master'

Replaces underscore with lodash for app/assets/javascripts/ide

See merge request gitlab-org/gitlab!27051
parents 674f7bc5 b535f94d
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import _ from 'underscore'; import { debounce } from 'lodash';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import Item from './item.vue'; import Item from './item.vue';
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
loadBranches() { loadBranches() {
this.fetchBranches({ search: this.search }); this.fetchBranches({ search: this.search });
}, },
searchBranches: _.debounce(function debounceSearch() { searchBranches: debounce(function debounceSearch() {
this.loadBranches(); this.loadBranches();
}, 250), }, 250),
focusSearch() { focusSearch() {
......
<script> <script>
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { mapState, mapGetters, createNamespacedHelpers } from 'vuex'; import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
import { sprintf, s__ } from '~/locale'; import { sprintf, s__ } from '~/locale';
import consts from '../../stores/modules/commit/constants'; import consts from '../../stores/modules/commit/constants';
...@@ -22,7 +22,7 @@ export default { ...@@ -22,7 +22,7 @@ export default {
commitToCurrentBranchText() { commitToCurrentBranchText() {
return sprintf( return sprintf(
s__('IDE|Commit to %{branchName} branch'), s__('IDE|Commit to %{branchName} branch'),
{ branchName: `<strong class="monospace">${_.escape(this.currentBranchId)}</strong>` }, { branchName: `<strong class="monospace">${esc(this.currentBranchId)}</strong>` },
false, false,
); );
}, },
......
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import _ from 'underscore'; import { throttle } from 'lodash';
import { __ } from '../../../locale'; import { __ } from '../../../locale';
import tooltip from '../../../vue_shared/directives/tooltip'; import tooltip from '../../../vue_shared/directives/tooltip';
import Icon from '../../../vue_shared/components/icon.vue'; import Icon from '../../../vue_shared/components/icon.vue';
...@@ -53,7 +53,7 @@ export default { ...@@ -53,7 +53,7 @@ export default {
this.$refs.buildTrace.scrollTo(0, 0); this.$refs.buildTrace.scrollTo(0, 0);
} }
}, },
scrollBuildLog: _.throttle(function buildLogScrollDebounce() { scrollBuildLog: throttle(function buildLogScrollDebounce() {
const { scrollTop } = this.$refs.buildTrace; const { scrollTop } = this.$refs.buildTrace;
const { offsetHeight, scrollHeight } = this.$refs.buildTrace; const { offsetHeight, scrollHeight } = this.$refs.buildTrace;
......
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import _ from 'underscore'; import { debounce } from 'lodash';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
...@@ -59,7 +59,7 @@ export default { ...@@ -59,7 +59,7 @@ export default {
loadMergeRequests() { loadMergeRequests() {
this.fetchMergeRequests({ type: this.type, search: this.search }); this.fetchMergeRequests({ type: this.type, search: this.search });
}, },
searchMergeRequests: _.debounce(function debounceSearch() { searchMergeRequests: debounce(function debounceSearch() {
this.loadMergeRequests(); this.loadMergeRequests();
}, 250), }, 250),
onSearchFocus() { onSearchFocus() {
......
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import _ from 'underscore';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import ResizablePanel from '../resizable_panel.vue'; import ResizablePanel from '../resizable_panel.vue';
...@@ -55,7 +54,7 @@ export default { ...@@ -55,7 +54,7 @@ export default {
return this.extensionTabs.filter(tab => tab.show); return this.extensionTabs.filter(tab => tab.show);
}, },
tabViews() { tabViews() {
return _.flatten(this.tabs.map(tab => tab.views)); return this.tabs.map(tab => tab.views).flat();
}, },
aliveTabViews() { aliveTabViews() {
return this.tabViews.filter(view => this.isAliveView(view.name)); return this.tabViews.filter(view => this.isAliveView(view.name));
......
<script> <script>
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { sprintf, __ } from '../../../locale'; import { sprintf, __ } from '../../../locale';
import Icon from '../../../vue_shared/components/icon.vue'; import Icon from '../../../vue_shared/components/icon.vue';
...@@ -35,7 +35,7 @@ export default { ...@@ -35,7 +35,7 @@ export default {
return sprintf( return sprintf(
__('You can test your .gitlab-ci.yml in %{linkStart}CI Lint%{linkEnd}.'), __('You can test your .gitlab-ci.yml in %{linkStart}CI Lint%{linkEnd}.'),
{ {
linkStart: `<a href="${_.escape(this.currentProject.web_url)}/-/ci/lint">`, linkStart: `<a href="${esc(this.currentProject.web_url)}/-/ci/lint">`,
linkEnd: '</a>', linkEnd: '</a>',
}, },
false, false,
......
<script> <script>
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import _ from 'underscore'; import { isEmpty } from 'lodash';
import { Manager } from 'smooshpack'; import { Manager } from 'smooshpack';
import { listen } from 'codesandbox-api'; import { listen } from 'codesandbox-api';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
...@@ -78,7 +78,7 @@ export default { ...@@ -78,7 +78,7 @@ export default {
.then(() => this.initPreview()); .then(() => this.initPreview());
}, },
beforeDestroy() { beforeDestroy() {
if (!_.isEmpty(this.manager)) { if (!isEmpty(this.manager)) {
this.manager.listener(); this.manager.listener();
} }
this.manager = {}; this.manager = {};
...@@ -125,7 +125,7 @@ export default { ...@@ -125,7 +125,7 @@ export default {
clearTimeout(this.timeout); clearTimeout(this.timeout);
this.timeout = setTimeout(() => { this.timeout = setTimeout(() => {
if (_.isEmpty(this.manager)) { if (isEmpty(this.manager)) {
this.initPreview(); this.initPreview();
return; return;
......
import Vue from 'vue'; import Vue from 'vue';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import _ from 'underscore';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
import { identity } from 'lodash';
import ide from './components/ide.vue'; import ide from './components/ide.vue';
import store from './stores'; import store from './stores';
import router from './ide_router'; import router from './ide_router';
...@@ -31,7 +31,7 @@ Vue.use(Translate); ...@@ -31,7 +31,7 @@ Vue.use(Translate);
export function initIde(el, options = {}) { export function initIde(el, options = {}) {
if (!el) return null; if (!el) return null;
const { rootComponent = ide, extendStore = _.identity } = options; const { rootComponent = ide, extendStore = identity } = options;
return new Vue({ return new Vue({
el, el,
......
import { Range } from 'monaco-editor'; import { Range } from 'monaco-editor';
import { throttle } from 'underscore'; import { throttle } from 'lodash';
import DirtyDiffWorker from './diff_worker'; import DirtyDiffWorker from './diff_worker';
import Disposable from '../common/disposable'; import Disposable from '../common/disposable';
......
import _ from 'underscore'; import { debounce } from 'lodash';
import { editor as monacoEditor, KeyCode, KeyMod } from 'monaco-editor'; import { editor as monacoEditor, KeyCode, KeyMod } from 'monaco-editor';
import store from '../stores'; import store from '../stores';
import DecorationsController from './decorations/controller'; import DecorationsController from './decorations/controller';
...@@ -38,7 +38,7 @@ export default class Editor { ...@@ -38,7 +38,7 @@ export default class Editor {
setupThemes(); setupThemes();
this.debouncedUpdate = _.debounce(() => { this.debouncedUpdate = debounce(() => {
this.updateDimensions(); this.updateDimensions();
}, 200); }, 200);
} }
......
import $ from 'jquery'; import $ from 'jquery';
import Vue from 'vue'; import Vue from 'vue';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import flash from '~/flash'; import flash from '~/flash';
...@@ -296,7 +296,7 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force = ...@@ -296,7 +296,7 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force =
sprintf( sprintf(
__('Branch not loaded - %{branchId}'), __('Branch not loaded - %{branchId}'),
{ {
branchId: `<strong>${_.escape(projectId)}/${_.escape(branchId)}</strong>`, branchId: `<strong>${esc(projectId)}/${esc(branchId)}</strong>`,
}, },
false, false,
), ),
......
import _ from 'underscore'; import { escape as esc } from 'lodash';
import flash from '~/flash'; import flash from '~/flash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import service from '../../services'; import service from '../../services';
...@@ -73,7 +73,7 @@ export const showBranchNotFoundError = ({ dispatch }, branchId) => { ...@@ -73,7 +73,7 @@ export const showBranchNotFoundError = ({ dispatch }, branchId) => {
text: sprintf( text: sprintf(
__("Branch %{branchName} was not found in this project's repository."), __("Branch %{branchName} was not found in this project's repository."),
{ {
branchName: `<strong>${_.escape(branchId)}</strong>`, branchName: `<strong>${esc(branchId)}</strong>`,
}, },
false, false,
), ),
...@@ -154,7 +154,7 @@ export const openBranch = ({ dispatch, state, getters }, { projectId, branchId, ...@@ -154,7 +154,7 @@ export const openBranch = ({ dispatch, state, getters }, { projectId, branchId,
sprintf( sprintf(
__('An error occurred while getting files for - %{branchId}'), __('An error occurred while getting files for - %{branchId}'),
{ {
branchId: `<strong>${_.escape(projectId)}/${_.escape(branchId)}</strong>`, branchId: `<strong>${esc(projectId)}/${esc(branchId)}</strong>`,
}, },
false, false,
), ),
......
import _ from 'underscore'; import { defer } from 'lodash';
import { __ } from '../../../locale'; import { __ } from '../../../locale';
import service from '../../services'; import service from '../../services';
import * as types from '../mutation_types'; import * as types from '../mutation_types';
...@@ -71,7 +71,7 @@ export const getFiles = ({ state, commit, dispatch }, payload = {}) => ...@@ -71,7 +71,7 @@ export const getFiles = ({ state, commit, dispatch }, payload = {}) =>
// Defer setting the directory data because this triggers some intense rendering. // Defer setting the directory data because this triggers some intense rendering.
// The entries is all we need to load the file editor. // The entries is all we need to load the file editor.
_.defer(() => dispatch('setDirectoryData', { projectId, branchId, treeList })); defer(() => dispatch('setDirectoryData', { projectId, branchId, treeList }));
resolve(); resolve();
}) })
......
...@@ -9,6 +9,8 @@ import { branches } from '../../mock_data'; ...@@ -9,6 +9,8 @@ import { branches } from '../../mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
jest.mock('lodash/debounce', () => jest.fn);
describe('IDE branches search list', () => { describe('IDE branches search list', () => {
let wrapper; let wrapper;
const fetchBranchesMock = jest.fn(); const fetchBranchesMock = jest.fn();
......
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