Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
dd467d6c
Commit
dd467d6c
authored
Jun 28, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevents project first environment from being fetched in every project view
parent
50a11a33
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
35 additions
and
35 deletions
+35
-35
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+0
-5
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+13
-0
app/controllers/projects/git_http_client_controller.rb
app/controllers/projects/git_http_client_controller.rb
+0
-1
app/controllers/projects/uploads_controller.rb
app/controllers/projects/uploads_controller.rb
+1
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+0
-1
app/helpers/environments_helper.rb
app/helpers/environments_helper.rb
+0
-6
app/views/layouts/nav/sidebar/_project.html.haml
app/views/layouts/nav/sidebar/_project.html.haml
+2
-2
config/routes/project.rb
config/routes/project.rb
+1
-0
spec/controllers/projects/environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+18
-0
spec/helpers/environments_helper_spec.rb
spec/helpers/environments_helper_spec.rb
+0
-19
No files found.
app/controllers/projects/application_controller.rb
View file @
dd467d6c
...
...
@@ -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!
...
...
app/controllers/projects/environments_controller.rb
View file @
dd467d6c
...
...
@@ -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
...
...
app/controllers/projects/git_http_client_controller.rb
View file @
dd467d6c
...
...
@@ -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
...
...
app/controllers/projects/uploads_controller.rb
View file @
dd467d6c
...
...
@@ -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
]
...
...
app/controllers/projects_controller.rb
View file @
dd467d6c
...
...
@@ -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?
]
...
...
app/helpers/environments_helper.rb
View file @
dd467d6c
...
...
@@ -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
app/views/layouts/nav/sidebar/_project.html.haml
View file @
dd467d6c
...
...
@@ -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_environmen
t
)
do
=
link_to
metrics_project_environments_path
(
@projec
t
)
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_environmen
t
),
title:
'Metrics'
,
class:
'shortcuts-metrics'
do
=
link_to
metrics_project_environments_path
(
@projec
t
),
title:
'Metrics'
,
class:
'shortcuts-metrics'
do
%span
=
_
(
'Metrics'
)
...
...
config/routes/project.rb
View file @
dd467d6c
...
...
@@ -235,6 +235,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
collection
do
get
:metrics
,
action: :metrics_redirect
get
:empty
get
:folder
,
path:
'folders/*id'
,
constraints:
{
format:
/(html|json)/
}
end
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
dd467d6c
...
...
@@ -287,6 +287,24 @@ describe Projects::EnvironmentsController do
end
end
describe
'GET #metrics_redirect'
do
let
(
:project
)
{
create
(
:project
)
}
it
'redirects to environment if it exists'
do
environment
=
create
(
:environment
,
name:
'production'
,
project:
project
)
get
:metrics_redirect
,
environment_params
expect
(
response
).
to
redirect_to
(
environment_metrics_path
(
environment
))
end
it
'redirects to empty page if no environment exists'
do
get
:metrics_redirect
,
environment_params
expect
(
response
).
to
redirect_to
(
empty_project_environments_path
(
project
))
end
end
describe
'GET #metrics'
do
before
do
allow
(
controller
).
to
receive
(
:environment
).
and_return
(
environment
)
...
...
spec/helpers/environments_helper_spec.rb
deleted
100644 → 0
View file @
50a11a33
require
'spec_helper'
describe
EnvironmentsHelper
do
include
ApplicationHelper
describe
'operations_metrics_path'
do
let
(
:project
)
{
create
(
:project
)
}
it
'returns empty metrics path when environment is nil'
do
expect
(
helper
.
operations_metrics_path
(
project
,
nil
)).
to
eq
(
empty_project_environments_path
(
project
))
end
it
'returns environment metrics path when environment is passed'
do
environment
=
create
(
:environment
,
project:
project
)
expect
(
helper
.
operations_metrics_path
(
project
,
environment
)).
to
eq
(
environment_metrics_path
(
environment
))
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment