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
Boxiang Sun
gitlab-ce
Commits
d714073d
Commit
d714073d
authored
Feb 20, 2018
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use OpenStruct instead Hash for statistics buttons
parent
083003bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
100 deletions
+62
-100
app/presenters/project_presenter.rb
app/presenters/project_presenter.rb
+58
-96
app/views/projects/_stat_anchor_list.html.haml
app/views/projects/_stat_anchor_list.html.haml
+4
-4
No files found.
app/presenters/project_presenter.rb
View file @
d714073d
...
@@ -189,125 +189,95 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
...
@@ -189,125 +189,95 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end
end
def
files_anchor_data
def
files_anchor_data
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
_
(
'Files (%{human_size})'
)
%
{
human_size:
storage_counter
(
statistics
.
total_repository_size
)
},
label:
_
(
'Files (%{human_size})'
)
%
{
human_size:
storage_counter
(
statistics
.
total_repository_size
)
},
link:
project_tree_path
(
project
))
link:
project_tree_path
(
project
)
}
end
end
def
commits_anchor_data
def
commits_anchor_data
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
n_
(
'Commit (%{commit_count})'
,
'Commits (%{commit_count})'
,
statistics
.
commit_count
)
%
{
commit_count:
number_with_delimiter
(
statistics
.
commit_count
)
},
label:
n_
(
'Commit (%{commit_count})'
,
'Commits (%{commit_count})'
,
statistics
.
commit_count
)
%
{
commit_count:
number_with_delimiter
(
statistics
.
commit_count
)
},
link:
project_commits_path
(
project
,
repository
.
root_ref
))
link:
project_commits_path
(
project
,
repository
.
root_ref
)
}
end
end
def
branches_anchor_data
def
branches_anchor_data
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
n_
(
'Branch (%{branch_count})'
,
'Branches (%{branch_count})'
,
repository
.
branch_count
)
%
{
branch_count:
number_with_delimiter
(
repository
.
branch_count
)
},
label:
n_
(
'Branch (%{branch_count})'
,
'Branches (%{branch_count})'
,
repository
.
branch_count
)
%
{
branch_count:
number_with_delimiter
(
repository
.
branch_count
)
},
link:
project_branches_path
(
project
))
link:
project_branches_path
(
project
)
}
end
end
def
tags_anchor_data
def
tags_anchor_data
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
n_
(
'Tag (%{tag_count})'
,
'Tags (%{tag_count})'
,
repository
.
tag_count
)
%
{
tag_count:
number_with_delimiter
(
repository
.
tag_count
)
},
label:
n_
(
'Tag (%{tag_count})'
,
'Tags (%{tag_count})'
,
repository
.
tag_count
)
%
{
tag_count:
number_with_delimiter
(
repository
.
tag_count
)
},
link:
project_tags_path
(
project
))
link:
project_tags_path
(
project
)
}
end
end
def
new_file_anchor_data
def
new_file_anchor_data
if
current_user
&&
can_current_user_push_code?
if
current_user
&&
can_current_user_push_code?
{
OpenStruct
.
new
(
enabled:
false
,
enabled:
false
,
label:
_
(
'New file'
),
label:
_
(
'New file'
),
link:
project_new_blob_path
(
project
,
default_branch
||
'master'
),
link:
project_new_blob_path
(
project
,
default_branch
||
'master'
),
class_modifier:
'new'
)
class_modifier:
'new'
}
end
end
end
end
def
readme_anchor_data
def
readme_anchor_data
if
current_user
&&
can_current_user_push_code?
&&
repository
.
readme
.
blank?
if
current_user
&&
can_current_user_push_code?
&&
repository
.
readme
.
blank?
{
OpenStruct
.
new
(
enabled:
false
,
enabled:
false
,
label:
_
(
'Add Readme'
),
label:
_
(
'Add Readme'
),
link:
add_readme_path
)
link:
add_readme_path
}
elsif
repository
.
readme
.
present?
elsif
repository
.
readme
.
present?
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
_
(
'Readme'
),
label:
_
(
'Readme'
),
link:
default_view
!=
'readme'
?
readme_path
:
'#readme'
)
link:
default_view
!=
'readme'
?
readme_path
:
'#readme'
}
end
end
end
end
def
changelog_anchor_data
def
changelog_anchor_data
if
current_user
&&
can_current_user_push_code?
&&
repository
.
changelog
.
blank?
if
current_user
&&
can_current_user_push_code?
&&
repository
.
changelog
.
blank?
{
OpenStruct
.
new
(
enabled:
false
,
enabled:
false
,
label:
_
(
'Add Changelog'
),
label:
_
(
'Add Changelog'
),
link:
add_special_file_path
(
file_name:
'CHANGELOG'
))
link:
add_special_file_path
(
file_name:
'CHANGELOG'
)
}
elsif
repository
.
changelog
.
present?
elsif
repository
.
changelog
.
present?
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
_
(
'Changelog'
),
label:
_
(
'Changelog'
),
link:
changelog_path
)
link:
changelog_path
}
end
end
end
end
def
license_anchor_data
def
license_anchor_data
if
current_user
&&
can_current_user_push_code?
&&
repository
.
license_blob
.
blank?
if
current_user
&&
can_current_user_push_code?
&&
repository
.
license_blob
.
blank?
{
OpenStruct
.
new
(
enabled:
false
,
enabled:
false
,
label:
_
(
'Add License'
),
label:
_
(
'Add License'
),
link:
add_license_path
)
link:
add_license_path
}
elsif
repository
.
license_blob
.
present?
elsif
repository
.
license_blob
.
present?
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
license_short_name
,
label:
license_short_name
,
link:
license_path
)
link:
license_path
}
end
end
end
end
def
contribution_guide_anchor_data
def
contribution_guide_anchor_data
if
current_user
&&
can_current_user_push_code?
&&
repository
.
contribution_guide
.
blank?
if
current_user
&&
can_current_user_push_code?
&&
repository
.
contribution_guide
.
blank?
{
OpenStruct
.
new
(
enabled:
false
,
enabled:
false
,
label:
_
(
'Add Contribution guide'
),
label:
_
(
'Add Contribution guide'
),
link:
add_special_file_path
(
file_name:
'CONTRIBUTING.md'
,
commit_message:
'Add contribution guide'
))
link:
add_special_file_path
(
file_name:
'CONTRIBUTING.md'
,
commit_message:
'Add contribution guide'
)
}
elsif
repository
.
contribution_guide
.
present?
elsif
repository
.
contribution_guide
.
present?
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
_
(
'Contribution guide'
),
label:
_
(
'Contribution guide'
),
link:
contribution_guide_path
)
link:
contribution_guide_path
}
end
end
end
end
def
autodevops_anchor_data
(
show_auto_devops_callout:
false
)
def
autodevops_anchor_data
(
show_auto_devops_callout:
false
)
if
current_user
&&
can?
(
current_user
,
:admin_pipeline
,
project
)
&&
repository
.
gitlab_ci_yml
.
blank?
&&
!
show_auto_devops_callout
if
current_user
&&
can?
(
current_user
,
:admin_pipeline
,
project
)
&&
repository
.
gitlab_ci_yml
.
blank?
&&
!
show_auto_devops_callout
{
OpenStruct
.
new
(
enabled:
auto_devops_enabled?
,
enabled:
auto_devops_enabled?
,
label:
auto_devops_enabled?
?
_
(
'Auto DevOps enabled'
)
:
_
(
'Enable Auto DevOps'
),
label:
auto_devops_enabled?
?
_
(
'Auto DevOps enabled'
)
:
_
(
'Enable Auto DevOps'
),
link:
project_settings_ci_cd_path
(
project
,
anchor:
'js-general-pipeline-settings'
))
link:
project_settings_ci_cd_path
(
project
,
anchor:
'js-general-pipeline-settings'
)
}
elsif
auto_devops_enabled?
elsif
auto_devops_enabled?
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
_
(
'Auto DevOps enabled'
),
label:
_
(
'Auto DevOps enabled'
),
link:
nil
)
link:
nil
}
end
end
end
end
...
@@ -319,37 +289,29 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
...
@@ -319,37 +289,29 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
cluster_link
=
new_project_cluster_path
(
project
)
cluster_link
=
new_project_cluster_path
(
project
)
end
end
{
OpenStruct
.
new
(
enabled:
!
clusters
.
empty?
,
enabled:
!
clusters
.
empty?
,
label:
clusters
.
empty?
?
_
(
'Add Kubernetes cluster'
)
:
n_
(
'Kubernetes cluster'
,
'Kubernetes clusters'
,
clusters
.
size
),
label:
clusters
.
empty?
?
_
(
'Add Kubernetes cluster'
)
:
n_
(
'Kubernetes cluster'
,
'Kubernetes clusters'
,
clusters
.
size
),
link:
cluster_link
)
link:
cluster_link
}
end
end
end
end
def
gitlab_ci_anchor_data
def
gitlab_ci_anchor_data
if
current_user
&&
can_current_user_push_code?
&&
repository
.
gitlab_ci_yml
.
blank?
&&
!
auto_devops_enabled?
if
current_user
&&
can_current_user_push_code?
&&
repository
.
gitlab_ci_yml
.
blank?
&&
!
auto_devops_enabled?
{
OpenStruct
.
new
(
enabled:
false
,
enabled:
false
,
label:
_
(
'Set up CI/CD'
),
label:
_
(
'Set up CI/CD'
),
link:
add_ci_yml_path
)
link:
add_ci_yml_path
}
elsif
repository
.
gitlab_ci_yml
.
present?
elsif
repository
.
gitlab_ci_yml
.
present?
{
OpenStruct
.
new
(
enabled:
true
,
enabled:
true
,
label:
_
(
'CI/CD configuration'
),
label:
_
(
'CI/CD configuration'
),
link:
ci_configuration_path
)
link:
ci_configuration_path
}
end
end
end
end
def
koding_anchor_data
def
koding_anchor_data
if
current_user
&&
can_current_user_push_code?
&&
koding_enabled?
&&
repository
.
koding_yml
.
blank?
if
current_user
&&
can_current_user_push_code?
&&
koding_enabled?
&&
repository
.
koding_yml
.
blank?
{
OpenStruct
.
new
(
enabled:
false
,
enabled:
false
,
label:
_
(
'Set up Koding'
),
label:
_
(
'Set up Koding'
),
link:
add_koding_stack_path
)
link:
add_koding_stack_path
}
end
end
end
end
...
...
app/views/projects/_stat_anchor_list.html.haml
View file @
d714073d
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
%ul
.nav
%ul
.nav
-
anchors
.
each
do
|
anchor
|
-
anchors
.
each
do
|
anchor
|
%li
%li
-
if
anchor
[
:link
]
-
if
anchor
.
link
=
link_to
anchor
[
:link
],
class:
anchor
[
:enabled
]
?
'stat-link'
:
"btn btn-
#{
anchor
[
:class_modifier
]
||
'missing'
}
"
do
=
link_to
anchor
.
link
,
class:
anchor
.
enabled
?
'stat-link'
:
"btn btn-
#{
anchor
.
class_modifier
||
'missing'
}
"
do
=
anchor
[
:label
]
=
anchor
.
label
-
else
-
else
%span
.stat-text
%span
.stat-text
=
anchor
[
:label
]
=
anchor
.
label
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