Commit 81a1850d authored by Mike Greiling's avatar Mike Greiling

Merge branch '213473-move-custom-metric-alerts' into 'master'

Move monitoring dashboard vue files to Core

See merge request gitlab-org/gitlab!29789
parents 84031c99 abcea55b
...@@ -14,7 +14,7 @@ import { ...@@ -14,7 +14,7 @@ import {
GlModalDirective, GlModalDirective,
GlTooltipDirective, GlTooltipDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import PanelType from 'ee_else_ce/monitoring/components/panel_type.vue'; import PanelType from './panel_type_with_alerts.vue';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import createFlash from '~/flash'; import createFlash from '~/flash';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
......
<script> <script>
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import PanelType from 'ee_else_ce/monitoring/components/panel_type.vue'; import PanelType from '~/monitoring/components/panel_type_with_alerts.vue';
import { convertToFixedRange } from '~/lib/utils/datetime_range'; import { convertToFixedRange } from '~/lib/utils/datetime_range';
import { defaultTimeRange } from '~/vue_shared/constants'; import { defaultTimeRange } from '~/vue_shared/constants';
import { timeRangeFromUrl, removeTimeRangeParams } from '../../utils'; import { timeRangeFromUrl, removeTimeRangeParams } from '../../utils';
......
...@@ -143,3 +143,9 @@ export const annotationsSymbolIcon = 'path://m5 229 5 8h-10z'; ...@@ -143,3 +143,9 @@ export const annotationsSymbolIcon = 'path://m5 229 5 8h-10z';
* https://gitlab.com/gitlab-org/gitlab/-/issues/214671 * https://gitlab.com/gitlab-org/gitlab/-/issues/214671
*/ */
export const DEFAULT_DASHBOARD_PATH = 'config/prometheus/common_metrics.yml'; export const DEFAULT_DASHBOARD_PATH = 'config/prometheus/common_metrics.yml';
export const OPERATORS = {
greaterThan: '>',
equalTo: '==',
lessThan: '<',
};
import Vue from 'vue'; import Vue from 'vue';
import { GlToast } from '@gitlab/ui'; import { GlToast } from '@gitlab/ui';
import Dashboard from 'ee_else_ce/monitoring/components/dashboard.vue'; import Dashboard from '~/monitoring/components/dashboard_with_alerts.vue';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import { getParameterValues } from '~/lib/utils/url_utility'; import { getParameterValues } from '~/lib/utils/url_utility';
import store from './stores'; import store from './stores';
......
import monitoringBundle from 'ee_else_ce/monitoring/monitoring_bundle'; import monitoringBundle from '~/monitoring/monitoring_bundle_with_alerts';
document.addEventListener('DOMContentLoaded', monitoringBundle); document.addEventListener('DOMContentLoaded', monitoringBundle);
...@@ -46,7 +46,9 @@ module EnvironmentsHelper ...@@ -46,7 +46,9 @@ module EnvironmentsHelper
"environment-state" => "#{environment.state}", "environment-state" => "#{environment.state}",
"custom-metrics-path" => project_prometheus_metrics_path(project), "custom-metrics-path" => project_prometheus_metrics_path(project),
"validate-query-path" => validate_query_project_prometheus_metrics_path(project), "validate-query-path" => validate_query_project_prometheus_metrics_path(project),
"custom-metrics-available" => "#{custom_metrics_available?(project)}" "custom-metrics-available" => "#{custom_metrics_available?(project)}",
"alerts-endpoint" => project_prometheus_alerts_path(project, environment_id: environment.id, format: :json),
"prometheus-alerts-available" => "#{can?(current_user, :read_prometheus_alerts, project)}"
} }
end end
......
---
title: Make setting alerts on the monitoring dashboard available to GitLab Core users
merge_request: 29789
author:
type: changed
// eslint-disable-next-line import/prefer-default-export
export const OPERATORS = {
greaterThan: '>',
equalTo: '==',
lessThan: '<',
};
...@@ -27,10 +27,7 @@ module EE ...@@ -27,10 +27,7 @@ module EE
end end
def metrics_data(project, environment) def metrics_data(project, environment)
ee_metrics_data = { ee_metrics_data = {}
"alerts-endpoint" => project_prometheus_alerts_path(project, environment_id: environment.id, format: :json),
"prometheus-alerts-available" => "#{can?(current_user, :read_prometheus_alerts, project)}"
}
ee_metrics_data["logs_path"] = project_logs_path(project, environment_name: environment.name) if can?(current_user, :read_pod_logs, project) ee_metrics_data["logs_path"] = project_logs_path(project, environment_name: environment.name) if can?(current_user, :read_pod_logs, project)
super.merge(ee_metrics_data) super.merge(ee_metrics_data)
......
...@@ -26,8 +26,6 @@ describe EnvironmentsHelper do ...@@ -26,8 +26,6 @@ describe EnvironmentsHelper do
it 'returns additional configuration' do it 'returns additional configuration' do
expect(subject).to include( expect(subject).to include(
'alerts-endpoint' => project_prometheus_alerts_path(project, environment_id: environment.id, format: :json),
'prometheus-alerts-available' => 'true',
'logs_path' => project_logs_path(project, environment_name: environment.name) 'logs_path' => project_logs_path(project, environment_name: environment.name)
) )
end end
......
...@@ -12,7 +12,7 @@ module QA ...@@ -12,7 +12,7 @@ module QA
def self.prepended(page) def self.prepended(page)
page.module_eval do page.module_eval do
view 'ee/app/assets/javascripts/monitoring/components/alert_widget_form.vue' do view 'app/assets/javascripts/monitoring/components/alert_widget_form.vue' do
element :alert_query_dropdown element :alert_query_dropdown
element :alert_query_option element :alert_query_option
element :alert_threshold_field element :alert_threshold_field
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLoadingIcon, GlTooltip, GlSprintf, GlBadge } from '@gitlab/ui'; import { GlLoadingIcon, GlTooltip, GlSprintf, GlBadge } from '@gitlab/ui';
import AlertWidget from 'ee/monitoring/components/alert_widget.vue'; import AlertWidget from '~/monitoring/components/alert_widget.vue';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import createFlash from '~/flash'; import createFlash from '~/flash';
...@@ -11,7 +11,7 @@ const mockDeleteAlert = jest.fn(); ...@@ -11,7 +11,7 @@ const mockDeleteAlert = jest.fn();
jest.mock('~/flash'); jest.mock('~/flash');
jest.mock( jest.mock(
'ee/monitoring/services/alerts_service', '~/monitoring/services/alerts_service',
() => () =>
function AlertsServiceMock() { function AlertsServiceMock() {
return { return {
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import AlertWidgetForm from 'ee/monitoring/components/alert_widget_form.vue'; import AlertWidgetForm from '~/monitoring/components/alert_widget_form.vue';
import ModalStub from '../stubs/modal_stub'; import ModalStub from '../stubs/modal_stub';
describe('AlertWidgetForm', () => { describe('AlertWidgetForm', () => {
......
...@@ -6,13 +6,13 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -6,13 +6,13 @@ import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import statusCodes from '~/lib/utils/http_status'; import statusCodes from '~/lib/utils/http_status';
import { metricStates } from '~/monitoring/constants'; import { metricStates } from '~/monitoring/constants';
import Dashboard from '~/monitoring/components/dashboard.vue'; import Dashboard from '~/monitoring/components/dashboard_with_alerts.vue';
import DateTimePicker from '~/vue_shared/components/date_time_picker/date_time_picker.vue'; import DateTimePicker from '~/vue_shared/components/date_time_picker/date_time_picker.vue';
import CustomMetricsFormFields from '~/custom_metrics/components/custom_metrics_form_fields.vue'; import CustomMetricsFormFields from '~/custom_metrics/components/custom_metrics_form_fields.vue';
import DashboardsDropdown from '~/monitoring/components/dashboards_dropdown.vue'; import DashboardsDropdown from '~/monitoring/components/dashboards_dropdown.vue';
import GroupEmptyState from '~/monitoring/components/group_empty_state.vue'; import GroupEmptyState from '~/monitoring/components/group_empty_state.vue';
import PanelType from 'ee_else_ce/monitoring/components/panel_type.vue'; import PanelType from '~/monitoring/components/panel_type_with_alerts.vue';
import { createStore } from '~/monitoring/stores'; import { createStore } from '~/monitoring/stores';
import * as types from '~/monitoring/stores/mutation_types'; import * as types from '~/monitoring/stores/mutation_types';
import { setupStoreWithDashboard, setMetricResult, setupStoreWithData } from '../store_utils'; import { setupStoreWithDashboard, setMetricResult, setupStoreWithData } from '../store_utils';
......
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import PanelType from 'ee_else_ce/monitoring/components/panel_type.vue'; import PanelType from '~/monitoring/components/panel_type_with_alerts.vue';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import MetricEmbed from '~/monitoring/components/embeds/metric_embed.vue'; import MetricEmbed from '~/monitoring/components/embeds/metric_embed.vue';
import { groups, initialState, metricsData, metricsWithData } from './mock_data'; import { groups, initialState, metricsData, metricsWithData } from './mock_data';
......
...@@ -2,8 +2,8 @@ import Vuex from 'vuex'; ...@@ -2,8 +2,8 @@ import Vuex from 'vuex';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlDropdownItem } from '@gitlab/ui'; import { GlDropdownItem } from '@gitlab/ui';
import { monitoringDashboard } from '~/monitoring/stores'; import { monitoringDashboard } from '~/monitoring/stores';
import PanelType from 'ee/monitoring/components/panel_type.vue'; import PanelType from '~/monitoring/components/panel_type_with_alerts.vue';
import AlertWidget from 'ee/monitoring/components/alert_widget.vue'; import AlertWidget from '~/monitoring/components/alert_widget.vue';
import { graphData } from 'jest/monitoring/fixture_data'; import { graphData } from 'jest/monitoring/fixture_data';
global.URL.createObjectURL = jest.fn(); global.URL.createObjectURL = jest.fn();
......
import { alertsValidator, queriesValidator } from 'ee/monitoring/validators'; import { alertsValidator, queriesValidator } from '~/monitoring/validators';
describe('alertsValidator', () => { describe('alertsValidator', () => {
const validAlert = { const validAlert = {
......
...@@ -37,10 +37,26 @@ describe EnvironmentsHelper do ...@@ -37,10 +37,26 @@ describe EnvironmentsHelper do
'environment-state' => environment.state, 'environment-state' => environment.state,
'custom-metrics-path' => project_prometheus_metrics_path(project), 'custom-metrics-path' => project_prometheus_metrics_path(project),
'validate-query-path' => validate_query_project_prometheus_metrics_path(project), 'validate-query-path' => validate_query_project_prometheus_metrics_path(project),
'custom-metrics-available' => 'true' 'custom-metrics-available' => 'true',
'alerts-endpoint' => project_prometheus_alerts_path(project, environment_id: environment.id, format: :json),
'prometheus-alerts-available' => 'true'
) )
end end
context 'without read_prometheus_alerts permission' do
before do
allow(helper).to receive(:can?)
.with(user, :read_prometheus_alerts, project)
.and_return(false)
end
it 'returns false' do
expect(metrics_data).to include(
'prometheus-alerts-available' => 'false'
)
end
end
context 'with metrics_setting' do context 'with metrics_setting' do
before do before do
create(:project_metrics_setting, project: project, external_dashboard_url: 'http://gitlab.com') create(:project_metrics_setting, project: project, external_dashboard_url: 'http://gitlab.com')
......
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