Created
July 11, 2014 06:58
-
-
Save sp3c73r2038/55ad3298b3fa63272250 to your computer and use it in GitHub Desktop.
patch that addes a /groups page to show all groups, for GitLab 7.0.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb | |
index a2629c5..020220e 100644 | |
--- a/app/controllers/groups_controller.rb | |
+++ b/app/controllers/groups_controller.rb | |
@@ -4,7 +4,7 @@ class GroupsController < ApplicationController | |
before_filter :group, except: [:new, :create] | |
# Authorize | |
- before_filter :authorize_read_group!, except: [:new, :create] | |
+ before_filter :authorize_read_group!, except: [:new, :create, :index] | |
before_filter :authorize_admin_group!, only: [:edit, :update, :destroy, :projects] | |
before_filter :authorize_create_group!, only: [:new, :create] | |
@@ -17,6 +17,13 @@ class GroupsController < ApplicationController | |
before_filter :set_title, only: [:new, :create] | |
+ def index | |
+ @groups = Group.order('name ASC') | |
+ @groups = @groups.search(params[:name]) if params[:name].present? | |
+ @groups = @groups.page(params[:page]).per(20) | |
+ @groups | |
+ end | |
+ | |
def new | |
@group = Group.new | |
end | |
@@ -139,7 +146,7 @@ class GroupsController < ApplicationController | |
end | |
def determine_layout | |
- if [:new, :create].include?(action_name.to_sym) | |
+ if [:new, :create, :index].include?(action_name.to_sym) | |
'navless' | |
elsif current_user | |
'group' | |
diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml | |
new file mode 100644 | |
index 0000000..7639d22 | |
--- /dev/null | |
+++ b/app/views/groups/index.html.haml | |
@@ -0,0 +1,37 @@ | |
+%h3.page-title | |
+ Groups (#{@groups.total_count}) | |
+ | |
+%p.light | |
+ Group allows you to keep projects organized. | |
+ Use groups for uniting related projects. | |
+ | |
+%hr | |
+= form_tag groups_path, method: :get, class: 'form-inline' do | |
+ .form-group | |
+ = text_field_tag :name, params[:name], class: "form-control input-mn-300" | |
+ = submit_tag "Search", class: "btn submit btn-primary" | |
+ | |
+%hr | |
+ | |
+%ul.bordered-list | |
+ - @groups.each do |group| | |
+ %li | |
+ .clearfix | |
+ | |
+ %h4 | |
+ = link_to group do | |
+ %i.icon-folder-close | |
+ = group.name | |
+ | |
+ → | |
+ %span.monospace | |
+ %strong #{group.path}/ | |
+ .clearfix | |
+ %p | |
+ = truncate group.description, length: 150 | |
+ .clearfix | |
+ %p.light | |
+ #{pluralize(group.members.size, 'member')}, #{pluralize(group.projects.count, 'project')} | |
+ | |
+ | |
+= paginate @groups, theme: "gitlab" | |
diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml | |
index fba56b5..0282cd4 100644 | |
--- a/app/views/layouts/_head_panel.html.haml | |
+++ b/app/views/layouts/_head_panel.html.haml | |
@@ -27,6 +27,9 @@ | |
= link_to public_root_path, title: "Public area", class: 'has_bottom_tooltip', 'data-original-title' => 'Public area' do | |
%i.icon-globe | |
%li | |
+ = link_to groups_path, title: "All groups", class: 'has_bottom_tooltip', 'data-original-title' => 'All groups' do | |
+ %i.icon-group | |
+ %li | |
= link_to user_snippets_path(current_user), title: "My snippets", class: 'has_bottom_tooltip', 'data-original-title' => 'My snippets' do | |
%i.icon-paste | |
- if current_user.is_admin? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment