Commit 79d601d4 authored by Robert Hunt's avatar Robert Hunt

Merge branch 'tnir/cleanup-old-environment-metrics-with-mr38364' into 'master'

Remove environment_metrics from helpers to avoid extra redirection

See merge request gitlab-org/gitlab!84351
parents 15e1fb16 a930ae63
......@@ -45,7 +45,7 @@ export const removeLeadingSlash = (str) => (str || '').replace(/^\/+/, '');
/**
* GraphQL environments API returns only id and name.
* For the environments dropdown we need metrics_path.
* This method parses the results and add neccessart attrs
* This method parses the results and add necessary attrs
*
* @param {Array} response Environments API result
* @param {String} projectPath Current project path
......@@ -57,7 +57,7 @@ export const parseEnvironmentsResponse = (response = [], projectPath) =>
return {
...env,
id,
metrics_path: `${projectPath}/environments/${id}/metrics`,
metrics_path: `${projectPath}/-/metrics?environment=${id}`,
};
});
......
......@@ -77,7 +77,7 @@ module EnvironmentHelper
can_destroy_environment: can_destroy_environment?(environment),
can_stop_environment: can?(current_user, :stop_environment, environment),
can_admin_environment: can?(current_user, :admin_environment, project),
environment_metrics_path: environment_metrics_path(environment),
environment_metrics_path: project_metrics_dashboard_path(project, environment: environment),
environments_fetch_path: project_environments_path(project, format: :json),
environment_edit_path: edit_project_environment_path(project, environment),
environment_stop_path: stop_project_environment_path(project, environment),
......
......@@ -92,7 +92,7 @@ module EnvironmentsHelper
return path if request.path.include?(path)
end
environment_metrics_path(environment)
project_metrics_dashboard_path(project, environment: environment)
end
def project_and_environment_metrics_data(project, environment)
......
......@@ -18,10 +18,6 @@ module Routing
project_environment_path(environment.project, environment, *args)
end
def environment_metrics_path(environment, *args)
metrics_project_environment_path(environment.project, environment, *args)
end
def environment_delete_path(environment, *args)
expose_path(api_v4_projects_environments_path(id: environment.project.id, environment_id: environment.id))
end
......
......@@ -16,7 +16,7 @@ class EnvironmentStatusEntity < Grape::Entity
end
expose :metrics_monitoring_url, if: ->(*) { can_read_environment? } do |es|
environment_metrics_path(es.environment)
project_metrics_dashboard_path(es.project, environment: es.environment)
end
expose :stop_url, if: ->(*) { can_stop_environment? } do |es|
......
......@@ -5,7 +5,7 @@ exports[`Dashboard template matches the default snapshot 1`] = `
class="prometheus-graphs"
data-qa-selector="prometheus_graphs"
environmentstate="available"
metricsdashboardbasepath="/monitoring/monitor-project/-/environments/1/metrics"
metricsdashboardbasepath="/monitoring/monitor-project/-/metrics?environment=1"
metricsendpoint="/monitoring/monitor-project/-/environments/1/additional_metrics.json"
>
<div>
......
......@@ -126,7 +126,7 @@ describe('dashboard invalid url parameters', () => {
});
it('redirects to different time range', async () => {
const toUrl = `${mockProjectDir}/-/environments/1/metrics`;
const toUrl = `${mockProjectDir}/-/metrics?environment=1`;
removeParams.mockReturnValueOnce(toUrl);
createMountedWrapper();
......
......@@ -547,7 +547,7 @@ describe('parseEnvironmentsResponse', () => {
{
id: 1,
name: 'env-1',
metrics_path: `${projectPath}/environments/1/metrics`,
metrics_path: `${projectPath}/-/metrics?environment=1`,
},
],
},
......@@ -562,7 +562,7 @@ describe('parseEnvironmentsResponse', () => {
{
id: 12,
name: 'env-12',
metrics_path: `${projectPath}/environments/12/metrics`,
metrics_path: `${projectPath}/-/metrics?environment=12`,
},
],
},
......
......@@ -55,7 +55,7 @@ RSpec.describe EnvironmentHelper do
can_destroy_environment: true,
can_stop_environment: true,
can_admin_environment: true,
environment_metrics_path: environment_metrics_path(environment),
environment_metrics_path: project_metrics_dashboard_path(project, environment: environment),
environments_fetch_path: project_environments_path(project, format: :json),
environment_edit_path: edit_project_environment_path(project, environment),
environment_stop_path: stop_project_environment_path(project, environment),
......
......@@ -20,7 +20,7 @@ RSpec.describe EnvironmentsHelper do
expect(metrics_data).to include(
'settings_path' => edit_project_integration_path(project, 'prometheus'),
'clusters_path' => project_clusters_path(project),
'metrics_dashboard_base_path' => environment_metrics_path(environment),
'metrics_dashboard_base_path' => project_metrics_dashboard_path(project, environment: environment),
'current_environment_name' => environment.name,
'documentation_path' => help_page_path('administration/monitoring/prometheus/index.md'),
'add_dashboard_documentation_path' => help_page_path('operations/metrics/dashboards/index.md', anchor: 'add-a-new-dashboard-to-your-project'),
......
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