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
Kazuhiko Shiozaki
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
Show 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
...
@@ -3,6 +3,8 @@ class DashboardController < ApplicationController
before_filter
:load_projects
,
except:
[
:projects
]
before_filter
:load_projects
,
except:
[
:projects
]
before_filter
:event_filter
,
only: :show
before_filter
:event_filter
,
only: :show
before_filter
:default_filter
,
only:
[
:issues
,
:merge_requests
]
def
show
def
show
# Fetch only 30 projects.
# Fetch only 30 projects.
...
@@ -51,12 +53,12 @@ class DashboardController < ApplicationController
...
@@ -51,12 +53,12 @@ class DashboardController < ApplicationController
end
end
def
merge_requests
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
)
@merge_requests
=
@merge_requests
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
end
end
def
issues
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
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
includes
(
:author
,
:project
)
@issues
=
@issues
.
includes
(
:author
,
:project
)
...
@@ -71,4 +73,9 @@ class DashboardController < ApplicationController
...
@@ -71,4 +73,9 @@ class DashboardController < ApplicationController
def
load_projects
def
load_projects
@projects
=
current_user
.
authorized_projects
.
sorted_by_activity
.
non_archived
@projects
=
current_user
.
authorized_projects
.
sorted_by_activity
.
non_archived
end
end
def
default_filter
params
[
:scope
]
=
'assigned-to-me'
if
params
[
:scope
].
blank?
params
[
:state
]
=
'opened'
if
params
[
:state
].
blank?
end
end
end
app/controllers/groups_controller.rb
View file @
6153aa13
...
@@ -10,6 +10,8 @@ class GroupsController < ApplicationController
...
@@ -10,6 +10,8 @@ class GroupsController < ApplicationController
# Load group projects
# Load group projects
before_filter
:projects
,
except:
[
:new
,
:create
]
before_filter
:projects
,
except:
[
:new
,
:create
]
before_filter
:default_filter
,
only:
[
:issues
,
:merge_requests
]
layout
:determine_layout
layout
:determine_layout
before_filter
:set_title
,
only:
[
:new
,
:create
]
before_filter
:set_title
,
only:
[
:new
,
:create
]
...
@@ -43,18 +45,14 @@ class GroupsController < ApplicationController
...
@@ -43,18 +45,14 @@ class GroupsController < ApplicationController
end
end
end
end
# Get authored or assigned open merge requests
def
merge_requests
def
merge_requests
@merge_requests
=
FilterContext
.
new
(
MergeRequest
,
current_user
,
params
).
execute
@merge_requests
=
FilteringService
.
new
.
execute
(
MergeRequest
,
current_user
,
params
)
@merge_requests
=
@merge_requests
.
of_group
(
@group
)
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
end
end
# Get only assigned issues
def
issues
def
issues
@issues
=
FilterContext
.
new
(
Issue
,
current_user
,
params
).
execute
@issues
=
FilteringService
.
new
.
execute
(
Issue
,
current_user
,
params
)
@issues
=
@issues
.
of_group
(
@group
)
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
includes
(
:author
,
:project
)
@issues
=
@issues
.
includes
(
:author
,
:project
)
respond_to
do
|
format
|
respond_to
do
|
format
|
...
@@ -130,4 +128,10 @@ class GroupsController < ApplicationController
...
@@ -130,4 +128,10 @@ class GroupsController < ApplicationController
'group'
'group'
end
end
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
end
app/helpers/dashboard_helper.rb
View file @
6153aa13
module
DashboardHelper
module
DashboardHelper
def
filter_path
(
entity
,
options
=
{})
def
filter_path
(
entity
,
options
=
{})
exist_opts
=
{
exist_opts
=
{
stat
us:
params
[
:status
],
stat
e:
params
[
:state
],
scope:
params
[
:scope
],
scope:
params
[
:scope
],
project_id:
params
[
:project_id
],
project_id:
params
[
:project_id
],
}
}
...
...
app/views/shared/_filter.html.haml
View file @
6153aa13
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
=
form_tag
filter_path
(
entity
),
method:
'get'
do
=
form_tag
filter_path
(
entity
),
method:
'get'
do
%fieldset
.scope-filter
%fieldset
.scope-filter
%ul
.nav.nav-pills.nav-stacked
%ul
.nav.nav-pills.nav-stacked
%li
{
class:
(
"active"
if
params
[
:scope
]
.
blank?
)}
%li
{
class:
(
"active"
if
params
[
:scope
]
==
'assigned-to-me'
)}
=
link_to
filter_path
(
entity
,
scope:
nil
)
do
=
link_to
filter_path
(
entity
,
scope:
'assigned-to-me'
)
do
Assigned to me
Assigned to me
%li
{
class:
(
"active"
if
params
[
:scope
]
==
'authored'
)}
%li
{
class:
(
"active"
if
params
[
:scope
]
==
'authored'
)}
=
link_to
filter_path
(
entity
,
scope:
'authored'
)
do
=
link_to
filter_path
(
entity
,
scope:
'authored'
)
do
...
@@ -15,14 +15,14 @@
...
@@ -15,14 +15,14 @@
%fieldset
.status-filter
%fieldset
.status-filter
%legend
State
%legend
State
%ul
.nav.nav-pills
%ul
.nav.nav-pills
%li
{
class:
(
"active"
if
params
[
:stat
us
].
blank?
)}
%li
{
class:
(
"active"
if
params
[
:stat
e
]
==
'opened'
)}
=
link_to
filter_path
(
entity
,
stat
us:
nil
)
do
=
link_to
filter_path
(
entity
,
stat
e:
'opened'
)
do
Open
Open
%li
{
class:
(
"active"
if
params
[
:stat
us
]
==
'closed'
)}
%li
{
class:
(
"active"
if
params
[
:stat
e
]
==
'closed'
)}
=
link_to
filter_path
(
entity
,
stat
us
:
'closed'
)
do
=
link_to
filter_path
(
entity
,
stat
e
:
'closed'
)
do
Closed
Closed
%li
{
class:
(
"active"
if
params
[
:stat
us
]
==
'all'
)}
%li
{
class:
(
"active"
if
params
[
:stat
e
]
==
'all'
)}
=
link_to
filter_path
(
entity
,
stat
us
:
'all'
)
do
=
link_to
filter_path
(
entity
,
stat
e
:
'all'
)
do
All
All
%fieldset
%fieldset
...
@@ -36,8 +36,8 @@
...
@@ -36,8 +36,8 @@
%small
.pull-right
=
entities_per_project
(
project
,
entity
)
%small
.pull-right
=
entities_per_project
(
project
,
entity
)
%fieldset
%fieldset
-
if
params
[
:stat
us
].
present?
||
params
[
:project_id
].
present?
-
if
params
[
:stat
e
].
present?
||
params
[
:project_id
].
present?
=
link_to
filter_path
(
entity
,
stat
us
:
nil
,
project_id:
nil
),
class:
'pull-right cgray'
do
=
link_to
filter_path
(
entity
,
stat
e
:
nil
,
project_id:
nil
),
class:
'pull-right cgray'
do
%i
.icon-remove
%i
.icon-remove
%strong
Clear filter
%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