Commit a2412cd9 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'tr-underscore-to-lodash-monitoring' into 'master'

Replace underscore with lodash for ~/monitoring

Closes #196674

See merge request gitlab-org/gitlab!23574
parents 90baa159 61ce591b
<script> <script>
import { flatten, isNumber } from 'underscore'; import { flattenDeep, isNumber } from 'lodash';
import { GlChartSeriesLabel } from '@gitlab/ui/dist/charts'; import { GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
import { roundOffFloat } from '~/lib/utils/common_utils'; import { roundOffFloat } from '~/lib/utils/common_utils';
import { hexToRgb } from '~/lib/utils/color_utils'; import { hexToRgb } from '~/lib/utils/color_utils';
...@@ -77,7 +77,7 @@ export default { ...@@ -77,7 +77,7 @@ export default {
* This offset is the lowest value. * This offset is the lowest value.
*/ */
yOffset() { yOffset() {
const values = flatten(this.series.map(ser => ser.data.map(([, y]) => y))); const values = flattenDeep(this.series.map(ser => ser.data.map(([, y]) => y)));
const min = values.length ? Math.floor(Math.min(...values)) : 0; const min = values.length ? Math.floor(Math.min(...values)) : 0;
return min < 0 ? -min : 0; return min < 0 ? -min : 0;
}, },
......
<script> <script>
import _ from 'underscore'; import { omit } from 'lodash';
import { GlLink, GlButton, GlTooltip, GlResizeObserverDirective } from '@gitlab/ui'; import { GlLink, GlButton, GlTooltip, GlResizeObserverDirective } from '@gitlab/ui';
import { GlAreaChart, GlLineChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts'; import { GlAreaChart, GlLineChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
...@@ -140,7 +140,7 @@ export default { ...@@ -140,7 +140,7 @@ export default {
return (this.option.series || []).concat(this.scatterSeries ? [this.scatterSeries] : []); return (this.option.series || []).concat(this.scatterSeries ? [this.scatterSeries] : []);
}, },
chartOptions() { chartOptions() {
const option = _.omit(this.option, 'series'); const option = omit(this.option, 'series');
return { return {
series: this.chartOptionSeries, series: this.chartOptionSeries,
xAxis: { xAxis: {
......
<script> <script>
import _ from 'underscore'; import { debounce, pickBy } from 'lodash';
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import VueDraggable from 'vuedraggable'; import VueDraggable from 'vuedraggable';
import { import {
...@@ -294,7 +294,7 @@ export default { ...@@ -294,7 +294,7 @@ export default {
generateLink(group, title, yLabel) { generateLink(group, title, yLabel) {
const dashboard = this.currentDashboard || this.firstDashboard.path; const dashboard = this.currentDashboard || this.firstDashboard.path;
const params = _.pick({ dashboard, group, title, y_label: yLabel }, value => value != null); const params = pickBy({ dashboard, group, title, y_label: yLabel }, value => value != null);
return mergeUrlParams(params, window.location.href); return mergeUrlParams(params, window.location.href);
}, },
hideAddMetricModal() { hideAddMetricModal() {
...@@ -306,7 +306,7 @@ export default { ...@@ -306,7 +306,7 @@ export default {
setFormValidity(isValid) { setFormValidity(isValid) {
this.formIsValid = isValid; this.formIsValid = isValid;
}, },
debouncedEnvironmentsSearch: _.debounce(function environmentsSearchOnInput(searchTerm) { debouncedEnvironmentsSearch: debounce(function environmentsSearchOnInput(searchTerm) {
this.setEnvironmentsSearchTerm(searchTerm); this.setEnvironmentsSearchTerm(searchTerm);
}, 500), }, 500),
submitCustomMetricsForm() { submitCustomMetricsForm() {
......
<script> <script>
import _ from 'underscore'; import { uniqueId } from 'lodash';
import { GlFormGroup, GlFormInput } from '@gitlab/ui'; import { GlFormGroup, GlFormInput } from '@gitlab/ui';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { dateFormats } from './date_time_picker_lib'; import { dateFormats } from './date_time_picker_lib';
...@@ -35,7 +35,7 @@ export default { ...@@ -35,7 +35,7 @@ export default {
id: { id: {
type: String, type: String,
required: false, required: false,
default: () => _.uniqueId('dateTimePicker_'), default: () => uniqueId('dateTimePicker_'),
}, },
}, },
data() { data() {
......
<script> <script>
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import _ from 'underscore'; import { pickBy } from 'lodash';
import { import {
GlDropdown, GlDropdown,
GlDropdownItem, GlDropdownItem,
...@@ -90,7 +90,7 @@ export default { ...@@ -90,7 +90,7 @@ export default {
getGraphAlerts(queries) { getGraphAlerts(queries) {
if (!this.allAlerts) return {}; if (!this.allAlerts) return {};
const metricIdsForChart = queries.map(q => q.metricId); const metricIdsForChart = queries.map(q => q.metricId);
return _.pick(this.allAlerts, alert => metricIdsForChart.includes(alert.metricId)); return pickBy(this.allAlerts, alert => metricIdsForChart.includes(alert.metricId));
}, },
getGraphAlertValues(queries) { getGraphAlertValues(queries) {
return Object.values(this.getGraphAlerts(queries)); return Object.values(this.getGraphAlerts(queries));
......
import _ from 'underscore'; import { omit } from 'lodash';
export const uniqMetricsId = metric => `${metric.metric_id}_${metric.id}`; export const uniqMetricsId = metric => `${metric.metric_id}_${metric.id}`;
...@@ -11,7 +11,7 @@ export const uniqMetricsId = metric => `${metric.metric_id}_${metric.id}`; ...@@ -11,7 +11,7 @@ export const uniqMetricsId = metric => `${metric.metric_id}_${metric.id}`;
*/ */
export const normalizeMetric = (metric = {}) => export const normalizeMetric = (metric = {}) =>
_.omit( omit(
{ {
...metric, ...metric,
metric_id: uniqMetricsId(metric), metric_id: uniqMetricsId(metric),
......
<script> <script>
import _ from 'underscore'; import { isEmpty, findKey } from 'lodash';
import Vue from 'vue'; import Vue from 'vue';
import { import {
GlLink, GlLink,
...@@ -118,7 +118,7 @@ export default { ...@@ -118,7 +118,7 @@ export default {
); );
}, },
submitAction() { submitAction() {
if (_.isEmpty(this.selectedAlert)) return 'create'; if (isEmpty(this.selectedAlert)) return 'create';
if (this.haveValuesChanged) return 'update'; if (this.haveValuesChanged) return 'update';
return 'delete'; return 'delete';
}, },
...@@ -147,7 +147,7 @@ export default { ...@@ -147,7 +147,7 @@ export default {
}, },
methods: { methods: {
selectQuery(queryId) { selectQuery(queryId) {
const existingAlertPath = _.findKey(this.alertsToManage, alert => alert.metricId === queryId); const existingAlertPath = findKey(this.alertsToManage, alert => alert.metricId === queryId);
const existingAlert = this.alertsToManage[existingAlertPath]; const existingAlert = this.alertsToManage[existingAlertPath];
if (existingAlert) { if (existingAlert) {
......
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