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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
21aabf98
Commit
21aabf98
authored
Dec 19, 2019
by
Etienne Baqué
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Project presenter methods
parent
ff937a0a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
3 deletions
+16
-3
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+1
-0
app/presenters/project_presenter.rb
app/presenters/project_presenter.rb
+14
-3
app/views/projects/environments/index.html.haml
app/views/projects/environments/index.html.haml
+1
-0
No files found.
app/controllers/projects/environments_controller.rb
View file @
21aabf98
...
@@ -23,6 +23,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -23,6 +23,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def
index
def
index
@environments
=
project
.
environments
@environments
=
project
.
environments
.
with_state
(
params
[
:scope
]
||
:available
)
.
with_state
(
params
[
:scope
]
||
:available
)
@project
=
ProjectPresenter
.
new
(
project
,
current_user:
current_user
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
...
...
app/presenters/project_presenter.rb
View file @
21aabf98
...
@@ -276,8 +276,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
...
@@ -276,8 +276,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end
end
def
kubernetes_cluster_anchor_data
def
kubernetes_cluster_anchor_data
if
current_user
&&
can?
(
current_user
,
:create_cluster
,
project
)
if
can_cluster_be_created?
if
clusters
.
empty?
if
clusters
.
empty?
AnchorData
.
new
(
false
,
AnchorData
.
new
(
false
,
statistic_icon
+
_
(
'Add Kubernetes cluster'
),
statistic_icon
+
_
(
'Add Kubernetes cluster'
),
...
@@ -294,7 +293,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
...
@@ -294,7 +293,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end
end
def
gitlab_ci_anchor_data
def
gitlab_ci_anchor_data
if
c
urrent_user
&&
can_current_user_push_code?
&&
repository
.
gitlab_ci_yml
.
blank?
&&
!
auto_devops_enabled
?
if
c
an_cicd_be_set_up
?
AnchorData
.
new
(
false
,
AnchorData
.
new
(
false
,
statistic_icon
+
_
(
'Set up CI/CD'
),
statistic_icon
+
_
(
'Set up CI/CD'
),
add_ci_yml_path
)
add_ci_yml_path
)
...
@@ -306,6 +305,18 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
...
@@ -306,6 +305,18 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end
end
end
end
def
can_setup_review_app?
can_cicd_be_set_up?
||
can_cluster_be_created?
end
def
can_cicd_be_set_up?
current_user
&&
can_current_user_push_code?
&&
repository
.
gitlab_ci_yml
.
blank?
&&
!
auto_devops_enabled?
end
def
can_cluster_be_created?
current_user
&&
can?
(
current_user
,
:create_cluster
,
project
)
end
def
topics_to_show
def
topics_to_show
project
.
tag_list
.
take
(
MAX_TOPICS_TO_SHOW
)
# rubocop: disable CodeReuse/ActiveRecord
project
.
tag_list
.
take
(
MAX_TOPICS_TO_SHOW
)
# rubocop: disable CodeReuse/ActiveRecord
end
end
...
...
app/views/projects/environments/index.html.haml
View file @
21aabf98
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#environments-list-view
{
data:
{
environments_data:
environments_list_data
,
#environments-list-view
{
data:
{
environments_data:
environments_list_data
,
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
).
to_s
,
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
).
to_s
,
"can-create-environment"
=>
can?
(
current_user
,
:create_environment
,
@project
).
to_s
,
"can-create-environment"
=>
can?
(
current_user
,
:create_environment
,
@project
).
to_s
,
"can-setup-review-app"
=>
@project
.
can_setup_review_app?
,
"new-environment-path"
=>
new_project_environment_path
(
@project
),
"new-environment-path"
=>
new_project_environment_path
(
@project
),
"help-page-path"
=>
help_page_path
(
"ci/environments"
),
"help-page-path"
=>
help_page_path
(
"ci/environments"
),
"deploy-boards-help-path"
=>
help_page_path
(
"user/project/deploy_boards"
,
anchor:
"enabling-deploy-boards"
)
}
}
"deploy-boards-help-path"
=>
help_page_path
(
"user/project/deploy_boards"
,
anchor:
"enabling-deploy-boards"
)
}
}
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