Commit 057e8d5a authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'jivanvl-replace-underscore-lodash-mr-widget' into 'master'

Replace underscore for lodash in mr_widget

Closes #196680

See merge request gitlab-org/gitlab!26814
parents d86b10ce 14dd2e4b
<script> <script>
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { n__, s__, sprintf } from '~/locale'; import { n__, s__, sprintf } from '~/locale';
import { mergeUrlParams, webIDEUrl } from '~/lib/utils/url_utility'; import { mergeUrlParams, webIDEUrl } from '~/lib/utils/url_utility';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
...@@ -35,7 +35,7 @@ export default { ...@@ -35,7 +35,7 @@ export default {
'mrWidget|The source branch is %{commitsBehindLinkStart}%{commitsBehind}%{commitsBehindLinkEnd} the target branch', 'mrWidget|The source branch is %{commitsBehindLinkStart}%{commitsBehind}%{commitsBehindLinkEnd} the target branch',
), ),
{ {
commitsBehindLinkStart: `<a href="${_.escape(this.mr.targetBranchPath)}">`, commitsBehindLinkStart: `<a href="${esc(this.mr.targetBranchPath)}">`,
commitsBehind: n__('%d commit behind', '%d commits behind', this.mr.divergedCommitsCount), commitsBehind: n__('%d commit behind', '%d commits behind', this.mr.divergedCommitsCount),
commitsBehindLinkEnd: '</a>', commitsBehindLinkEnd: '</a>',
}, },
......
<script> <script>
import _ from 'underscore'; import { isNumber } from 'lodash';
import ArtifactsApp from './artifacts_list_app.vue'; import ArtifactsApp from './artifacts_list_app.vue';
import Deployment from './deployment/deployment.vue'; import Deployment from './deployment/deployment.vue';
import MrWidgetContainer from './mr_widget_container.vue'; import MrWidgetContainer from './mr_widget_container.vue';
...@@ -67,7 +67,7 @@ export default { ...@@ -67,7 +67,7 @@ export default {
return this.mr.visualReviewAppAvailable && this.glFeatures.anonymousVisualReviewFeedback; return this.mr.visualReviewAppAvailable && this.glFeatures.anonymousVisualReviewFeedback;
}, },
showMergeTrainPositionIndicator() { showMergeTrainPositionIndicator() {
return _.isNumber(this.mr.mergeTrainIndex); return isNumber(this.mr.mergeTrainIndex);
}, },
}, },
}; };
......
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { __, n__, sprintf, s__ } from '~/locale'; import { __, n__, sprintf, s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
...@@ -60,7 +60,7 @@ export default { ...@@ -60,7 +60,7 @@ export default {
{ {
commitCount: `<strong class="commits-count-message">${this.commitsCountMessage}</strong>`, commitCount: `<strong class="commits-count-message">${this.commitsCountMessage}</strong>`,
mergeCommitCount: `<strong>${s__('mrWidgetCommitsAdded|1 merge commit')}</strong>`, mergeCommitCount: `<strong>${s__('mrWidgetCommitsAdded|1 merge commit')}</strong>`,
targetBranch: `<span class="label-branch">${_.escape(this.targetBranch)}</span>`, targetBranch: `<span class="label-branch">${esc(this.targetBranch)}</span>`,
}, },
false, false,
); );
......
<script> <script>
import _ from 'underscore';
import autoMergeMixin from 'ee_else_ce/vue_merge_request_widget/mixins/auto_merge'; import autoMergeMixin from 'ee_else_ce/vue_merge_request_widget/mixins/auto_merge';
import Flash from '../../../flash'; import Flash from '../../../flash';
import statusIcon from '../mr_widget_status_icon.vue'; import statusIcon from '../mr_widget_status_icon.vue';
...@@ -72,7 +71,7 @@ export default { ...@@ -72,7 +71,7 @@ export default {
.merge(options) .merge(options)
.then(res => res.data) .then(res => res.data)
.then(data => { .then(data => {
if (_.includes(AUTO_MERGE_STRATEGIES, data.status)) { if (AUTO_MERGE_STRATEGIES.includes(data.status)) {
eventHub.$emit('MRWidgetUpdateRequested'); eventHub.$emit('MRWidgetUpdateRequested');
} }
}) })
......
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import { mouseenter, debouncedMouseleave, togglePopover } from '~/shared/popover'; import { mouseenter, debouncedMouseleave, togglePopover } from '~/shared/popover';
import StatusIcon from '../mr_widget_status_icon.vue'; import StatusIcon from '../mr_widget_status_icon.vue';
...@@ -50,7 +50,7 @@ export default { ...@@ -50,7 +50,7 @@ export default {
content: sprintf( content: sprintf(
s__('mrWidget|%{link_start}Learn more about resolving conflicts%{link_end}'), s__('mrWidget|%{link_start}Learn more about resolving conflicts%{link_end}'),
{ {
link_start: `<a href="${_.escape( link_start: `<a href="${esc(
this.mr.conflictsDocsPath, this.mr.conflictsDocsPath,
)}" target="_blank" rel="noopener noreferrer">`, )}" target="_blank" rel="noopener noreferrer">`,
link_end: '</a>', link_end: '</a>',
......
<script> <script>
import _ from 'underscore'; import { isEmpty } from 'lodash';
import { GlIcon, GlButton } from '@gitlab/ui'; import { GlIcon, GlButton } from '@gitlab/ui';
import successSvg from 'icons/_icon_status_success.svg'; import successSvg from 'icons/_icon_status_success.svg';
import warningSvg from 'icons/_icon_status_warning.svg'; import warningSvg from 'icons/_icon_status_warning.svg';
...@@ -51,7 +51,7 @@ export default { ...@@ -51,7 +51,7 @@ export default {
}, },
computed: { computed: {
isAutoMergeAvailable() { isAutoMergeAvailable() {
return !_.isEmpty(this.mr.availableAutoMergeStrategies); return !isEmpty(this.mr.availableAutoMergeStrategies);
}, },
status() { status() {
const { pipeline, isPipelineFailed, hasCI, ciStatus } = this.mr; const { pipeline, isPipelineFailed, hasCI, ciStatus } = this.mr;
...@@ -158,7 +158,7 @@ export default { ...@@ -158,7 +158,7 @@ export default {
.then(data => { .then(data => {
const hasError = data.status === 'failed' || data.status === 'hook_validation_error'; const hasError = data.status === 'failed' || data.status === 'hook_validation_error';
if (_.includes(AUTO_MERGE_STRATEGIES, data.status)) { if (AUTO_MERGE_STRATEGIES.includes(data.status)) {
eventHub.$emit('MRWidgetUpdateRequested'); eventHub.$emit('MRWidgetUpdateRequested');
} else if (data.status === 'success') { } else if (data.status === 'success') {
this.initiateMergePolling(); this.initiateMergePolling();
......
<script> <script>
import _ from 'underscore'; import { isEmpty } from 'lodash';
import MRWidgetStore from 'ee_else_ce/vue_merge_request_widget/stores/mr_widget_store'; import MRWidgetStore from 'ee_else_ce/vue_merge_request_widget/stores/mr_widget_store';
import MRWidgetService from 'ee_else_ce/vue_merge_request_widget/services/mr_widget_service'; import MRWidgetService from 'ee_else_ce/vue_merge_request_widget/services/mr_widget_service';
import stateMaps from 'ee_else_ce/vue_merge_request_widget/stores/state_maps'; import stateMaps from 'ee_else_ce/vue_merge_request_widget/stores/state_maps';
...@@ -118,7 +118,7 @@ export default { ...@@ -118,7 +118,7 @@ export default {
return this.mr.allowCollaboration && this.mr.isOpen; return this.mr.allowCollaboration && this.mr.isOpen;
}, },
shouldRenderMergedPipeline() { shouldRenderMergedPipeline() {
return this.mr.state === 'merged' && !_.isEmpty(this.mr.mergePipeline); return this.mr.state === 'merged' && !isEmpty(this.mr.mergePipeline);
}, },
showMergePipelineForkWarning() { showMergePipelineForkWarning() {
return Boolean( return Boolean(
......
import { format } from 'timeago.js'; import { format } from 'timeago.js';
import _ from 'underscore';
import getStateKey from 'ee_else_ce/vue_merge_request_widget/stores/get_state_key'; import getStateKey from 'ee_else_ce/vue_merge_request_widget/stores/get_state_key';
import { stateKey } from './state_maps'; import { stateKey } from './state_maps';
import { formatDate } from '../../lib/utils/datetime_utility'; import { formatDate } from '../../lib/utils/datetime_utility';
...@@ -228,11 +227,13 @@ export default class MergeRequestStore { ...@@ -228,11 +227,13 @@ export default class MergeRequestStore {
} }
static getPreferredAutoMergeStrategy(availableAutoMergeStrategies) { static getPreferredAutoMergeStrategy(availableAutoMergeStrategies) {
if (_.includes(availableAutoMergeStrategies, MTWPS_MERGE_STRATEGY)) { if (availableAutoMergeStrategies === undefined) return undefined;
if (availableAutoMergeStrategies.includes(MTWPS_MERGE_STRATEGY)) {
return MTWPS_MERGE_STRATEGY; return MTWPS_MERGE_STRATEGY;
} else if (_.includes(availableAutoMergeStrategies, MT_MERGE_STRATEGY)) { } else if (availableAutoMergeStrategies.includes(MT_MERGE_STRATEGY)) {
return MT_MERGE_STRATEGY; return MT_MERGE_STRATEGY;
} else if (_.includes(availableAutoMergeStrategies, MWPS_MERGE_STRATEGY)) { } else if (availableAutoMergeStrategies.includes(MWPS_MERGE_STRATEGY)) {
return MWPS_MERGE_STRATEGY; return MWPS_MERGE_STRATEGY;
} }
......
<script> <script>
import _ from 'underscore'; import { uniqueId } from 'lodash';
import ApprovalCheckRulePopover from 'ee/approvals/components/approval_check_rule_popover.vue'; import ApprovalCheckRulePopover from 'ee/approvals/components/approval_check_rule_popover.vue';
import EmptyRuleName from 'ee/approvals/components/empty_rule_name.vue'; import EmptyRuleName from 'ee/approvals/components/empty_rule_name.vue';
import { RULE_TYPE_CODE_OWNER, RULE_TYPE_ANY_APPROVER } from 'ee/approvals/constants'; import { RULE_TYPE_CODE_OWNER, RULE_TYPE_ANY_APPROVER } from 'ee/approvals/constants';
...@@ -34,12 +34,12 @@ export default { ...@@ -34,12 +34,12 @@ export default {
sections() { sections() {
return [ return [
{ {
id: _.uniqueId(), id: uniqueId(),
title: '', title: '',
rules: this.approvalRules.filter(rule => rule.rule_type !== RULE_TYPE_CODE_OWNER), rules: this.approvalRules.filter(rule => rule.rule_type !== RULE_TYPE_CODE_OWNER),
}, },
{ {
id: _.uniqueId(), id: uniqueId(),
title: __('Code Owners'), title: __('Code Owners'),
rules: this.approvalRules rules: this.approvalRules
.filter(rule => rule.rule_type === RULE_TYPE_CODE_OWNER) .filter(rule => rule.rule_type === RULE_TYPE_CODE_OWNER)
......
<script> <script>
import { GlModal, GlButton } from '@gitlab/ui'; import { GlModal, GlButton } from '@gitlab/ui';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
export default { export default {
...@@ -22,7 +22,7 @@ export default { ...@@ -22,7 +22,7 @@ export default {
"Merging immediately isn't recommended as it may negatively impact the existing merge train. Read the %{docsLinkStart}documentation%{docsLinkEnd} for more information.", "Merging immediately isn't recommended as it may negatively impact the existing merge train. Read the %{docsLinkStart}documentation%{docsLinkEnd} for more information.",
), ),
{ {
docsLinkStart: `<a href="${_.escape( docsLinkStart: `<a href="${esc(
this.docsUrl, this.docsUrl,
)}" target="_blank" rel="noopener noreferrer">`, )}" target="_blank" rel="noopener noreferrer">`,
docsLinkEnd: '</a>', docsLinkEnd: '</a>',
......
<script> <script>
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
...@@ -37,7 +37,7 @@ export default { ...@@ -37,7 +37,7 @@ export default {
'mrWidget|This merge request will be added to the merge train when pipeline %{linkStart}#%{pipelineId}%{linkEnd} succeeds.', 'mrWidget|This merge request will be added to the merge train when pipeline %{linkStart}#%{pipelineId}%{linkEnd} succeeds.',
); );
const sanitizedPipelineLink = _.escape(this.pipelineLink); const sanitizedPipelineLink = esc(this.pipelineLink);
return sprintf( return sprintf(
text, text,
......
import _ from 'underscore'; import { groupBy } from 'lodash';
import { import {
RULE_TYPE_REGULAR, RULE_TYPE_REGULAR,
RULE_TYPE_FALLBACK, RULE_TYPE_FALLBACK,
...@@ -31,7 +31,7 @@ function getApprovalRuleNamesLeft(data) { ...@@ -31,7 +31,7 @@ function getApprovalRuleNamesLeft(data) {
return []; return [];
} }
const rulesLeft = _.groupBy(data.approval_rules_left, x => x.rule_type); const rulesLeft = groupBy(data.approval_rules_left, x => x.rule_type);
// Filter out empty names (fallback rule has no name) because the empties would look weird. // Filter out empty names (fallback rule has no name) because the empties would look weird.
const regularRules = (rulesLeft[RULE_TYPE_REGULAR] || []).map(x => x.name).filter(x => x); const regularRules = (rulesLeft[RULE_TYPE_REGULAR] || []).map(x => x.name).filter(x => x);
......
<script> <script>
import _ from 'underscore'; import { isNumber, isString } from 'lodash';
import GroupedSecurityReportsApp from 'ee/vue_shared/security_reports/grouped_security_reports_app.vue'; import GroupedSecurityReportsApp from 'ee/vue_shared/security_reports/grouped_security_reports_app.vue';
import GroupedMetricsReportsApp from 'ee/vue_shared/metrics_reports/grouped_metrics_reports_app.vue'; import GroupedMetricsReportsApp from 'ee/vue_shared/metrics_reports/grouped_metrics_reports_app.vue';
import reportsMixin from 'ee/vue_shared/security_reports/mixins/reports_mixin'; import reportsMixin from 'ee/vue_shared/security_reports/mixins/reports_mixin';
...@@ -154,8 +154,8 @@ export default { ...@@ -154,8 +154,8 @@ export default {
shouldRenderMergeTrainHelperText() { shouldRenderMergeTrainHelperText() {
return ( return (
this.mr.pipeline && this.mr.pipeline &&
_.isNumber(this.mr.pipeline.id) && isNumber(this.mr.pipeline.id) &&
_.isString(this.mr.pipeline.path) && isString(this.mr.pipeline.path) &&
this.mr.preferredAutoMergeStrategy === MTWPS_MERGE_STRATEGY && this.mr.preferredAutoMergeStrategy === MTWPS_MERGE_STRATEGY &&
!this.mr.autoMergeEnabled !this.mr.autoMergeEnabled
); );
......
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