summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-06-28 11:54:02 +0200
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-06-28 14:25:15 +0200
commitdd467d6c758b485938553f312ee276fd54e63384 (patch)
tree34effd399f67a8507343586b175286d7d545067e /app
parent50a11a339e65b23bd33e5ad937dbc39674093869 (diff)
downloadgitlab-ce-dd467d6c758b485938553f312ee276fd54e63384.tar.gz
Prevents project first environment from being fetched in every project view
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/application_controller.rb5
-rw-r--r--app/controllers/projects/environments_controller.rb13
-rw-r--r--app/controllers/projects/git_http_client_controller.rb1
-rw-r--r--app/controllers/projects/uploads_controller.rb2
-rw-r--r--app/controllers/projects_controller.rb1
-rw-r--r--app/helpers/environments_helper.rb6
-rw-r--r--app/views/layouts/nav/sidebar/_project.html.haml4
7 files changed, 16 insertions, 16 deletions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index 5475e333db9..5ab6d103c89 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -5,7 +5,6 @@ class Projects::ApplicationController < ApplicationController
skip_before_action :authenticate_user!
before_action :project
before_action :repository
- before_action :available_environment
layout 'project'
helper_method :repository, :can_collaborate_with_project?, :user_access
@@ -33,10 +32,6 @@ class Projects::ApplicationController < ApplicationController
@repository ||= project.repository
end
- def available_environment
- @available_environment ||= project.environments.with_state(:available).first
- end
-
def authorize_action!(action)
unless can?(current_user, action, project)
return access_denied!
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index decef19a0a2..53da384dc74 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -124,6 +124,19 @@ class Projects::EnvironmentsController < Projects::ApplicationController
render :empty
end
+ def metrics_redirect
+ environment = project.environments.with_state(:available).first
+
+ path =
+ if environment
+ environment_metrics_path(environment)
+ else
+ empty_project_environments_path(project)
+ end
+
+ redirect_to path
+ end
+
def metrics
# Currently, this acts as a hint to load the metrics details into the cache
# if they aren't there already
diff --git a/app/controllers/projects/git_http_client_controller.rb b/app/controllers/projects/git_http_client_controller.rb
index 199a8a4c4c5..07249fe3182 100644
--- a/app/controllers/projects/git_http_client_controller.rb
+++ b/app/controllers/projects/git_http_client_controller.rb
@@ -15,7 +15,6 @@ class Projects::GitHttpClientController < Projects::ApplicationController
# Git clients will not know what authenticity token to send along
skip_before_action :verify_authenticity_token
skip_before_action :repository
- skip_before_action :available_environment
before_action :authenticate_user
private
diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb
index 14e84f6a65f..f5cf089ad98 100644
--- a/app/controllers/projects/uploads_controller.rb
+++ b/app/controllers/projects/uploads_controller.rb
@@ -2,7 +2,7 @@ class Projects::UploadsController < Projects::ApplicationController
include UploadsActions
# These will kick you out if you don't have access.
- skip_before_action :project, :repository, :available_environment,
+ skip_before_action :project, :repository,
if: -> { action_name == 'show' && image_or_video? }
before_action :authorize_upload_file!, only: [:create]
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 5a6ccd629d1..c2492a137fb 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -8,7 +8,6 @@ class ProjectsController < Projects::ApplicationController
before_action :redirect_git_extension, only: [:show]
before_action :project, except: [:index, :new, :create]
before_action :repository, except: [:index, :new, :create]
- before_action :available_environment, except: [:index, :new, :create]
before_action :assign_ref_vars, only: [:show], if: :repo_exists?
before_action :tree, only: [:show], if: [:repo_exists?, :project_view_files?]
before_action :lfs_blob_ids, only: [:show], if: [:repo_exists?, :project_view_files?]
diff --git a/app/helpers/environments_helper.rb b/app/helpers/environments_helper.rb
index 9276d9b6ac5..4ce89f89fa9 100644
--- a/app/helpers/environments_helper.rb
+++ b/app/helpers/environments_helper.rb
@@ -4,10 +4,4 @@ module EnvironmentsHelper
endpoint: project_environments_path(@project, format: :json)
}
end
-
- def operations_metrics_path(project, environment)
- return environment_metrics_path(environment) if environment
-
- empty_project_environments_path(project)
- end
end
diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml
index 7ff4bcebe27..a1763393d25 100644
--- a/app/views/layouts/nav/sidebar/_project.html.haml
+++ b/app/views/layouts/nav/sidebar/_project.html.haml
@@ -204,14 +204,14 @@
%ul.sidebar-sub-level-items
= nav_link(controller: [:environments, :clusters, :user, :gcp], html_options: { class: "fly-out-top-item" } ) do
- = link_to operations_metrics_path(@project, @available_environment) do
+ = link_to metrics_project_environments_path(@project) do
%strong.fly-out-top-item-name
= _('Operations')
%li.divider.fly-out-top-item
- if project_nav_tab? :environments
= nav_link(controller: :environments, action: [:metrics, :empty]) do
- = link_to operations_metrics_path(@project, @available_environment), title: 'Metrics', class: 'shortcuts-metrics' do
+ = link_to metrics_project_environments_path(@project), title: 'Metrics', class: 'shortcuts-metrics' do
%span
= _('Metrics')