Commit 3066bdd6 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'jivanvl-replace-underscore-lodash-ee-vue-shared' into 'master'

Replace underscore/lodash in ee/vue_shared

Closes #210267

See merge request gitlab-org/gitlab!27925
parents 81ba4565 6057e96e
<script>
import { uniqueId } from 'underscore';
import { uniqueId } from 'lodash';
export default {
created() {
......
<script>
import { uniqueId } from 'underscore';
import { uniqueId } from 'lodash';
import { GlSkeletonLoader } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
......
<script>
import _ from 'underscore';
import { escape as esc } from 'lodash';
import { __, n__, sprintf } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue';
......@@ -40,8 +40,8 @@ export default {
return sprintf(
__('%{title} %{operator} %{threshold}'),
{
title: _.escape(this.lastAlert.title),
threshold: `${_.escape(this.lastAlert.threshold)}%`,
title: esc(this.lastAlert.title),
threshold: `${esc(this.lastAlert.threshold)}%`,
operator: this.lastAlert.operator,
},
false,
......
import Visibility from 'visibilityjs';
import _ from 'underscore';
import { find } from 'lodash';
import Api from '~/api';
import axios from '~/lib/utils/axios_utils';
import Poll from '~/lib/utils/poll';
......@@ -33,7 +33,7 @@ export const addProjectsToDashboard = ({ state, dispatch }) =>
.catch(() => dispatch('receiveAddProjectsToDashboardError'));
export const toggleSelectedProject = ({ commit, state }, project) => {
if (!_.find(state.selectedProjects, { id: project.id })) {
if (!find(state.selectedProjects, { id: project.id })) {
commit(types.ADD_SELECTED_PROJECT, project);
} else {
commit(types.REMOVE_SELECTED_PROJECT, project);
......
<script>
import _ from 'underscore';
import { escape as esc } from 'lodash';
import { mapActions, mapState } from 'vuex';
import { s__, sprintf } from '~/locale';
import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue';
......@@ -12,7 +12,7 @@ export default {
computed: {
...mapState(LICENSE_MANAGEMENT, ['currentLicenseInModal']),
confirmationText() {
const name = `<strong>${_.escape(this.currentLicenseInModal.name)}</strong>`;
const name = `<strong>${esc(this.currentLicenseInModal.name)}</strong>`;
return sprintf(
s__('LicenseCompliance|You are about to remove the license, %{name}, from this project.'),
......
<script>
import _ from 'underscore';
import { escape as esc } from 'lodash';
import EventItem from 'ee/vue_shared/security_reports/components/event_item.vue';
import { GlButton } from '@gitlab/ui';
import { __, sprintf } from '~/locale';
......@@ -54,7 +54,7 @@ export default {
const projectLink =
project && project.url && project.value
? `<a href="${_.escape(project.url)}">${_.escape(project.value)}</a>`
? `<a href="${esc(project.url)}">${esc(project.value)}</a>`
: null;
if (pipelineLink && projectLink) {
......
<script>
import _ from 'underscore';
import { escape as esc } from 'lodash';
import EventItem from 'ee/vue_shared/security_reports/components/event_item.vue';
import { __, sprintf } from '~/locale';
......@@ -24,7 +24,7 @@ export default {
const issueLink = `<a href="${feedback.issue_url}">#${feedback.issue_iid}</a>`;
if (project && project.value && project.url) {
const projectLink = `<a href="${_.escape(project.url)}">${_.escape(project.value)}</a>`;
const projectLink = `<a href="${esc(project.url)}">${esc(project.value)}</a>`;
return sprintf(
__('Created issue %{issueLink} at %{projectLink}'),
......
<script>
import _ from 'underscore';
import { escape as esc } from 'lodash';
import EventItem from 'ee/vue_shared/security_reports/components/event_item.vue';
import { __, sprintf } from '~/locale';
......@@ -24,7 +24,7 @@ export default {
const mergeRequestLink = `<a href="${feedback.merge_request_path}">!${feedback.merge_request_iid}</a>`;
if (project && project.value && project.url) {
const projectLink = `<a href="${_.escape(project.url)}">${_.escape(project.value)}</a>`;
const projectLink = `<a href="${esc(project.url)}">${esc(project.value)}</a>`;
return sprintf(
__('Created merge request %{mergeRequestLink} at %{projectLink}'),
......
import { shallowMount } from '@vue/test-utils';
import { uniqueId } from 'underscore';
import { AccordionItem } from 'ee/vue_shared/components/accordion';
import accordionEventBus from 'ee/vue_shared/components/accordion/accordion_event_bus';
import { uniqueId } from 'lodash';
jest.mock('ee/vue_shared/components/accordion/accordion_event_bus', () => ({
$on: jest.fn(),
......@@ -10,7 +10,7 @@ jest.mock('ee/vue_shared/components/accordion/accordion_event_bus', () => ({
$off: jest.fn(),
}));
jest.mock('underscore');
jest.mock('lodash/uniqueId', () => jest.fn().mockReturnValue('mockUniqueId'));
describe('AccordionItem component', () => {
const mockUniqueId = 'mockUniqueId';
......@@ -43,10 +43,6 @@ describe('AccordionItem component', () => {
const content = () => wrapper.find({ ref: 'content' });
const namespacedCloseOtherAccordionItemsEvent = `${accordionId}.closeOtherAccordionItems`;
beforeEach(() => {
uniqueId.mockReturnValue(mockUniqueId);
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
......@@ -171,8 +167,7 @@ describe('AccordionItem component', () => {
it('contains a expansion trigger element with a unique, namespaced id', () => {
expect(uniqueId).toHaveBeenCalledWith('gl-accordion-item-trigger-');
expect(expansionTrigger().attributes('id')).toBe('mockUniqueId');
expect(expansionTrigger().attributes('id')).toBe(mockUniqueId);
});
it('contains a content-container element with a unique, namespaced id', () => {
......
import { shallowMount } from '@vue/test-utils';
import { Accordion } from 'ee/vue_shared/components/accordion';
import { uniqueId } from 'underscore';
jest.mock('underscore');
jest.mock('lodash/uniqueId', () => () => 'foo');
describe('Accordion component', () => {
let wrapper;
......@@ -30,7 +28,6 @@ describe('Accordion component', () => {
it('passes a unique "accordionId" to the default slot', () => {
const mockUniqueIdValue = 'foo';
uniqueId.mockReturnValueOnce(mockUniqueIdValue);
const defaultSlot = '<span>{{ props.accordionId }}</span>';
......
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