diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-06-21 10:05:25 +0100 |
---|---|---|
committer | Jose <jvargas@gitlab.com> | 2018-06-26 23:06:25 -0500 |
commit | 55943872f43798b58009c4248d993cc8cb8d34cc (patch) | |
tree | 626c2e14592a7dcb8853e0a8ad5debdfdf374d5d /app | |
parent | 3c49bcb602a38364d0034bfe927097bedbca986c (diff) | |
download | gitlab-ce-55943872f43798b58009c4248d993cc8cb8d34cc.tar.gz |
Adds empty environments page
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/application_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/environments_helper.rb | 4 | ||||
-rw-r--r-- | app/views/layouts/nav/sidebar/_project.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/environments/empty.html.haml | 6 |
6 files changed, 17 insertions, 7 deletions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 719a3c37f45..5475e333db9 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -5,7 +5,7 @@ class Projects::ApplicationController < ApplicationController skip_before_action :authenticate_user! before_action :project before_action :repository - before_action :environment + before_action :available_environment layout 'project' helper_method :repository, :can_collaborate_with_project?, :user_access @@ -33,8 +33,8 @@ class Projects::ApplicationController < ApplicationController @repository ||= project.repository end - def environment - @environment ||= project.environments.first + def available_environment + @available_environment ||= project.environments.with_state(:available).first end def authorize_action!(action) diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 0821362f5df..47b2028860d 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -31,6 +31,10 @@ class Projects::EnvironmentsController < Projects::ApplicationController end end + def empty + render :empty + end + def folder folder_environments = project.environments.where(environment_type: params[:id]) @environments = folder_environments.with_state(params[:scope] || :available) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 582e4d26685..5a6ccd629d1 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -8,7 +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 :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 ed6635a5f06..048175a5264 100644 --- a/app/helpers/environments_helper.rb +++ b/app/helpers/environments_helper.rb @@ -6,8 +6,8 @@ module EnvironmentsHelper end def metrics_path(project, environment) - metrics_project_environment_path(project, environment) if environment + return metrics_project_environment_path(project, environment) if environment - project_environments_path(project) + 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 f516a7fefce..d90ce99da8d 100644 --- a/app/views/layouts/nav/sidebar/_project.html.haml +++ b/app/views/layouts/nav/sidebar/_project.html.haml @@ -211,7 +211,7 @@ - if project_nav_tab? :environments = nav_link(controller: [:environments, :metrics]) do - = link_to metrics_path(@project, @environment), title: 'Metrics', class: 'shortcuts-environments' do + = link_to metrics_path(@project, @available_environment), title: 'Metrics', class: 'shortcuts-environments' do %span = _('Metrics') diff --git a/app/views/projects/environments/empty.html.haml b/app/views/projects/environments/empty.html.haml new file mode 100644 index 00000000000..fc97afc1eab --- /dev/null +++ b/app/views/projects/environments/empty.html.haml @@ -0,0 +1,6 @@ +- page_title "Metrics" + +%h1 + No environments were found + += link_to "New Environment", new_project_environment_path(@project) |