Commit 41e291de authored by Jose Vargas's avatar Jose Vargas

Replace underscore/lodash in ee/analytics

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