diff options
-rw-r--r-- | app/assets/stylesheets/selects.scss | 4 | ||||
-rw-r--r-- | app/controllers/admin/projects_controller.rb | 6 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 9 | ||||
-rw-r--r-- | app/helpers/namespaces_helper.rb | 10 | ||||
-rw-r--r-- | app/views/admin/projects/index.html.haml | 4 |
5 files changed, 18 insertions, 15 deletions
diff --git a/app/assets/stylesheets/selects.scss b/app/assets/stylesheets/selects.scss index 7abbe80bd39..9b7b6ad583c 100644 --- a/app/assets/stylesheets/selects.scss +++ b/app/assets/stylesheets/selects.scss @@ -10,6 +10,10 @@ .ajax-users-select { width: 400px; + + &.input-large { + width: 210px; + } } .user-result { diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index fa7d730663a..a63c4694a81 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -2,8 +2,10 @@ class Admin::ProjectsController < Admin::ApplicationController before_filter :project, only: [:edit, :show, :update, :destroy, :team_update] def index - @projects = Project.scoped - @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present? + owner_id = params[:owner_id] + user = User.find_by_id(owner_id) + + @projects = user ? user.owned_projects : Project.scoped @projects = @projects.where(public: true) if params[:public_only].present? @projects = @projects.with_push if params[:with_push].present? @projects = @projects.abandoned if params[:abandoned].present? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 935fb327c62..4cbc4d187e8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -192,9 +192,12 @@ module ApplicationHelper alias_method :url_to_image, :image_url def users_select_tag(id, opts = {}) - css_class = "ajax-users-select" - css_class << " multiselect" if opts[:multiple] - hidden_field_tag(id, '', class: css_class) + css_class = "ajax-users-select " + css_class << "multiselect " if opts[:multiple] + css_class << opts[:class] || '' + value = opts[:selected] || '' + + hidden_field_tag(id, value, class: css_class) end def body_data_page diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb index a9a6c78654f..69ad3de5031 100644 --- a/app/helpers/namespaces_helper.rb +++ b/app/helpers/namespaces_helper.rb @@ -1,13 +1,7 @@ module NamespacesHelper def namespaces_options(selected = :current_user, scope = :default) - if current_user.admin - groups = Group.all - users = Namespace.root - else - groups = current_user.owned_groups.select {|n| n.type == 'Group'} - users = current_user.namespaces.reject {|n| n.type == 'Group'} - end - + groups = current_user.owned_groups.select {|n| n.type == 'Group'} + users = current_user.namespaces.reject {|n| n.type == 'Group'} global_opts = ["Global", [['/', Namespace.global_id]] ] group_opts = ["Groups", groups.sort_by(&:human_name).map {|g| [g.human_name, g.id]} ] diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml index af65a868b5c..70ea460a06f 100644 --- a/app/views/admin/projects/index.html.haml +++ b/app/views/admin/projects/index.html.haml @@ -14,9 +14,9 @@ = text_field_tag :name, params[:name], class: "span2" .control-group - = label_tag :namespace_id, 'Namespace:', class: 'control-label' + = label_tag :owner_id, 'Owner:', class: 'control-label' .controls - = select_tag :namespace_id, namespaces_options(params[:namespace_id], :all), class: "chosen span2", prompt: "Any" + = users_select_tag :owner_id, selected: params[:owner_id], class: 'input-large' .control-group = label_tag :public_only, 'Public Only', class: 'control-label' .controls |