Commit 6296f65d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'collapsed-projects-list' into 'master'

Improve projects list

* Add search filtering for group projects
* Show all user projects on dashboard
* Refactor projects list into one view
* Hide big list of projects with 'Show all' button

For #2069

See merge request !1636
parents d07b2e09 7b9b9f70
class @Dashboard class @Dashboard
constructor: -> constructor: ->
@initSidebarTab() @initSidebarTab()
new ProjectsList()
$(".dash-filter").keyup ->
terms = $(this).val()
uiBox = $(this).parents('.panel').first()
if terms == "" || terms == undefined
uiBox.find(".dash-list li").show()
else
uiBox.find(".dash-list li").each (index) ->
name = $(this).find(".filter-title").text()
if name.toLowerCase().search(terms.toLowerCase()) == -1
$(this).hide()
else
$(this).show()
initSidebarTab: -> initSidebarTab: ->
key = "dashboard_sidebar_filter" key = "dashboard_sidebar_filter"
......
...@@ -62,9 +62,13 @@ class Dispatcher ...@@ -62,9 +62,13 @@ class Dispatcher
shortcut_handler = new ShortcutsNavigation() shortcut_handler = new ShortcutsNavigation()
when 'projects:commits:show' when 'projects:commits:show'
shortcut_handler = new ShortcutsNavigation() shortcut_handler = new ShortcutsNavigation()
when 'groups:show', 'projects:show' when 'projects:show'
new Activities() new Activities()
shortcut_handler = new ShortcutsNavigation() shortcut_handler = new ShortcutsNavigation()
when 'groups:show'
new Activities()
shortcut_handler = new ShortcutsNavigation()
new ProjectsList()
when 'groups:members' when 'groups:members'
new GroupMembers() new GroupMembers()
new UsersSelect() new UsersSelect()
......
class @ProjectsList
constructor: ->
$(".projects-list .js-expand").on 'click', (e) ->
e.preventDefault()
list = $(this).closest('.projects-list')
list.find("li").show()
list.find("li.bottom").hide()
$(".projects-list-filter").keyup ->
terms = $(this).val()
uiBox = $(this).closest('.panel')
if terms == "" || terms == undefined
uiBox.find(".projects-list li").show()
else
uiBox.find(".projects-list li").each (index) ->
name = $(this).find(".filter-title").text()
if name.toLowerCase().search(terms.toLowerCase()) == -1
$(this).hide()
else
$(this).show()
uiBox.find(".projects-list li.bottom").hide()
class @User class @User
constructor: -> constructor: ->
$('.profile-groups-avatars').tooltip("placement": "top") $('.profile-groups-avatars').tooltip("placement": "top")
new ProjectsList()
...@@ -5,15 +5,11 @@ class DashboardController < ApplicationController ...@@ -5,15 +5,11 @@ class DashboardController < ApplicationController
before_filter :event_filter, only: :show before_filter :event_filter, only: :show
def show def show
# Fetch only 30 projects. @projects_limit = 20
# If user needs more - point to Dashboard#projects page
@projects_limit = 30
@groups = current_user.authorized_groups.order_name_asc @groups = current_user.authorized_groups.order_name_asc
@has_authorized_projects = @projects.count > 0 @has_authorized_projects = @projects.count > 0
@projects_count = @projects.count @projects_count = @projects.count
@projects = @projects.includes(:namespace).limit(@projects_limit) @projects = @projects.includes(:namespace)
@last_push = current_user.recent_push @last_push = current_user.recent_push
@publicish_project_count = Project.publicish(current_user).count @publicish_project_count = Project.publicish(current_user).count
......
.panel.panel-default .panel.panel-default
.panel-heading.clearfix .panel-heading.clearfix
.input-group .input-group
= search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'dash-filter form-control' = search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'projects-list-filter form-control'
- if current_user.can_create_project? - if current_user.can_create_project?
.input-group-addon.dash-new-project .input-group-addon.dash-new-project
= link_to new_project_path do = link_to new_project_path do
%strong New project %strong New project
%ul.well-list.dash-list = render 'shared/projects_list', projects: @projects, projects_limit: 20
- projects.each do |project|
%li.project-row
= render "project", project: project
- if projects.blank?
%li
.nothing-here-block There are no projects here.
- if @projects_count > @projects_limit
%li.bottom
%span.light
#{@projects_limit} of #{pluralize(@projects_count, 'project')} displayed.
.pull-right
= link_to projects_dashboard_path do
Show all
%i.fa.fa-angle-right
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading.clearfix
Projects (#{projects.count}) .input-group
= search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'projects-list-filter form-control'
- if can? current_user, :create_projects, @group - if can? current_user, :create_projects, @group
.panel-head-actions .input-group-addon.dash-new-project
= link_to new_project_path(namespace_id: @group.id), class: "btn btn-new" do = link_to new_project_path(namespace_id: @group.id) do
%i.fa.fa-plus %strong New project
New project
%ul.well-list = render 'shared/projects_list', projects: @projects, projects_limit: 20
- if projects.blank?
.nothing-here-block This group has no projects yet
- projects.each do |project|
%li.project-row
= link_to project_path(project), class: dom_class(project) do
.dash-project-avatar
= project_icon(project, alt: '', class: 'avatar s40')
.dash-project-access-icon
= visibility_level_icon(project.visibility_level)
%span.str-truncated
%span.project-name
= project.name
%span.arrow
%i.fa.fa-angle-right
= link_to project_path(project), class: dom_class(project) do = link_to project_path(project), class: dom_class(project) do
- if avatar
.dash-project-avatar .dash-project-avatar
= project_icon(project, alt: '', class: 'avatar project-avatar s40') = project_icon(project, alt: '', class: 'avatar project-avatar s40')
.dash-project-access-icon .dash-project-access-icon
...@@ -10,5 +11,10 @@ ...@@ -10,5 +11,10 @@
\/ \/
%span.project-name.filter-title %span.project-name.filter-title
= project.name = project.name
- if stars
%span.pull-right.light
%i.fa.fa-star
= project.star_count
- else
%span.arrow %span.arrow
%i.fa.fa-angle-right %i.fa.fa-angle-right
- projects_limit = 20 unless local_assigns[:projects_limit]
- avatar = true unless local_assigns[:avatar] == false
- stars = false unless local_assigns[:stars] == true
%ul.well-list.projects-list
- projects.each_with_index do |project, i|
%li{class: (i >= projects_limit) ? 'project-row hide' : 'project-row'}
= render "shared/project", project: project, avatar: avatar, stars: stars
- if projects.blank?
%li
.nothing-here-block There are no projects here.
- if projects.count > projects_limit
%li.bottom
%span.light
#{projects_limit} of #{pluralize(projects.count, 'project')} displayed.
%span
= link_to '#', class: 'js-expand' do
Show all
- if @contributed_projects.present? - if @contributed_projects.present?
.panel.panel-default .panel.panel-default
.panel-heading Projects contributed to .panel-heading Projects contributed to
%ul.well-list = render 'shared/projects_list',
- @contributed_projects.sort_by(&:star_count).reverse.each do |project| projects: @contributed_projects.sort_by(&:star_count).reverse,
%li projects_limit: 5, stars: true, avatar: false
= link_to_project project
%span.pull-right.light
%i.fa.fa-star
= project.star_count
- if @projects.present? - if @projects.present?
.panel.panel-default .panel.panel-default
.panel-heading Personal projects .panel-heading Personal projects
%ul.well-list = render 'shared/projects_list',
- @projects.sort_by(&:star_count).reverse.each do |project| projects: @projects.sort_by(&:star_count).reverse,
%li projects_limit: 10, stars: true, avatar: false
= link_to_project project
%span.pull-right.light
%i.fa.fa-star
= project.star_count
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment