Commit 58f6d52e authored by Martin Wortschack's avatar Martin Wortschack

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

Replace underscore/lodash in ee/analytics

Closes #210254

See merge request gitlab-org/gitlab!27146
parents 6f09f635 41e291de
<script> <script>
import { escape } from 'underscore'; import { escape as esc } from 'lodash';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { __, sprintf, n__ } from '~/locale'; import { __, sprintf, n__ } from '~/locale';
import { getTimeago } from '~/lib/utils/datetime_utility'; import { getTimeago } from '~/lib/utils/datetime_utility';
...@@ -25,7 +25,7 @@ export default { ...@@ -25,7 +25,7 @@ export default {
methods: { methods: {
getTimeAgoString(createdAt) { getTimeAgoString(createdAt) {
return sprintf(__('opened %{timeAgo}'), { return sprintf(__('opened %{timeAgo}'), {
timeAgo: escape(getTimeago().format(createdAt)), timeAgo: esc(getTimeago().format(createdAt)),
}); });
}, },
showReviewTime(value) { showReviewTime(value) {
......
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { isEqual } from 'underscore'; import { isEqual } from 'lodash';
import { import {
GlFormGroup, GlFormGroup,
GlFormInput, GlFormInput,
......
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale'; import { sprintf, s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
...@@ -74,7 +74,7 @@ export default { ...@@ -74,7 +74,7 @@ export default {
return ` return `
<li> <li>
<a href='#' class='dropdown-menu-link is-active'> <a href='#' class='dropdown-menu-link is-active'>
${_.escape(stage.title)} ${esc(stage.title)}
</a> </a>
</li> </li>
`; `;
......
import { isNumber } from 'underscore'; import { isNumber } from 'lodash';
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { convertToSnakeCase } from '~/lib/utils/text_utility'; import { convertToSnakeCase } from '~/lib/utils/text_utility';
......
<script> <script>
import _ from 'underscore'; import { isEmpty } from 'lodash';
import { GlDropdown, GlDropdownItem, GlLoadingIcon } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlLoadingIcon } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
...@@ -53,7 +53,7 @@ export default { ...@@ -53,7 +53,7 @@ export default {
return foundMetric ? foundMetric.label : s__('MetricChart|Please select a metric'); return foundMetric ? foundMetric.label : s__('MetricChart|Please select a metric');
}, },
hasChartData() { hasChartData() {
return !_.isEmpty(this.chartData); return !isEmpty(this.chartData);
}, },
}, },
methods: { methods: {
......
import _ from 'underscore'; import { isEmpty } from 'lodash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import httpStatus from '~/lib/utils/http_status'; import httpStatus from '~/lib/utils/http_status';
import { import {
...@@ -52,7 +52,7 @@ export const getColumnChartData = state => chartKey => { ...@@ -52,7 +52,7 @@ export const getColumnChartData = state => chartKey => {
return dataWithSelected; return dataWithSelected;
}; };
export const chartHasData = state => chartKey => !_.isEmpty(state.charts[chartKey].data); export const chartHasData = state => chartKey => !isEmpty(state.charts[chartKey].data);
export const getScatterPlotMainData = (state, getters, rootState) => export const getScatterPlotMainData = (state, getters, rootState) =>
getScatterPlotData( getScatterPlotData(
......
import _ from 'underscore'; import { flatten } from 'lodash';
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
import { getDayDifference, getDateInPast } from '~/lib/utils/datetime_utility'; import { getDayDifference, getDateInPast } from '~/lib/utils/datetime_utility';
import { median } from '~/lib/utils/number_utils'; import { median } from '~/lib/utils/number_utils';
...@@ -134,7 +134,7 @@ export const getScatterPlotData = (data, startDate, endDate) => { ...@@ -134,7 +134,7 @@ export const getScatterPlotData = (data, startDate, endDate) => {
const visibleData = data.slice(startIndex); const visibleData = data.slice(startIndex);
// group by date // group by date
const result = _.flatten(visibleData).map(item => [ const result = flatten(visibleData).map(item => [
dateFormat(item.merged_at, dateFormats.isoDate), dateFormat(item.merged_at, dateFormats.isoDate),
item.metric, item.metric,
item.merged_at, item.merged_at,
...@@ -175,7 +175,7 @@ export const getMedianLineData = (data, startDate, endDate, daysOffset) => { ...@@ -175,7 +175,7 @@ export const getMedianLineData = (data, startDate, endDate, daysOffset) => {
startIndex = i - daysOffset - 1; startIndex = i - daysOffset - 1;
if (transformedData[startIndex] && transformedData[i - 1]) { if (transformedData[startIndex] && transformedData[i - 1]) {
medianData = transformedData.slice(startIndex, i); medianData = transformedData.slice(startIndex, i);
flattenedData = _.flatten(medianData); flattenedData = flatten(medianData);
if (flattenedData.length) { if (flattenedData.length) {
d = getDateInPast(endDate, len - i).toISOString(); d = getDateInPast(endDate, len - i).toISOString();
result.push([dateFormat(d, dateFormats.isoDate), median(flattenedData)]); result.push([dateFormat(d, dateFormats.isoDate), median(flattenedData)]);
......
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { GlLoadingIcon, GlButton, GlAvatar } from '@gitlab/ui'; import { GlLoadingIcon, GlButton, GlAvatar } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
...@@ -99,7 +99,7 @@ export default { ...@@ -99,7 +99,7 @@ export default {
const lastPart = parts.length - 1; const lastPart = parts.length - 1;
return parts return parts
.map((part, idx) => .map((part, idx) =>
idx === lastPart ? `<strong>${_.escape(part.trim())}</strong>` : _.escape(part.trim()), idx === lastPart ? `<strong>${esc(part.trim())}</strong>` : esc(part.trim()),
) )
.join(' / '); .join(' / ');
}, },
......
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { GlLoadingIcon, GlButton, GlAvatar } from '@gitlab/ui'; import { GlLoadingIcon, GlButton, GlAvatar } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { n__, s__, __ } from '~/locale'; import { n__, s__, __ } from '~/locale';
...@@ -120,7 +120,7 @@ export default { ...@@ -120,7 +120,7 @@ export default {
<li> <li>
<a href='#' class='dropdown-menu-link ${isActiveClass}'> <a href='#' class='dropdown-menu-link ${isActiveClass}'>
${this.avatarTemplate(project)} ${this.avatarTemplate(project)}
<div class="align-middle">${_.escape(project.name)}</div> <div class="align-middle">${esc(project.name)}</div>
</a> </a>
</li> </li>
`; `;
......
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