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
constructor: ->
@initSidebarTab()
$(".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()
new ProjectsList()
initSidebarTab: ->
key = "dashboard_sidebar_filter"
......
......@@ -62,9 +62,13 @@ class Dispatcher
shortcut_handler = new ShortcutsNavigation()
when 'projects:commits:show'
shortcut_handler = new ShortcutsNavigation()
when 'groups:show', 'projects:show'
when 'projects:show'
new Activities()
shortcut_handler = new ShortcutsNavigation()
when 'groups:show'
new Activities()
shortcut_handler = new ShortcutsNavigation()
new ProjectsList()
when 'groups:members'
new GroupMembers()
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
constructor: ->
$('.profile-groups-avatars').tooltip("placement": "top")
new ProjectsList()
......@@ -5,15 +5,11 @@ class DashboardController < ApplicationController
before_filter :event_filter, only: :show
def show
# Fetch only 30 projects.
# If user needs more - point to Dashboard#projects page
@projects_limit = 30
@projects_limit = 20
@groups = current_user.authorized_groups.order_name_asc
@has_authorized_projects = @projects.count > 0
@projects_count = @projects.count
@projects = @projects.includes(:namespace).limit(@projects_limit)
@projects = @projects.includes(:namespace)
@last_push = current_user.recent_push
@publicish_project_count = Project.publicish(current_user).count
......
.panel.panel-default
.panel-heading.clearfix
.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?
.input-group-addon.dash-new-project
= link_to new_project_path do
%strong New project
%ul.well-list.dash-list
- 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
= render 'shared/projects_list', projects: @projects, projects_limit: 20
.panel.panel-default
.panel-heading
Projects (#{projects.count})
- if can? current_user, :create_projects, @group
.panel-head-actions
= link_to new_project_path(namespace_id: @group.id), class: "btn btn-new" do
%i.fa.fa-plus
New project
%ul.well-list
- 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
.panel-heading.clearfix
.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
.input-group-addon.dash-new-project
= link_to new_project_path(namespace_id: @group.id) do
%strong New project
= render 'shared/projects_list', projects: @projects, projects_limit: 20
= link_to project_path(project), class: dom_class(project) do
.dash-project-avatar
= project_icon(project, alt: '', class: 'avatar project-avatar s40')
- if avatar
.dash-project-avatar
= project_icon(project, alt: '', class: 'avatar project-avatar s40')
.dash-project-access-icon
= visibility_level_icon(project.visibility_level)
%span.str-truncated
......@@ -10,5 +11,10 @@
\/
%span.project-name.filter-title
= project.name
%span.arrow
%i.fa.fa-angle-right
- if stars
%span.pull-right.light
%i.fa.fa-star
= project.star_count
- else
%span.arrow
%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?
.panel.panel-default
.panel-heading Projects contributed to
%ul.well-list
- @contributed_projects.sort_by(&:star_count).reverse.each do |project|
%li
= link_to_project project
%span.pull-right.light
%i.fa.fa-star
= project.star_count
= render 'shared/projects_list',
projects: @contributed_projects.sort_by(&:star_count).reverse,
projects_limit: 5, stars: true, avatar: false
- if @projects.present?
.panel.panel-default
.panel-heading Personal projects
%ul.well-list
- @projects.sort_by(&:star_count).reverse.each do |project|
%li
= link_to_project project
%span.pull-right.light
%i.fa.fa-star
= project.star_count
= render 'shared/projects_list',
projects: @projects.sort_by(&:star_count).reverse,
projects_limit: 10, stars: true, avatar: false
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