diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-06-20 11:23:33 +0100 |
---|---|---|
committer | Jose <jvargas@gitlab.com> | 2018-06-26 23:06:24 -0500 |
commit | 3c49bcb602a38364d0034bfe927097bedbca986c (patch) | |
tree | ee2fff1eabed9962dd473c133786164dff2c4fb1 /app | |
parent | 292cf668905a55e7b305c67b314cb039d2681a54 (diff) | |
download | gitlab-ce-3c49bcb602a38364d0034bfe927097bedbca986c.tar.gz |
Adds metrics to Operartions tab in projects sidebar
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/application_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 1 | ||||
-rw-r--r-- | app/helpers/environments_helper.rb | 6 | ||||
-rw-r--r-- | app/views/layouts/nav/sidebar/_project.html.haml | 5 |
4 files changed, 17 insertions, 0 deletions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 5ab6d103c89..719a3c37f45 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -5,6 +5,7 @@ class Projects::ApplicationController < ApplicationController skip_before_action :authenticate_user! before_action :project before_action :repository + before_action :environment layout 'project' helper_method :repository, :can_collaborate_with_project?, :user_access @@ -32,6 +33,10 @@ class Projects::ApplicationController < ApplicationController @repository ||= project.repository end + def environment + @environment ||= project.environments.first + end + def authorize_action!(action) unless can?(current_user, action, project) return access_denied! diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c2492a137fb..582e4d26685 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -8,6 +8,7 @@ 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 :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 4ce89f89fa9..ed6635a5f06 100644 --- a/app/helpers/environments_helper.rb +++ b/app/helpers/environments_helper.rb @@ -4,4 +4,10 @@ module EnvironmentsHelper endpoint: project_environments_path(@project, format: :json) } end + + def metrics_path(project, environment) + metrics_project_environment_path(project, environment) if environment + + 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 33416bf76d7..f516a7fefce 100644 --- a/app/views/layouts/nav/sidebar/_project.html.haml +++ b/app/views/layouts/nav/sidebar/_project.html.haml @@ -210,6 +210,11 @@ %li.divider.fly-out-top-item - if project_nav_tab? :environments + = nav_link(controller: [:environments, :metrics]) do + = link_to metrics_path(@project, @environment), title: 'Metrics', class: 'shortcuts-environments' do + %span + = _('Metrics') + = nav_link(controller: :environments) do = link_to project_environments_path(@project), title: 'Environments', class: 'shortcuts-environments' do %span |