Commit 4a995726 authored by Jose Vargas's avatar Jose Vargas

Replace underscore/lodash in ee/projects

parent 424778d6
<script> <script>
import { uniqueId } from 'underscore'; import { uniqueId } from 'lodash';
import { GlLink, GlIntersperse, GlModal, GlButton, GlModalDirective } from '@gitlab/ui'; import { GlLink, GlIntersperse, GlModal, GlButton, GlModalDirective } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale'; import { sprintf, s__ } from '~/locale';
......
<script> <script>
import { escape } from 'underscore'; import { escape } from 'lodash';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
......
import _ from 'underscore'; import { uniqueId } from 'lodash';
export const getLicenseKey = ({ id }) => { export const getLicenseKey = ({ id }) => {
if (id) { if (id) {
return `id_${id}`; return `id_${id}`;
} }
return `client_${_.uniqueId()}`; return `client_${uniqueId()}`;
}; };
/** /**
......
/* eslint-disable no-underscore-dangle, class-methods-use-this */ /* eslint-disable no-underscore-dangle, class-methods-use-this */
import { escape as esc, find, countBy } from 'lodash';
import _ from 'underscore';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import Flash from '~/flash'; import Flash from '~/flash';
import { n__, s__, __ } from '~/locale'; import { n__, s__, __ } from '~/locale';
...@@ -269,7 +268,7 @@ export default class AccessDropdown { ...@@ -269,7 +268,7 @@ export default class AccessDropdown {
} }
const labelPieces = []; const labelPieces = [];
const counts = _.countBy(currentItems, item => item.type); const counts = countBy(currentItems, item => item.type);
if (counts[LEVEL_TYPES.ROLE] > 0) { if (counts[LEVEL_TYPES.ROLE] > 0) {
labelPieces.push(n__('1 role', '%d roles', counts[LEVEL_TYPES.ROLE])); labelPieces.push(n__('1 role', '%d roles', counts[LEVEL_TYPES.ROLE]));
...@@ -445,7 +444,7 @@ export default class AccessDropdown { ...@@ -445,7 +444,7 @@ export default class AccessDropdown {
break; break;
} }
const isActive = _.find(this.getSelectedItems(), criteria) ? 'is-active' : ''; const isActive = find(this.getSelectedItems(), criteria) ? 'is-active' : '';
switch (item.type) { switch (item.type) {
case LEVEL_TYPES.USER: case LEVEL_TYPES.USER:
...@@ -472,7 +471,7 @@ export default class AccessDropdown { ...@@ -472,7 +471,7 @@ export default class AccessDropdown {
<li> <li>
<a href="#" class="${isActiveClass}"> <a href="#" class="${isActiveClass}">
<img src="${user.avatar_url}" class="avatar avatar-inline" width="30"> <img src="${user.avatar_url}" class="avatar avatar-inline" width="30">
<strong class="dropdown-menu-user-full-name">${_.escape(user.name)}</strong> <strong class="dropdown-menu-user-full-name">${esc(user.name)}</strong>
<span class="dropdown-menu-user-username">${user.username}</span> <span class="dropdown-menu-user-username">${user.username}</span>
</a> </a>
</li> </li>
......
...@@ -7,9 +7,7 @@ import PaginatedLicensesTable from 'ee/project_licenses/components/paginated_lic ...@@ -7,9 +7,7 @@ import PaginatedLicensesTable from 'ee/project_licenses/components/paginated_lic
import Pagination from '~/vue_shared/components/pagination_links.vue'; import Pagination from '~/vue_shared/components/pagination_links.vue';
import mockLicensesResponse from '../store/modules/list/data/mock_licenses.json'; import mockLicensesResponse from '../store/modules/list/data/mock_licenses.json';
jest.mock('underscore', () => ({ jest.mock('lodash/uniqueId', () => () => 'fakeUniqueId');
uniqueId: () => 'fakeUniqueId',
}));
describe('PaginatedLicensesTable component', () => { describe('PaginatedLicensesTable component', () => {
const namespace = LICENSE_LIST; const namespace = LICENSE_LIST;
......
import { toLicenseObject } from 'ee/project_licenses/utils/mappers'; import { toLicenseObject } from 'ee/project_licenses/utils/mappers';
const UNIQUE_ID = 'fakeUniqueId'; const UNIQUE_ID = 'fakeUniqueId';
jest.mock('underscore', () => ({ jest.mock('lodash/uniqueId', () => () => 'fakeUniqueId');
uniqueId: () => 'fakeUniqueId',
}));
describe('ee/project_licenses/utils/mappers', () => { describe('ee/project_licenses/utils/mappers', () => {
describe('toLicenseObject', () => { describe('toLicenseObject', () => {
......
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