Commit 9d0e91a0 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '42639-move-javascripts-prometheus_metrics' into 'master'

Move custom metrics partial and prometheus_metrics js files into Core

See merge request gitlab-org/gitlab!28919
parents 34b027d5 1009bc5b
...@@ -409,7 +409,6 @@ linters: ...@@ -409,7 +409,6 @@ linters:
- 'ee/app/views/projects/push_rules/_index.html.haml' - 'ee/app/views/projects/push_rules/_index.html.haml'
- 'ee/app/views/projects/services/gitlab_slack_application/_help.html.haml' - 'ee/app/views/projects/services/gitlab_slack_application/_help.html.haml'
- 'ee/app/views/projects/services/gitlab_slack_application/_slack_integration_form.html.haml' - 'ee/app/views/projects/services/gitlab_slack_application/_slack_integration_form.html.haml'
- 'ee/app/views/projects/services/prometheus/_metrics.html.haml'
- 'ee/app/views/projects/settings/slacks/edit.html.haml' - 'ee/app/views/projects/settings/slacks/edit.html.haml'
- 'ee/app/views/shared/_additional_email_text.html.haml' - 'ee/app/views/shared/_additional_email_text.html.haml'
- 'ee/app/views/shared/_mirror_update_button.html.haml' - 'ee/app/views/shared/_mirror_update_button.html.haml'
......
import IntegrationSettingsForm from '~/integrations/integration_settings_form'; import IntegrationSettingsForm from '~/integrations/integration_settings_form';
import PrometheusMetrics from 'ee_else_ce/prometheus_metrics/prometheus_metrics'; import PrometheusMetrics from '~/prometheus_metrics/custom_metrics';
import PrometheusAlerts from '~/prometheus_alerts'; import PrometheusAlerts from '~/prometheus_alerts';
import initAlertsSettings from '~/alerts_service_settings'; import initAlertsSettings from '~/alerts_service_settings';
......
...@@ -2,4 +2,5 @@ export default { ...@@ -2,4 +2,5 @@ export default {
EMPTY: 'empty', EMPTY: 'empty',
LOADING: 'loading', LOADING: 'loading',
LIST: 'list', LIST: 'list',
NO_INTEGRATION: 'no-integration',
}; };
import $ from 'jquery'; import $ from 'jquery';
import { escape, sortBy } from 'lodash'; import { escape, sortBy } from 'lodash';
import PrometheusMetrics from '~/prometheus_metrics/prometheus_metrics'; import PrometheusMetrics from './prometheus_metrics';
import PANEL_STATE from './constants'; import PANEL_STATE from './constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
export default class EEPrometheusMetrics extends PrometheusMetrics { export default class CustomMetrics extends PrometheusMetrics {
constructor(wrapperSelector) { constructor(wrapperSelector) {
super(wrapperSelector); super(wrapperSelector);
this.customMetrics = []; this.customMetrics = [];
...@@ -106,7 +106,7 @@ export default class EEPrometheusMetrics extends PrometheusMetrics { ...@@ -106,7 +106,7 @@ export default class EEPrometheusMetrics extends PrometheusMetrics {
const sortedMetrics = sortBy(this.customMetrics.map(capitalizeGroup), ['group', 'title']); const sortedMetrics = sortBy(this.customMetrics.map(capitalizeGroup), ['group', 'title']);
sortedMetrics.forEach(metric => { sortedMetrics.forEach(metric => {
this.$monitoredCustomMetricsList.append(EEPrometheusMetrics.customMetricTemplate(metric)); this.$monitoredCustomMetricsList.append(CustomMetrics.customMetricTemplate(metric));
}); });
this.$monitoredCustomMetricsCount.text(this.customMetrics.length); this.$monitoredCustomMetricsCount.text(this.customMetrics.length);
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
.card-header .card-header
%strong %strong
= s_('PrometheusService|Custom metrics') = s_('PrometheusService|Custom metrics')
-# haml-lint:disable NoPlainNodes
%span.badge.badge-pill.js-custom-monitored-count 0 %span.badge.badge-pill.js-custom-monitored-count 0
-# haml-lint:enable NoPlainNodes
= link_to s_('PrometheusService|New metric'), new_project_prometheus_metric_path(project), class: 'btn btn-success js-new-metric-button hidden' = link_to s_('PrometheusService|New metric'), new_project_prometheus_metric_path(project), class: 'btn btn-success js-new-metric-button hidden'
.card-body .card-body
.flash-container.hidden .flash-container.hidden
...@@ -26,5 +28,3 @@ ...@@ -26,5 +28,3 @@
%p.text-tertiary.m-3.js-new-metric-text.hidden %p.text-tertiary.m-3.js-new-metric-text.hidden
= s_('PrometheusService|No custom metrics have been created. Create one using the button above') = s_('PrometheusService|No custom metrics have been created. Create one using the button above')
%ul.list-unstyled.metrics-list.hidden.js-custom-metrics-list %ul.list-unstyled.metrics-list.hidden.js-custom-metrics-list
= render_ce 'projects/services/prometheus/metrics', project: project
- project = local_assigns.fetch(:project) - project = local_assigns.fetch(:project)
= render 'projects/services/prometheus/custom_metrics', project: project
.col-lg-3 .col-lg-3
%p %p
= s_('PrometheusService|Common metrics are automatically monitored based on a library of metrics from popular exporters.') = s_('PrometheusService|Common metrics are automatically monitored based on a library of metrics from popular exporters.')
......
import PANEL_STATE from '~/prometheus_metrics/constants';
const PANEL_STATE_EE = {
NO_INTEGRATION: 'no-integration',
};
export default Object.assign({}, PANEL_STATE, PANEL_STATE_EE);
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import PrometheusMetrics from 'ee/prometheus_metrics/prometheus_metrics'; import PrometheusMetrics from '~/prometheus_metrics/custom_metrics';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import PANEL_STATE from '~/prometheus_metrics/constants'; import PANEL_STATE from '~/prometheus_metrics/constants';
import metrics from './mock_data'; import metrics from './mock_data';
describe('PrometheusMetrics EE', () => { describe('PrometheusMetrics', () => {
const FIXTURE = 'services/prometheus/prometheus_service.html'; const FIXTURE = 'services/prometheus/prometheus_service.html';
const customMetricsEndpoint = const customMetricsEndpoint =
'http://test.host/frontend-fixtures/services-project/prometheus/metrics'; 'http://test.host/frontend-fixtures/services-project/prometheus/metrics';
...@@ -23,7 +23,7 @@ describe('PrometheusMetrics EE', () => { ...@@ -23,7 +23,7 @@ describe('PrometheusMetrics EE', () => {
mock.restore(); mock.restore();
}); });
describe('Custom Metrics EE', () => { describe('Custom Metrics', () => {
let prometheusMetrics; let prometheusMetrics;
beforeEach(() => { beforeEach(() => {
......
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