Commit bd392b93 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'jivanvl-replace-underscore-lodash-diffs' into 'master'

Replace underscore for lodash in diffs

Closes #196687

See merge request gitlab-org/gitlab!25712
parents db662ee6 29406c26
<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 createFlash from '~/flash'; import createFlash from '~/flash';
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
return sprintf( return sprintf(
__('You can %{linkStart}view the blob%{linkEnd} instead.'), __('You can %{linkStart}view the blob%{linkEnd} instead.'),
{ {
linkStart: `<a href="${_.escape(this.file.view_path)}">`, linkStart: `<a href="${esc(this.file.view_path)}">`,
linkEnd: '</a>', linkEnd: '</a>',
}, },
false, false,
......
<script> <script>
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import { GlButton, GlTooltipDirective, GlLoadingIcon } from '@gitlab/ui'; import { GlButton, GlTooltipDirective, GlLoadingIcon } from '@gitlab/ui';
import { polyfillSticky } from '~/lib/utils/sticky'; import { polyfillSticky } from '~/lib/utils/sticky';
...@@ -91,7 +91,7 @@ export default { ...@@ -91,7 +91,7 @@ export default {
return this.expanded ? 'chevron-down' : 'chevron-right'; return this.expanded ? 'chevron-down' : 'chevron-right';
}, },
viewFileButtonText() { viewFileButtonText() {
const truncatedContentSha = _.escape(truncateSha(this.diffFile.content_sha)); const truncatedContentSha = esc(truncateSha(this.diffFile.content_sha));
return sprintf( return sprintf(
s__('MergeRequests|View file @ %{commitId}'), s__('MergeRequests|View file @ %{commitId}'),
{ commitId: truncatedContentSha }, { commitId: truncatedContentSha },
...@@ -99,7 +99,7 @@ export default { ...@@ -99,7 +99,7 @@ export default {
); );
}, },
viewReplacedFileButtonText() { viewReplacedFileButtonText() {
const truncatedBaseSha = _.escape(truncateSha(this.diffFile.diff_refs.base_sha)); const truncatedBaseSha = esc(truncateSha(this.diffFile.diff_refs.base_sha));
return sprintf( return sprintf(
s__('MergeRequests|View replaced file @ %{commitId}'), s__('MergeRequests|View replaced file @ %{commitId}'),
{ {
......
<script> <script>
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { n__ } from '~/locale'; import { n__ } from '~/locale';
import { isNumber } from 'underscore'; import { isNumber } from 'lodash';
export default { export default {
components: { Icon }, components: { Icon },
......
<script> <script>
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import _ from 'underscore'; import { isArray } from 'lodash';
import imageDiffMixin from 'ee_else_ce/diffs/mixins/image_diff'; import imageDiffMixin from 'ee_else_ce/diffs/mixins/image_diff';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
return this.getCommentFormForDiffFile(this.fileHash); return this.getCommentFormForDiffFile(this.fileHash);
}, },
allDiscussions() { allDiscussions() {
return _.isArray(this.discussions) ? this.discussions : [this.discussions]; return isArray(this.discussions) ? this.discussions : [this.discussions];
}, },
}, },
methods: { methods: {
......
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
...@@ -24,8 +24,8 @@ export default { ...@@ -24,8 +24,8 @@ export default {
{ {
ref_start: '<span class="ref-name">', ref_start: '<span class="ref-name">',
ref_end: '</span>', ref_end: '</span>',
source_branch: _.escape(this.getNoteableData.source_branch), source_branch: esc(this.getNoteableData.source_branch),
target_branch: _.escape(this.getNoteableData.target_branch), target_branch: esc(this.getNoteableData.target_branch),
}, },
false, false,
); );
......
import _ from 'underscore'; import { property, isEqual } from 'lodash';
import { truncatePathMiddleToLength } from '~/lib/utils/text_utility'; import { truncatePathMiddleToLength } from '~/lib/utils/text_utility';
import { diffModes, diffViewerModes } from '~/ide/constants'; import { diffModes, diffViewerModes } from '~/ide/constants';
import { import {
...@@ -442,7 +442,7 @@ export function isDiscussionApplicableToLine({ discussion, diffPosition, latestD ...@@ -442,7 +442,7 @@ export function isDiscussionApplicableToLine({ discussion, diffPosition, latestD
const originalRefs = discussion.original_position; const originalRefs = discussion.original_position;
const refs = discussion.position; const refs = discussion.position;
return _.isEqual(refs, diffPositionCopy) || _.isEqual(originalRefs, diffPositionCopy); return isEqual(refs, diffPositionCopy) || isEqual(originalRefs, diffPositionCopy);
} }
// eslint-disable-next-line // eslint-disable-next-line
...@@ -578,10 +578,10 @@ export const convertExpandLines = ({ ...@@ -578,10 +578,10 @@ export const convertExpandLines = ({
for (let i = 0, diffLinesLength = diffLines.length; i < diffLinesLength; i += 1) { for (let i = 0, diffLinesLength = diffLines.length; i < diffLinesLength; i += 1) {
const line = diffLines[i]; const line = diffLines[i];
if (_.property(typeKey)(line) === 'match') { if (property(typeKey)(line) === 'match') {
const beforeLine = diffLines[i - 1]; const beforeLine = diffLines[i - 1];
const afterLine = diffLines[i + 1]; const afterLine = diffLines[i + 1];
const newLineProperty = _.property(newLineKey); const newLineProperty = property(newLineKey);
const beforeLineIndex = newLineProperty(beforeLine) || 0; const beforeLineIndex = newLineProperty(beforeLine) || 0;
const afterLineIndex = newLineProperty(afterLine) - 1 || dataLength; const afterLineIndex = newLineProperty(afterLine) - 1 || dataLength;
...@@ -589,7 +589,7 @@ export const convertExpandLines = ({ ...@@ -589,7 +589,7 @@ export const convertExpandLines = ({
...data.slice(beforeLineIndex, afterLineIndex).map((l, index) => ...data.slice(beforeLineIndex, afterLineIndex).map((l, index) =>
mapLine({ mapLine({
line: Object.assign(l, { hasForm: false, discussions: [] }), line: Object.assign(l, { hasForm: false, discussions: [] }),
oldLine: (_.property(oldLineKey)(beforeLine) || 0) + index + 1, oldLine: (property(oldLineKey)(beforeLine) || 0) + index + 1,
newLine: (newLineProperty(beforeLine) || 0) + index + 1, newLine: (newLineProperty(beforeLine) || 0) + index + 1,
}), }),
), ),
......
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