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