Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
b7c30cae
Commit
b7c30cae
authored
Mar 01, 2017
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add filter and sorting to dashboard groups page
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
11dd2348
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
202 additions
and
46 deletions
+202
-46
app/assets/javascripts/application.js
app/assets/javascripts/application.js
+1
-0
app/assets/javascripts/groups_list.js
app/assets/javascripts/groups_list.js
+50
-0
app/controllers/dashboard/groups_controller.rb
app/controllers/dashboard/groups_controller.rb
+13
-1
app/controllers/explore/groups_controller.rb
app/controllers/explore/groups_controller.rb
+10
-1
app/helpers/explore_helper.rb
app/helpers/explore_helper.rb
+11
-3
app/views/dashboard/_groups_head.html.haml
app/views/dashboard/_groups_head.html.haml
+5
-2
app/views/dashboard/groups/_groups.html.haml
app/views/dashboard/groups/_groups.html.haml
+7
-0
app/views/dashboard/groups/index.html.haml
app/views/dashboard/groups/index.html.haml
+3
-5
app/views/explore/groups/_groups.html.haml
app/views/explore/groups/_groups.html.haml
+6
-0
app/views/explore/groups/index.html.haml
app/views/explore/groups/index.html.haml
+7
-34
app/views/shared/groups/_dropdown.html.haml
app/views/shared/groups/_dropdown.html.haml
+18
-0
changelogs/unreleased/dz-dashboard-groups-search.yml
changelogs/unreleased/dz-dashboard-groups-search.yml
+4
-0
spec/features/dashboard/groups_list_spec.rb
spec/features/dashboard/groups_list_spec.rb
+34
-0
spec/features/explore/groups_list_spec.rb
spec/features/explore/groups_list_spec.rb
+33
-0
No files found.
app/assets/javascripts/application.js
View file @
b7c30cae
...
@@ -177,6 +177,7 @@ require('./project_select');
...
@@ -177,6 +177,7 @@ require('./project_select');
require
(
'
./project_show
'
);
require
(
'
./project_show
'
);
require
(
'
./project_variables
'
);
require
(
'
./project_variables
'
);
require
(
'
./projects_list
'
);
require
(
'
./projects_list
'
);
require
(
'
./groups_list
'
);
require
(
'
./render_gfm
'
);
require
(
'
./render_gfm
'
);
require
(
'
./render_math
'
);
require
(
'
./render_math
'
);
require
(
'
./right_sidebar
'
);
require
(
'
./right_sidebar
'
);
...
...
app/assets/javascripts/groups_list.js
0 → 100644
View file @
b7c30cae
/* eslint-disable func-names, space-before-function-paren, object-shorthand, quotes, no-var, one-var, one-var-declaration-per-line, prefer-arrow-callback, consistent-return, no-unused-vars, camelcase, prefer-template, comma-dangle, max-len */
(
function
()
{
window
.
GroupsList
=
{
init
:
function
()
{
$
(
"
.groups-list-filter
"
).
off
(
'
keyup
'
);
this
.
initSearch
();
return
this
.
initPagination
();
},
initSearch
:
function
()
{
var
debounceFilter
,
groupsListFilter
;
groupsListFilter
=
$
(
'
.groups-list-filter
'
);
debounceFilter
=
_
.
debounce
(
window
.
GroupsList
.
filterResults
,
500
);
return
groupsListFilter
.
on
(
'
keyup
'
,
function
(
e
)
{
if
(
groupsListFilter
.
val
()
!==
''
)
{
return
debounceFilter
();
}
});
},
filterResults
:
function
()
{
var
form
,
group_filter_url
,
search
;
$
(
'
.groups-list-holder
'
).
fadeTo
(
250
,
0.5
);
form
=
null
;
form
=
$
(
"
form#group-filter-form
"
);
search
=
$
(
"
.groups-list-filter
"
).
val
();
group_filter_url
=
form
.
attr
(
'
action
'
)
+
'
?
'
+
form
.
serialize
();
return
$
.
ajax
({
type
:
"
GET
"
,
url
:
form
.
attr
(
'
action
'
),
data
:
form
.
serialize
(),
complete
:
function
()
{
return
$
(
'
.groups-list-holder
'
).
fadeTo
(
250
,
1
);
},
success
:
function
(
data
)
{
$
(
'
.groups-list-holder
'
).
replaceWith
(
data
.
html
);
return
history
.
replaceState
({
page
:
group_filter_url
// Change url so if user reload a page - search results are saved
},
document
.
title
,
group_filter_url
);
},
dataType
:
"
json
"
});
},
initPagination
:
function
()
{
return
$
(
'
.groups-list-holder .pagination
'
).
on
(
'
ajax:success
'
,
function
(
e
,
data
)
{
return
$
(
'
.groups-list-holder
'
).
replaceWith
(
data
.
html
);
});
}
};
}).
call
(
window
);
app/controllers/dashboard/groups_controller.rb
View file @
b7c30cae
class
Dashboard::GroupsController
<
Dashboard
::
ApplicationController
class
Dashboard::GroupsController
<
Dashboard
::
ApplicationController
def
index
def
index
@group_members
=
current_user
.
group_members
.
includes
(
source: :route
).
page
(
params
[
:page
])
@group_members
=
current_user
.
group_members
.
includes
(
source: :route
).
joins
(
:group
)
@group_members
=
@group_members
.
merge
(
Group
.
search
(
params
[
:filter_groups
]))
if
params
[
:filter_groups
].
present?
@group_members
=
@group_members
.
merge
(
Group
.
sort
(
@sort
=
params
[
:sort
]))
@group_members
=
@group_members
.
page
(
params
[
:page
])
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
{
html:
view_to_html_string
(
"dashboard/groups/_groups"
,
locals:
{
group_members:
@group_members
})
}
end
end
end
end
end
end
app/controllers/explore/groups_controller.rb
View file @
b7c30cae
class
Explore::GroupsController
<
Explore
::
ApplicationController
class
Explore::GroupsController
<
Explore
::
ApplicationController
def
index
def
index
@groups
=
GroupsFinder
.
new
.
execute
(
current_user
)
@groups
=
GroupsFinder
.
new
.
execute
(
current_user
)
@groups
=
@groups
.
search
(
params
[
:
search
])
if
params
[
:search
].
present?
@groups
=
@groups
.
search
(
params
[
:
filter_groups
])
if
params
[
:filter_groups
].
present?
@groups
=
@groups
.
sort
(
@sort
=
params
[
:sort
])
@groups
=
@groups
.
sort
(
@sort
=
params
[
:sort
])
@groups
=
@groups
.
page
(
params
[
:page
])
@groups
=
@groups
.
page
(
params
[
:page
])
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
{
html:
view_to_html_string
(
"explore/groups/_groups"
,
locals:
{
groups:
@groups
})
}
end
end
end
end
end
end
app/helpers/explore_helper.rb
View file @
b7c30cae
...
@@ -9,12 +9,20 @@ module ExploreHelper
...
@@ -9,12 +9,20 @@ module ExploreHelper
}
}
options
=
exist_opts
.
merge
(
options
)
options
=
exist_opts
.
merge
(
options
)
path
=
request
.
path
request_path_with_options
(
options
)
path
<<
"?
#{
options
.
to_param
}
"
end
path
def
filter_groups_path
(
options
=
{})
request_path_with_options
(
options
)
end
end
def
explore_controller?
def
explore_controller?
controller
.
class
.
name
.
split
(
"::"
).
first
==
"Explore"
controller
.
class
.
name
.
split
(
"::"
).
first
==
"Explore"
end
end
private
def
request_path_with_options
(
options
=
{})
request
.
path
+
"?
#{
options
.
to_param
}
"
end
end
end
app/views/dashboard/_groups_head.html.haml
View file @
b7c30cae
...
@@ -6,7 +6,10 @@
...
@@ -6,7 +6,10 @@
=
nav_link
(
page:
explore_groups_path
)
do
=
nav_link
(
page:
explore_groups_path
)
do
=
link_to
explore_groups_path
,
title:
'Explore groups'
do
=
link_to
explore_groups_path
,
title:
'Explore groups'
do
Explore Groups
Explore Groups
-
if
current_user
.
can_create_group?
.nav-controls
.nav-controls
=
form_tag
request
.
path
,
method: :get
,
class:
'group-filter-form'
,
id:
'group-filter-form'
do
|
f
|
=
search_field_tag
:filter_groups
,
params
[
:filter_groups
],
placeholder:
'Filter by name...'
,
class:
'group-filter-form-field form-control input-short groups-list-filter'
,
spellcheck:
false
,
id:
'group-filter-form-field'
,
tabindex:
"2"
=
render
'shared/groups/dropdown'
-
if
current_user
.
can_create_group?
=
link_to
new_group_path
,
class:
"btn btn-new"
do
=
link_to
new_group_path
,
class:
"btn btn-new"
do
New Group
New Group
app/views/dashboard/groups/_groups.html.haml
0 → 100644
View file @
b7c30cae
.groups-list-holder
%ul
.content-list
-
@group_members
.
each
do
|
group_member
|
-
group
=
group_member
.
group
=
render
'shared/groups/group'
,
group:
group
,
group_member:
group_member
=
paginate
@group_members
,
theme:
'gitlab'
app/views/dashboard/groups/index.html.haml
View file @
b7c30cae
...
@@ -5,9 +5,7 @@
...
@@ -5,9 +5,7 @@
-
if
@group_members
.
empty?
-
if
@group_members
.
empty?
=
render
'empty_state'
=
render
'empty_state'
-
else
-
else
%ul
.content-list
=
render
'groups'
-
@group_members
.
each
do
|
group_member
|
-
group
=
group_member
.
group
=
render
'shared/groups/group'
,
group:
group
,
group_member:
group_member
=
paginate
@group_members
,
theme:
'gitlab'
:javascript
GroupsList
.
init
();
app/views/explore/groups/_groups.html.haml
0 → 100644
View file @
b7c30cae
.groups-list-holder
%ul
.content-list
-
@groups
.
each
do
|
group
|
=
render
'shared/groups/group'
,
group:
group
=
paginate
@groups
,
theme:
'gitlab'
app/views/explore/groups/index.html.haml
View file @
b7c30cae
...
@@ -6,40 +6,13 @@
...
@@ -6,40 +6,13 @@
-
else
-
else
=
render
'explore/head'
=
render
'explore/head'
.row-content-block.clearfix
.pull-left
=
form_tag
explore_groups_path
,
method: :get
,
class:
'form-inline form-tiny'
do
|
f
|
=
hidden_field_tag
:sort
,
@sort
.form-group
=
search_field_tag
:search
,
params
[
:search
],
placeholder:
"Filter by name"
,
class:
"form-control search-text-input"
,
id:
"groups_search"
,
spellcheck:
false
.form-group
=
button_tag
'Search'
,
class:
"btn btn-default"
.pull-right
.dropdown.inline
%button
.dropdown-toggle
{
type:
'button'
,
'data-toggle'
=>
'dropdown'
}
%span
.light
-
if
@sort
.
present?
=
sort_options_hash
[
@sort
]
-
else
=
sort_title_recently_created
=
icon
(
'chevron-down'
)
%ul
.dropdown-menu.dropdown-menu-align-right
%li
=
link_to
explore_groups_path
(
sort:
sort_value_recently_created
)
do
=
sort_title_recently_created
=
link_to
explore_groups_path
(
sort:
sort_value_oldest_created
)
do
=
sort_title_oldest_created
=
link_to
explore_groups_path
(
sort:
sort_value_recently_updated
)
do
=
sort_title_recently_updated
=
link_to
explore_groups_path
(
sort:
sort_value_oldest_updated
)
do
=
sort_title_oldest_updated
%ul
.content-list
-
@groups
.
each
do
|
group
|
=
render
'shared/groups/group'
,
group:
group
-
unless
@groups
.
present?
.nothing-here-block
No public groups
-
if
@groups
.
present?
=
render
'groups'
-
else
.nothing-here-block
No public groups
=
paginate
@groups
,
theme:
"gitlab"
=
paginate
@groups
,
theme:
"gitlab"
:javascript
GroupsList
.
init
();
app/views/shared/groups/_dropdown.html.haml
0 → 100644
View file @
b7c30cae
.dropdown.inline
%button
.dropdown-toggle
{
type:
'button'
,
'data-toggle'
=>
'dropdown'
}
%span
.light
-
if
@sort
.
present?
=
sort_options_hash
[
@sort
]
-
else
=
sort_title_recently_created
=
icon
(
'chevron-down'
)
%ul
.dropdown-menu.dropdown-menu-align-right
%li
=
link_to
filter_groups_path
(
sort:
sort_value_recently_created
)
do
=
sort_title_recently_created
=
link_to
filter_groups_path
(
sort:
sort_value_oldest_created
)
do
=
sort_title_oldest_created
=
link_to
filter_groups_path
(
sort:
sort_value_recently_updated
)
do
=
sort_title_recently_updated
=
link_to
filter_groups_path
(
sort:
sort_value_oldest_updated
)
do
=
sort_title_oldest_updated
changelogs/unreleased/dz-dashboard-groups-search.yml
0 → 100644
View file @
b7c30cae
---
title
:
Add filter and sorting to dashboard groups page
merge_request
:
9619
author
:
spec/features/dashboard/groups_list_spec.rb
0 → 100644
View file @
b7c30cae
require
'spec_helper'
RSpec
.
describe
'Dashboard Groups page'
,
js:
true
,
feature:
true
do
include
WaitForAjax
let!
(
:user
)
{
create
:user
}
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:nested_group
)
{
create
(
:group
,
:nested
)
}
let!
(
:another_group
)
{
create
(
:group
)
}
before
do
group
.
add_owner
(
user
)
nested_group
.
add_owner
(
user
)
login_as
(
user
)
visit
dashboard_groups_path
end
it
'shows groups user is member of'
do
expect
(
page
).
to
have_content
(
group
.
full_name
)
expect
(
page
).
to
have_content
(
nested_group
.
full_name
)
expect
(
page
).
not_to
have_content
(
another_group
.
full_name
)
end
it
'filters groups'
do
fill_in
'filter_groups'
,
with:
group
.
name
wait_for_ajax
expect
(
page
).
to
have_content
(
group
.
full_name
)
expect
(
page
).
not_to
have_content
(
nested_group
.
full_name
)
expect
(
page
).
not_to
have_content
(
another_group
.
full_name
)
end
end
spec/features/explore/groups_list_spec.rb
0 → 100644
View file @
b7c30cae
require
'spec_helper'
RSpec
.
describe
'Explore Groups page'
,
js:
true
,
feature:
true
do
include
WaitForAjax
let!
(
:user
)
{
create
:user
}
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:public_group
)
{
create
(
:group
,
:public
)
}
let!
(
:private_group
)
{
create
(
:group
,
:private
)
}
before
do
group
.
add_owner
(
user
)
login_as
(
user
)
visit
explore_groups_path
end
it
'shows groups user is member of'
do
expect
(
page
).
to
have_content
(
group
.
full_name
)
expect
(
page
).
to
have_content
(
public_group
.
full_name
)
expect
(
page
).
not_to
have_content
(
private_group
.
full_name
)
end
it
'filters groups'
do
fill_in
'filter_groups'
,
with:
group
.
name
wait_for_ajax
expect
(
page
).
to
have_content
(
group
.
full_name
)
expect
(
page
).
not_to
have_content
(
public_group
.
full_name
)
expect
(
page
).
not_to
have_content
(
private_group
.
full_name
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment