Commit 8d19dd96 authored by Ryan Cobb's avatar Ryan Cobb

Change action name and fix code styling

Change action name to show and fix a few code style issues.
parent f786c359
# frozen_string_literal: true
class Projects::MetricsDashboardController < Projects::ApplicationController
before_action :metrics_dashboard_page do
authorize_metrics_dashboard!
module Projects
class MetricsDashboardController < Projects::ApplicationController
before_action :authorize_metrics_dashboard!
before_action do
push_frontend_feature_flag(:prometheus_computed_alerts)
end
def metrics_dashboard_page
def show
if environment
render 'projects/environments/metrics'
else
......@@ -19,14 +18,11 @@ class Projects::MetricsDashboardController < Projects::ApplicationController
def environment
@environment ||=
if metrics_dashboard_page_params[:environment]
project.environments.find(metrics_dashboard_page_params[:environment])
if params[:environment]
project.environments.find(params[:environment])
else
project.default_environment
end
end
def metrics_dashboard_page_params
params.permit(:environment)
end
end
......@@ -26,7 +26,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
scope '-' do
get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive'
get 'd(/:dashboard_path)', constraints: { dashboard_path: /.+\.yml/ },
to: 'metrics_dashboard#metrics_dashboard_page', as: :metrics_dashboard_page, format: false
to: 'metrics_dashboard#show', as: :metrics_dashboard, format: false
resources :artifacts, only: [:index, :destroy]
......
......@@ -44,7 +44,7 @@ describe 'metrics dashboard page' do
end
end
describe 'GET /:namespace/:project/-d/:dashboard_path' do
describe 'GET /:namespace/:project/-/d/:dashboard_path' do
let(:dashboard_path) { '.gitlab/dashboards/dashboard_path.yml' }
it 'returns 200' do
......@@ -58,7 +58,7 @@ describe 'metrics dashboard page' do
end
end
describe 'GET :/namespace/:project/-d/:dashboard_path?environment=:environment.id' do
describe 'GET :/namespace/:project/-/d/:dashboard_path?environment=:environment.id' do
let(:dashboard_path) { '.gitlab/dashboards/dashboard_path.yml' }
it 'returns 200' do
......@@ -80,6 +80,6 @@ describe 'metrics dashboard page' do
end
def send_request(params = {})
get namespace_project_metrics_dashboard_page_path(namespace_id: project.namespace, project_id: project, **params)
get namespace_project_metrics_dashboard_path(namespace_id: project.namespace, project_id: project, **params)
end
end
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