Commit 6e4cfc73 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'resolve_gitlab_issue_196641' into 'master'

Replace underscore with lodash equivalents in ./app/assets/javascripts/vue_shared

See merge request gitlab-org/gitlab!25108
parents b7f09891 a7fc2585
<script> <script>
import _ from 'underscore'; import { isString, isEmpty } from 'lodash';
import { GlTooltipDirective, GlLink } from '@gitlab/ui'; import { GlTooltipDirective, GlLink } from '@gitlab/ui';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue'; import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
required: false, required: false,
default: undefined, default: undefined,
validator: ref => validator: ref =>
_.isUndefined(ref) || (_.isFinite(ref.iid) && _.isString(ref.path) && !_.isEmpty(ref.path)), ref === undefined || (Number.isFinite(ref.iid) && isString(ref.path) && !isEmpty(ref.path)),
}, },
/** /**
......
<script> <script>
import _ from 'underscore'; import { throttle } from 'lodash';
import { numberToHumanSize } from '../../../../lib/utils/number_utils'; import { numberToHumanSize } from '../../../../lib/utils/number_utils';
export default { export default {
...@@ -48,7 +48,7 @@ export default { ...@@ -48,7 +48,7 @@ export default {
mounted() { mounted() {
// The onImgLoad may have happened before the control was actually mounted // The onImgLoad may have happened before the control was actually mounted
this.onImgLoad(); this.onImgLoad();
this.resizeThrottled = _.throttle(this.onImgLoad, 400); this.resizeThrottled = throttle(this.onImgLoad, 400);
window.addEventListener('resize', this.resizeThrottled, false); window.addEventListener('resize', this.resizeThrottled, false);
}, },
methods: { methods: {
......
<script> <script>
import _ from 'underscore'; import { throttle } from 'lodash';
import { pixeliseValue } from '../../../lib/utils/dom_utils'; import { pixeliseValue } from '../../../lib/utils/dom_utils';
import ImageViewer from '../../../content_viewer/viewers/image_viewer.vue'; import ImageViewer from '../../../content_viewer/viewers/image_viewer.vue';
...@@ -98,7 +98,7 @@ export default { ...@@ -98,7 +98,7 @@ export default {
this.swipeOldImgInfo = imgInfo; this.swipeOldImgInfo = imgInfo;
this.prepareSwipe(); this.prepareSwipe();
}, },
resize: _.throttle(function throttledResize() { resize: throttle(function throttledResize() {
this.swipeBarPos = 0; this.swipeBarPos = 0;
this.swipeWrapWidth = 0; this.swipeWrapWidth = 0;
this.prepareSwipe(); this.prepareSwipe();
......
<script> <script>
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import icon from '../../../vue_shared/components/icon.vue'; import icon from '../../../vue_shared/components/icon.vue';
function buildDocsLinkStart(path) { function buildDocsLinkStart(path) {
return `<a href="${_.escape(path)}" target="_blank" rel="noopener noreferrer">`; return `<a href="${esc(path)}" target="_blank" rel="noopener noreferrer">`;
} }
export default { export default {
......
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import '~/behaviors/markdown/render_gfm'; import '~/behaviors/markdown/render_gfm';
import _ from 'underscore'; import { unescape as unesc } from 'lodash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { stripHtml } from '~/lib/utils/text_utility'; import { stripHtml } from '~/lib/utils/text_utility';
import Flash from '../../../flash'; import Flash from '../../../flash';
...@@ -115,7 +115,7 @@ export default { ...@@ -115,7 +115,7 @@ export default {
return text; return text;
} }
return _.unescape(stripHtml(richText).replace(/\n/g, '')); return unesc(stripHtml(richText).replace(/\n/g, ''));
} }
return ''; return '';
......
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import _ from 'underscore'; import { isString } from 'lodash';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue'; import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue';
import highlight from '~/lib/utils/highlight'; import highlight from '~/lib/utils/highlight';
...@@ -17,7 +17,7 @@ export default { ...@@ -17,7 +17,7 @@ export default {
project: { project: {
type: Object, type: Object,
required: true, required: true,
validator: p => _.isFinite(p.id) && _.isString(p.name) && _.isString(p.name_with_namespace), validator: p => Number.isFinite(p.id) && isString(p.name) && isString(p.name_with_namespace),
}, },
selected: { selected: {
type: Boolean, type: Boolean,
......
<script> <script>
import _ from 'underscore'; import { debounce } from 'lodash';
import { GlLoadingIcon, GlSearchBoxByType, GlInfiniteScroll } from '@gitlab/ui'; import { GlLoadingIcon, GlSearchBoxByType, GlInfiniteScroll } from '@gitlab/ui';
import ProjectListItem from './project_list_item.vue'; import ProjectListItem from './project_list_item.vue';
...@@ -61,9 +61,9 @@ export default { ...@@ -61,9 +61,9 @@ export default {
this.$emit('bottomReached'); this.$emit('bottomReached');
}, },
isSelected(project) { isSelected(project) {
return Boolean(_.find(this.selectedProjects, { id: project.id })); return this.selectedProjects.some(({ id }) => project.id === id);
}, },
onInput: _.debounce(function debouncedOnInput() { onInput: debounce(function debouncedOnInput() {
this.$emit('searched', this.searchQuery); this.$emit('searched', this.searchQuery);
}, SEARCH_INPUT_TIMEOUT_MS), }, SEARCH_INPUT_TIMEOUT_MS),
}, },
......
<script> <script>
import _ from 'underscore'; import { isString } from 'lodash';
import { GlDropdown, GlDropdownDivider, GlDropdownItem } from '@gitlab/ui'; import { GlDropdown, GlDropdownDivider, GlDropdownItem } from '@gitlab/ui';
const isValidItem = item => const isValidItem = item =>
_.isString(item.eventName) && _.isString(item.title) && _.isString(item.description); isString(item.eventName) && isString(item.title) && isString(item.description);
export default { export default {
components: { components: {
......
import _ from 'underscore'; import { isEmpty } from 'lodash';
import { sprintf, __ } from '~/locale'; import { sprintf, __ } from '~/locale';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
...@@ -130,7 +130,7 @@ const mixins = { ...@@ -130,7 +130,7 @@ const mixins = {
return this.assignees.length > 0; return this.assignees.length > 0;
}, },
hasMilestone() { hasMilestone() {
return !_.isEmpty(this.milestone); return !isEmpty(this.milestone);
}, },
iconName() { iconName() {
if (this.isMergeRequest && this.isMerged) { if (this.isMergeRequest && this.isMerged) {
......
---
title: Replace underscore with lodash for ./app/assets/javascripts/vue_shared
merge_request: 25108
author: Tobias Spagert
type: other
...@@ -22,6 +22,7 @@ describe('ProjectSelector component', () => { ...@@ -22,6 +22,7 @@ describe('ProjectSelector component', () => {
beforeEach(() => { beforeEach(() => {
jasmine.clock().install(); jasmine.clock().install();
jasmine.clock().mockDate();
wrapper = mount(Vue.extend(ProjectSelector), { wrapper = mount(Vue.extend(ProjectSelector), {
localVue, localVue,
......
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