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
iv
gitlab-ce
Commits
6153aa13
Commit
6153aa13
authored
Jan 15, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use FilteringService for Dashboard, Group pages
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
5e96ee34
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
21 deletions
+32
-21
app/controllers/dashboard_controller.rb
app/controllers/dashboard_controller.rb
+9
-2
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+12
-8
app/helpers/dashboard_helper.rb
app/helpers/dashboard_helper.rb
+1
-1
app/views/shared/_filter.html.haml
app/views/shared/_filter.html.haml
+10
-10
No files found.
app/controllers/dashboard_controller.rb
View file @
6153aa13
...
...
@@ -3,6 +3,8 @@ class DashboardController < ApplicationController
before_filter
:load_projects
,
except:
[
:projects
]
before_filter
:event_filter
,
only: :show
before_filter
:default_filter
,
only:
[
:issues
,
:merge_requests
]
def
show
# Fetch only 30 projects.
...
...
@@ -51,12 +53,12 @@ class DashboardController < ApplicationController
end
def
merge_requests
@merge_requests
=
Filter
Context
.
new
(
MergeRequest
,
current_user
,
params
).
execute
@merge_requests
=
Filter
ingService
.
new
.
execute
(
MergeRequest
,
current_user
,
params
)
@merge_requests
=
@merge_requests
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
end
def
issues
@issues
=
Filter
Context
.
new
(
Issue
,
current_user
,
params
).
execute
@issues
=
Filter
ingService
.
new
.
execute
(
Issue
,
current_user
,
params
)
@issues
=
@issues
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
includes
(
:author
,
:project
)
...
...
@@ -71,4 +73,9 @@ class DashboardController < ApplicationController
def
load_projects
@projects
=
current_user
.
authorized_projects
.
sorted_by_activity
.
non_archived
end
def
default_filter
params
[
:scope
]
=
'assigned-to-me'
if
params
[
:scope
].
blank?
params
[
:state
]
=
'opened'
if
params
[
:state
].
blank?
end
end
app/controllers/groups_controller.rb
View file @
6153aa13
...
...
@@ -10,6 +10,8 @@ class GroupsController < ApplicationController
# Load group projects
before_filter
:projects
,
except:
[
:new
,
:create
]
before_filter
:default_filter
,
only:
[
:issues
,
:merge_requests
]
layout
:determine_layout
before_filter
:set_title
,
only:
[
:new
,
:create
]
...
...
@@ -43,18 +45,14 @@ class GroupsController < ApplicationController
end
end
# Get authored or assigned open merge requests
def
merge_requests
@merge_requests
=
FilterContext
.
new
(
MergeRequest
,
current_user
,
params
).
execute
@merge_requests
=
@merge_requests
.
of_group
(
@group
)
@merge_requests
=
@merge_requests
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
FilteringService
.
new
.
execute
(
MergeRequest
,
current_user
,
params
)
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
end
# Get only assigned issues
def
issues
@issues
=
FilterContext
.
new
(
Issue
,
current_user
,
params
).
execute
@issues
=
@issues
.
of_group
(
@group
)
@issues
=
@issues
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
FilteringService
.
new
.
execute
(
Issue
,
current_user
,
params
)
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
includes
(
:author
,
:project
)
respond_to
do
|
format
|
...
...
@@ -130,4 +128,10 @@ class GroupsController < ApplicationController
'group'
end
end
def
default_filter
params
[
:scope
]
=
'assigned-to-me'
if
params
[
:scope
].
blank?
params
[
:state
]
=
'opened'
if
params
[
:state
].
blank?
params
[
:group_id
]
=
@group
.
id
end
end
app/helpers/dashboard_helper.rb
View file @
6153aa13
module
DashboardHelper
def
filter_path
(
entity
,
options
=
{})
exist_opts
=
{
stat
us:
params
[
:status
],
stat
e:
params
[
:state
],
scope:
params
[
:scope
],
project_id:
params
[
:project_id
],
}
...
...
app/views/shared/_filter.html.haml
View file @
6153aa13
...
...
@@ -2,8 +2,8 @@
=
form_tag
filter_path
(
entity
),
method:
'get'
do
%fieldset
.scope-filter
%ul
.nav.nav-pills.nav-stacked
%li
{
class:
(
"active"
if
params
[
:scope
]
.
blank?
)}
=
link_to
filter_path
(
entity
,
scope:
nil
)
do
%li
{
class:
(
"active"
if
params
[
:scope
]
==
'assigned-to-me'
)}
=
link_to
filter_path
(
entity
,
scope:
'assigned-to-me'
)
do
Assigned to me
%li
{
class:
(
"active"
if
params
[
:scope
]
==
'authored'
)}
=
link_to
filter_path
(
entity
,
scope:
'authored'
)
do
...
...
@@ -15,14 +15,14 @@
%fieldset
.status-filter
%legend
State
%ul
.nav.nav-pills
%li
{
class:
(
"active"
if
params
[
:stat
us
].
blank?
)}
=
link_to
filter_path
(
entity
,
stat
us:
nil
)
do
%li
{
class:
(
"active"
if
params
[
:stat
e
]
==
'opened'
)}
=
link_to
filter_path
(
entity
,
stat
e:
'opened'
)
do
Open
%li
{
class:
(
"active"
if
params
[
:stat
us
]
==
'closed'
)}
=
link_to
filter_path
(
entity
,
stat
us
:
'closed'
)
do
%li
{
class:
(
"active"
if
params
[
:stat
e
]
==
'closed'
)}
=
link_to
filter_path
(
entity
,
stat
e
:
'closed'
)
do
Closed
%li
{
class:
(
"active"
if
params
[
:stat
us
]
==
'all'
)}
=
link_to
filter_path
(
entity
,
stat
us
:
'all'
)
do
%li
{
class:
(
"active"
if
params
[
:stat
e
]
==
'all'
)}
=
link_to
filter_path
(
entity
,
stat
e
:
'all'
)
do
All
%fieldset
...
...
@@ -36,8 +36,8 @@
%small
.pull-right
=
entities_per_project
(
project
,
entity
)
%fieldset
-
if
params
[
:stat
us
].
present?
||
params
[
:project_id
].
present?
=
link_to
filter_path
(
entity
,
stat
us
:
nil
,
project_id:
nil
),
class:
'pull-right cgray'
do
-
if
params
[
:stat
e
].
present?
||
params
[
:project_id
].
present?
=
link_to
filter_path
(
entity
,
stat
e
:
nil
,
project_id:
nil
),
class:
'pull-right cgray'
do
%i
.icon-remove
%strong
Clear filter
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