summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2016-09-05 13:14:49 -0500
committerPatricio Cano <suprnova32@gmail.com>2016-09-15 12:27:32 -0500
commitc788c66a85ba4682f5e27a12b5fa73489af23b5f (patch)
tree4ce769eeaa74868c19522db2ec9aee08d5cb8347 /app
parenta8b0d501017ed8ab8656e8cabe5c29ed7e3cbe89 (diff)
downloadgitlab-ce-c788c66a85ba4682f5e27a12b5fa73489af23b5f.tar.gz
Improved helper methods, better flow for `project.lfs_enabled?`, and UI fixes.
Diffstat (limited to 'app')
-rw-r--r--app/helpers/groups_helper.rb23
-rw-r--r--app/helpers/projects_helper.rb4
-rw-r--r--app/models/project.rb4
-rw-r--r--app/views/admin/groups/show.html.haml3
-rw-r--r--app/views/admin/projects/show.html.haml2
-rw-r--r--app/views/projects/edit.html.haml17
6 files changed, 33 insertions, 20 deletions
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index e87197d2056..0352a48e050 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -25,7 +25,26 @@ module GroupsHelper
end
def projects_with_lfs_enabled(group)
- total = group.projects.size
- "#{total - group.projects.select{ |p| !p.lfs_enabled? }.size}/#{total} projects have it enabled"
+ lfs_enabled = group.projects.select(&:lfs_enabled?).size
+ size = group.projects.size
+
+ if lfs_enabled == size || lfs_enabled == 0
+ ' on all projects'
+ else
+ " on #{lfs_enabled}/#{size} projects"
+ end
+ end
+
+ def group_lfs_status(group)
+ if group.lfs_enabled?
+ output = content_tag(:span, class: 'lfs-enabled') do
+ 'Enabled'
+ end
+ else
+ output = content_tag(:span, class: 'lfs-disabled') do
+ 'Disabled'
+ end
+ end
+ output << projects_with_lfs_enabled(group)
end
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index b4be679c72d..16a8e52a4ca 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -202,8 +202,8 @@ module ProjectsHelper
nav_tabs.flatten
end
- def lfs_status_helper(subject)
- if subject.lfs_enabled?
+ def project_lfs_status(project)
+ if project.lfs_enabled?
content_tag(:span, class: 'lfs-enabled') do
'Enabled'
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 8e3bedffe1f..8b5a6f167bd 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -393,10 +393,6 @@ class Project < ActiveRecord::Base
end
def lfs_enabled?
- # Specifically check is lfs_enabled is false
- return false if self[:lfs_enabled] == false
-
- # Should only fallback to the namespace value if no value is set for the project
return namespace.lfs_enabled? if self[:lfs_enabled].nil?
self[:lfs_enabled] && Gitlab.config.lfs.enabled
diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml
index b8e83075a72..0188ed448ce 100644
--- a/app/views/admin/groups/show.html.haml
+++ b/app/views/admin/groups/show.html.haml
@@ -40,8 +40,7 @@
%li
%span.light Group Git LFS status:
%strong
- = lfs_status_helper(@group)
- = projects_with_lfs_enabled(@group)
+ = group_lfs_status(@group)
= link_to icon('question-circle'), help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs')
.panel.panel-default
diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml
index eecc69b125c..6c7c3c48604 100644
--- a/app/views/admin/projects/show.html.haml
+++ b/app/views/admin/projects/show.html.haml
@@ -77,7 +77,7 @@
%li
%span.light Git LFS status:
%strong
- = lfs_status_helper(@project)
+ = project_lfs_status(@project)
= link_to icon('question-circle'), help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs')
- else
%li
diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml
index f6d751a343e..a04d53e02bf 100644
--- a/app/views/projects/edit.html.haml
+++ b/app/views/projects/edit.html.haml
@@ -84,15 +84,14 @@
= project_feature_access_select(:snippets_access_level)
- if Gitlab.config.lfs.enabled && current_user.admin?
- .form-group
- .checkbox
- = f.label :lfs_enabled do
- = f.check_box :lfs_enabled, checked: @project.lfs_enabled?
- %strong LFS
- %br
- %span.descr
- Git Large File Storage
- = link_to icon('question-circle'), help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs')
+ .row
+ .col-md-9
+ = f.label :lfs_enabled, 'LFS', class: 'label-light'
+ %span.help-block
+ Git Large File Storage
+ = link_to icon('question-circle'), help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs')
+ .col-md-3
+ = f.select :lfs_enabled, [%w(Enabled true), %w(Disabled false)], {}, selected: @project.lfs_enabled?, class: 'pull-right form-control'
- if Gitlab.config.registry.enabled
.form-group