summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-20 21:06:18 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-20 21:06:18 +0000
commit12577c6e3988054d510529d8de4ec99d1cdbfc85 (patch)
treebcc2f3881365f43116a79dc22ddff66134b43518 /app
parent4c6c0280a6111a2d9d5364a9d5a513e7fc538dd7 (diff)
downloadgitlab-ce-12577c6e3988054d510529d8de4ec99d1cdbfc85.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/monitoring/stores/mutations.js15
-rw-r--r--app/assets/javascripts/monitoring/stores/utils.js19
2 files changed, 31 insertions, 3 deletions
diff --git a/app/assets/javascripts/monitoring/stores/mutations.js b/app/assets/javascripts/monitoring/stores/mutations.js
index b19520d6638..b1080b23815 100644
--- a/app/assets/javascripts/monitoring/stores/mutations.js
+++ b/app/assets/javascripts/monitoring/stores/mutations.js
@@ -1,6 +1,8 @@
import Vue from 'vue';
import * as types from './mutation_types';
-import { normalizeMetrics, sortMetrics, normalizeQueryResult } from './utils';
+import { normalizeMetrics, sortMetrics, normalizeMetric, normalizeQueryResult } from './utils';
+
+const normalizePanel = panel => panel.metrics.map(normalizeMetric);
export default {
[types.REQUEST_METRICS_DATA](state) {
@@ -9,13 +11,19 @@ export default {
},
[types.RECEIVE_METRICS_DATA_SUCCESS](state, groupData) {
state.groups = groupData.map(group => {
- let { metrics } = group;
+ let { metrics = [], panels = [] } = group;
+
+ // each panel has metric information that needs to be normalized
+ panels = panels.map(panel => ({
+ ...panel,
+ metrics: normalizePanel(panel),
+ }));
// for backwards compatibility, and to limit Vue template changes:
// for each group alias panels to metrics
// for each panel alias metrics to queries
if (state.useDashboardEndpoint) {
- metrics = group.panels.map(panel => ({
+ metrics = panels.map(panel => ({
...panel,
queries: panel.metrics,
}));
@@ -23,6 +31,7 @@ export default {
return {
...group,
+ panels,
metrics: normalizeMetrics(sortMetrics(metrics)),
};
});
diff --git a/app/assets/javascripts/monitoring/stores/utils.js b/app/assets/javascripts/monitoring/stores/utils.js
index 938ee2f0a9a..a19829f0c65 100644
--- a/app/assets/javascripts/monitoring/stores/utils.js
+++ b/app/assets/javascripts/monitoring/stores/utils.js
@@ -63,6 +63,25 @@ export function groupQueriesByChartInfo(metrics) {
return Object.values(metricsByChart);
}
+export const uniqMetricsId = metric => `${metric.metric_id}_${metric.id}`;
+
+/**
+ * Not to confuse with normalizeMetrics (plural)
+ * Metrics loaded from project-defined dashboards do not have a metric_id.
+ * This method creates a unique ID combining metric_id and id, if either is present.
+ * This is hopefully a temporary solution until BE processes metrics before passing to fE
+ * @param {Object} metric - metric
+ * @returns {Object} - normalized metric with a uniqueID
+ */
+export const normalizeMetric = (metric = {}) =>
+ _.omit(
+ {
+ ...metric,
+ metric_id: uniqMetricsId(metric),
+ },
+ 'id',
+ );
+
export const sortMetrics = metrics =>
_.chain(metrics)
.sortBy('title')