Commit 715a4020 authored by Jose Vargas's avatar Jose Vargas

Replace underscore/lodash in design_management

This replaces all underscore usage for lodash inside
the EE feature design_management
parent 502cdc4a
<script> <script>
import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui'; import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui';
import _ from 'underscore'; import { uniqueId } from 'lodash';
export default { export default {
name: 'DeleteButton', name: 'DeleteButton',
...@@ -35,7 +35,7 @@ export default { ...@@ -35,7 +35,7 @@ export default {
}, },
data() { data() {
return { return {
modalId: _.uniqueId('design-deletion-confirmation-'), modalId: uniqueId('design-deletion-confirmation-'),
}; };
}, },
}; };
......
<script> <script>
import _ from 'underscore'; import { throttle } from 'lodash';
import DesignImage from './image.vue'; import DesignImage from './image.vue';
import DesignOverlay from './design_overlay.vue'; import DesignOverlay from './design_overlay.vue';
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
const { presentationViewport } = this.$refs; const { presentationViewport } = this.$refs;
if (!presentationViewport) return; if (!presentationViewport) return;
this.scrollThrottled = _.throttle(() => { this.scrollThrottled = throttle(() => {
this.shiftZoomFocalPoint(); this.shiftZoomFocalPoint();
}, 400); }, 400);
......
<script> <script>
import _ from 'underscore'; import { throttle } from 'lodash';
export default { export default {
props: { props: {
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
mounted() { mounted() {
this.onImgLoad(); this.onImgLoad();
this.resizeThrottled = _.throttle(() => { this.resizeThrottled = throttle(() => {
// NOTE: if imageStyle is set, then baseImageSize // NOTE: if imageStyle is set, then baseImageSize
// won't change due to resize. We must still emit a // won't change due to resize. We must still emit a
// `resize` event so that the parent can handle // `resize` event so that the parent can handle
......
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import _ from 'underscore'; import { uniqueId } from 'lodash';
import { defaultDataIdFromObject } from 'apollo-cache-inmemory'; import { defaultDataIdFromObject } from 'apollo-cache-inmemory';
import createDefaultClient from '~/lib/graphql'; import createDefaultClient from '~/lib/graphql';
...@@ -15,7 +15,7 @@ const defaultClient = createDefaultClient( ...@@ -15,7 +15,7 @@ const defaultClient = createDefaultClient(
dataIdFromObject: object => { dataIdFromObject: object => {
// eslint-disable-next-line no-underscore-dangle, @gitlab/require-i18n-strings // eslint-disable-next-line no-underscore-dangle, @gitlab/require-i18n-strings
if (object.__typename === 'Design') { if (object.__typename === 'Design') {
return object.id && object.image ? `${object.id}-${object.image}` : _.uniqueId(); return object.id && object.image ? `${object.id}-${object.image}` : uniqueId();
} }
return defaultDataIdFromObject(object); return defaultDataIdFromObject(object);
}, },
......
import { propertyOf } from 'underscore'; import { propertyOf } from 'lodash';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import projectQuery from '../graphql/queries/project.query.graphql'; import projectQuery from '../graphql/queries/project.query.graphql';
......
import { uniqueId } from 'underscore'; import { uniqueId } from 'lodash';
import { VALID_DESIGN_FILE_MIMETYPE } from '../constants'; import { VALID_DESIGN_FILE_MIMETYPE } from '../constants';
export const isValidDesignFile = ({ type }) => export const isValidDesignFile = ({ type }) =>
......
import underscore from 'underscore';
import { import {
extractCurrentDiscussion, extractCurrentDiscussion,
extractDiscussions, extractDiscussions,
...@@ -8,6 +7,8 @@ import { ...@@ -8,6 +7,8 @@ import {
isValidDesignFile, isValidDesignFile,
} from 'ee/design_management/utils/design_management_utils'; } from 'ee/design_management/utils/design_management_utils';
jest.mock('lodash/uniqueId', () => () => 1);
describe('extractCurrentDiscussion', () => { describe('extractCurrentDiscussion', () => {
let discussions; let discussions;
...@@ -75,7 +76,6 @@ describe('version parser', () => { ...@@ -75,7 +76,6 @@ describe('version parser', () => {
describe('optimistic responses', () => { describe('optimistic responses', () => {
it('correctly generated for designManagementUpload', () => { it('correctly generated for designManagementUpload', () => {
jest.spyOn(underscore, 'uniqueId').mockImplementation(() => 1);
const expectedResponse = { const expectedResponse = {
__typename: 'Mutation', __typename: 'Mutation',
designManagementUpload: { designManagementUpload: {
......
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