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
Boxiang Sun
gitlab-ce
Commits
cc64f2a8
Commit
cc64f2a8
authored
Jan 07, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Common filtering for dashboard and group. Share partial search result partial
parent
0a160399
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
214 additions
and
207 deletions
+214
-207
app/contexts/filter_context.rb
app/contexts/filter_context.rb
+31
-0
app/controllers/dashboard_controller.rb
app/controllers/dashboard_controller.rb
+2
-21
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+7
-5
app/helpers/groups_helper.rb
app/helpers/groups_helper.rb
+17
-0
app/views/groups/_filter.html.haml
app/views/groups/_filter.html.haml
+33
-0
app/views/groups/issues.html.haml
app/views/groups/issues.html.haml
+18
-15
app/views/groups/merge_requests.html.haml
app/views/groups/merge_requests.html.haml
+18
-13
app/views/groups/search.html.haml
app/views/groups/search.html.haml
+1
-67
app/views/groups/show.html.haml
app/views/groups/show.html.haml
+2
-2
app/views/search/_result.html.haml
app/views/search/_result.html.haml
+84
-0
app/views/search/show.html.haml
app/views/search/show.html.haml
+1
-84
No files found.
app/contexts/filter_context.rb
0 → 100644
View file @
cc64f2a8
class
FilterContext
attr_accessor
:items
,
:params
def
initialize
(
items
,
params
)
@items
=
items
@params
=
params
end
def
execute
apply_filter
(
items
)
end
def
apply_filter
items
if
params
[
:project_id
]
items
=
items
.
where
(
project_id:
params
[
:project_id
])
end
if
params
[
:search
].
present?
items
=
items
.
search
(
params
[
:search
])
end
case
params
[
:status
]
when
'closed'
items
.
closed
when
'all'
items
else
items
.
opened
end
end
end
app/controllers/dashboard_controller.rb
View file @
cc64f2a8
...
@@ -36,14 +36,14 @@ class DashboardController < ApplicationController
...
@@ -36,14 +36,14 @@ class DashboardController < ApplicationController
# Get authored or assigned open merge requests
# Get authored or assigned open merge requests
def
merge_requests
def
merge_requests
@merge_requests
=
current_user
.
cared_merge_requests
@merge_requests
=
current_user
.
cared_merge_requests
@merge_requests
=
dashboard_filter
(
@merge_requests
)
@merge_requests
=
FilterContext
.
new
(
@merge_requests
,
params
).
execute
@merge_requests
=
@merge_requests
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
end
end
# Get only assigned issues
# Get only assigned issues
def
issues
def
issues
@issues
=
current_user
.
assigned_issues
@issues
=
current_user
.
assigned_issues
@issues
=
dashboard_filter
(
@issues
)
@issues
=
FilterContext
.
new
(
@issues
,
params
).
execute
@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
)
...
@@ -62,23 +62,4 @@ class DashboardController < ApplicationController
...
@@ -62,23 +62,4 @@ class DashboardController < ApplicationController
def
event_filter
def
event_filter
@event_filter
||=
EventFilter
.
new
(
params
[
:event_filter
])
@event_filter
||=
EventFilter
.
new
(
params
[
:event_filter
])
end
end
def
dashboard_filter
items
if
params
[
:project_id
]
items
=
items
.
where
(
project_id:
params
[
:project_id
])
end
if
params
[
:search
].
present?
items
=
items
.
search
(
params
[
:search
])
end
case
params
[
:status
]
when
'closed'
items
.
closed
when
'all'
items
else
items
.
opened
end
end
end
end
app/controllers/groups_controller.rb
View file @
cc64f2a8
...
@@ -21,15 +21,16 @@ class GroupsController < ApplicationController
...
@@ -21,15 +21,16 @@ class GroupsController < ApplicationController
# Get authored or assigned open merge requests
# Get authored or assigned open merge requests
def
merge_requests
def
merge_requests
@merge_requests
=
current_user
.
cared_merge_requests
.
opened
@merge_requests
=
current_user
.
cared_merge_requests
.
of_group
(
@group
)
@merge_requests
=
@merge_requests
.
of_group
(
@group
).
recent
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
FilterContext
.
new
(
@merge_requests
,
params
).
execute
@merge_requests
=
@merge_requests
.
recent
.
page
(
params
[
:page
]).
per
(
20
)
end
end
# Get only assigned issues
# Get only assigned issues
def
issues
def
issues
@
user
=
current_user
@
issues
=
current_user
.
assigned_issues
.
of_group
(
@group
)
@issues
=
current_user
.
assigned_issues
.
opened
@issues
=
FilterContext
.
new
(
@issues
,
params
).
execute
@issues
=
@issues
.
of_group
(
@group
).
recent
.
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
|
...
@@ -44,6 +45,7 @@ class GroupsController < ApplicationController
...
@@ -44,6 +45,7 @@ class GroupsController < ApplicationController
@projects
=
result
[
:projects
]
@projects
=
result
[
:projects
]
@merge_requests
=
result
[
:merge_requests
]
@merge_requests
=
result
[
:merge_requests
]
@issues
=
result
[
:issues
]
@issues
=
result
[
:issues
]
@wiki_pages
=
result
[
:wiki_pages
]
end
end
def
people
def
people
...
...
app/helpers/groups_helper.rb
0 → 100644
View file @
cc64f2a8
module
GroupsHelper
def
group_filter_path
(
entity
,
options
=
{})
exist_opts
=
{
status:
params
[
:status
],
project_id:
params
[
:project_id
],
}
options
=
exist_opts
.
merge
(
options
)
case
entity
when
'issue'
then
issues_group_path
(
@group
,
options
)
when
'merge_request'
merge_requests_group_path
(
@group
,
options
)
end
end
end
app/views/groups/_filter.html.haml
0 → 100644
View file @
cc64f2a8
=
form_tag
group_filter_path
(
entity
),
method:
'get'
do
%fieldset
.dashboard-search-filter
=
search_field_tag
"search"
,
params
[
:search
],
{
placeholder:
'Search'
,
class:
'search-text-input'
}
=
button_tag
type:
'submit'
,
class:
'btn'
do
%i
.icon-search
%fieldset
%legend
Status:
%ul
.nav.nav-pills.nav-stacked
%li
{
class:
(
"active"
if
!
params
[
:status
])}
=
link_to
group_filter_path
(
entity
,
status:
nil
)
do
Open
%li
{
class:
(
"active"
if
params
[
:status
]
==
'closed'
)}
=
link_to
group_filter_path
(
entity
,
status:
'closed'
)
do
Closed
%li
{
class:
(
"active"
if
params
[
:status
]
==
'all'
)}
=
link_to
group_filter_path
(
entity
,
status:
'all'
)
do
All
%fieldset
%legend
Projects:
%ul
.nav.nav-pills.nav-stacked
-
@projects
.
each
do
|
project
|
-
unless
entities_per_project
(
project
,
entity
).
zero?
%li
{
class:
(
"active"
if
params
[
:project_id
]
==
project
.
id
.
to_s
)}
=
link_to
group_filter_path
(
entity
,
project_id:
project
.
id
)
do
=
project
.
name_with_namespace
%small
.right
=
entities_per_project
(
project
,
entity
)
%fieldset
%hr
=
link_to
"Reset"
,
group_filter_path
(
entity
),
class:
'btn right'
app/views/groups/issues.html.haml
View file @
cc64f2a8
...
@@ -3,18 +3,21 @@
...
@@ -3,18 +3,21 @@
%small
(assigned to you)
%small
(assigned to you)
%small
.right
#{
@issues
.
total_count
}
issues
%small
.right
#{
@issues
.
total_count
}
issues
%br
%hr
.clearfix
.row
-
if
@issues
.
any?
.span3
-
@issues
.
group_by
(
&
:project
).
each
do
|
group
|
=
render
'filter'
,
entity:
'issue'
%div
.ui-box
.span9
-
@project
=
group
[
0
]
-
if
@issues
.
any?
%h5
.title
-
@issues
.
group_by
(
&
:project
).
each
do
|
group
|
=
@project
.
name
%div
.ui-box
%ul
.well-list.issues_table
-
@project
=
group
[
0
]
-
group
[
1
].
each
do
|
issue
|
%h5
.title
=
render
(
partial:
'issues/show'
,
locals:
{
issue:
issue
})
=
link_to_project
@project
%hr
%ul
.well-list.issues_table
=
paginate
@issues
,
theme:
"gitlab"
-
group
[
1
].
each
do
|
issue
|
-
else
=
render
(
partial:
'issues/show'
,
locals:
{
issue:
issue
})
%h3
.nothing_here_message
Nothing to show here
%hr
=
paginate
@issues
,
theme:
"gitlab"
-
else
%p
.nothing_here_message
Nothing to show here
app/views/groups/merge_requests.html.haml
View file @
cc64f2a8
...
@@ -3,17 +3,22 @@
...
@@ -3,17 +3,22 @@
%small
(authored by or assigned to you)
%small
(authored by or assigned to you)
%small
.right
#{
@merge_requests
.
total_count
}
merge requests
%small
.right
#{
@merge_requests
.
total_count
}
merge requests
%br
%hr
-
if
@merge_requests
.
any?
.row
-
@merge_requests
.
group_by
(
&
:project
).
each
do
|
group
|
.span3
%ul
.well-list.ui-box
=
render
'filter'
,
entity:
'merge_request'
-
@project
=
group
[
0
]
.span9
%h5
.title
-
if
@merge_requests
.
any?
=
@project
.
name
-
@merge_requests
.
group_by
(
&
:project
).
each
do
|
group
|
-
group
[
1
].
each
do
|
merge_request
|
.ui-box
=
render
(
partial:
'merge_requests/merge_request'
,
locals:
{
merge_request:
merge_request
})
-
@project
=
group
[
0
]
%hr
%h5
.title
=
paginate
@merge_requests
,
theme:
"gitlab"
=
link_to_project
@project
%ul
.well-list
-
group
[
1
].
each
do
|
merge_request
|
=
render
(
partial:
'merge_requests/merge_request'
,
locals:
{
merge_request:
merge_request
})
%hr
=
paginate
@merge_requests
,
theme:
"gitlab"
-
else
-
else
%h3
.nothing_here_message
Nothing to show here
%h3
.nothing_here_message
Nothing to show here
app/views/groups/search.html.haml
View file @
cc64f2a8
...
@@ -6,70 +6,4 @@
...
@@ -6,70 +6,4 @@
=
search_field_tag
:search
,
params
[
:search
],
placeholder:
"issue 143"
,
class:
"input-xxlarge search-text-input"
,
id:
"dashboard_search"
=
search_field_tag
:search
,
params
[
:search
],
placeholder:
"issue 143"
,
class:
"input-xxlarge search-text-input"
,
id:
"dashboard_search"
=
submit_tag
'Search'
,
class:
"btn primary wide"
=
submit_tag
'Search'
,
class:
"btn primary wide"
-
if
params
[
:search
].
present?
-
if
params
[
:search
].
present?
%br
=
render
'search/result'
%h3
Search results
%small
(
#{
@projects
.
count
+
@merge_requests
.
count
+
@issues
.
count
}
)
%hr
.search_results
.row
.span6
%table
%thead
%tr
%th
Projects
%tbody
-
@projects
.
each
do
|
project
|
%tr
%td
=
link_to
project
do
%strong
.term
=
project
.
name
%small
.cgray
last activity at
=
project
.
last_activity_date
.
stamp
(
"Aug 25, 2011"
)
-
if
@projects
.
blank?
%tr
%td
%h4
.nothing_here_message
No Projects
%br
%table
%thead
%tr
%th
Merge Requests
%tbody
-
@merge_requests
.
each
do
|
merge_request
|
%tr
%td
=
link_to
[
merge_request
.
project
,
merge_request
]
do
%span
.badge.badge-info
##{merge_request.id}
–
%strong
.term
=
truncate
merge_request
.
title
,
length:
50
%strong
.right
%span
.label
=
merge_request
.
project
.
name
-
if
@merge_requests
.
blank?
%tr
%td
%h4
.nothing_here_message
No Merge Requests
.span6
%table
%thead
%tr
%th
Issues
%tbody
-
@issues
.
each
do
|
issue
|
%tr
%td
=
link_to
[
issue
.
project
,
issue
]
do
%span
.badge.badge-info
##{issue.id}
–
%strong
.term
=
truncate
issue
.
title
,
length:
40
%strong
.right
%span
.label
=
issue
.
project
.
name
-
if
@issues
.
blank?
%tr
%td
%h4
.nothing_here_message
No Issues
:javascript
$
(
function
()
{
$
(
"
.search_results .term
"
).
highlight
(
"
#{
params
[
:search
]
}
"
);
})
app/views/groups/show.html.haml
View file @
cc64f2a8
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
%span
.cgray
Events and projects are filtered in scope of group
%span
.cgray
Events and projects are filtered in scope of group
%hr
%hr
-
if
@events
.
any?
-
if
@events
.
any?
.content_list
=
render
@events
.content_list
-
else
-
else
%p
.nothing_here_message
Projects activity will be displayed here
%p
.nothing_here_message
Projects activity will be displayed here
.loading.hide
.loading.hide
...
@@ -26,4 +26,4 @@
...
@@ -26,4 +26,4 @@
=
link_to
"@gitlabhq"
,
"https://twitter.com/gitlabhq"
=
link_to
"@gitlabhq"
,
"https://twitter.com/gitlabhq"
:javascript
:javascript
$
(
function
(){
Pager
.
init
(
20
);
});
$
(
function
(){
Pager
.
init
(
20
,
true
);
});
app/views/search/_result.html.haml
View file @
cc64f2a8
%br
%h3
.page_title
Search results
%span
.cgray
(
#{
@projects
.
count
+
@merge_requests
.
count
+
@issues
.
count
+
@wiki_pages
.
count
}
)
%hr
.search_results
.row
.span6
%table
%thead
%tr
%th
Projects
%tbody
-
@projects
.
each
do
|
project
|
%tr
%td
=
link_to
project
do
%strong
.term
=
project
.
name_with_namespace
%small
.cgray
last activity at
=
project
.
last_activity_date
.
stamp
(
"Aug 25, 2011"
)
-
if
@projects
.
blank?
%tr
%td
%h4
.nothing_here_message
No Projects
%br
%table
%thead
%tr
%th
Merge Requests
%tbody
-
@merge_requests
.
each
do
|
merge_request
|
%tr
%td
=
link_to
[
merge_request
.
project
,
merge_request
]
do
%span
.badge.badge-info
##{merge_request.id}
–
%strong
.term
=
truncate
merge_request
.
title
,
length:
50
%strong
.right
%span
.label
=
merge_request
.
project
.
name
-
if
@merge_requests
.
blank?
%tr
%td
%h4
.nothing_here_message
No Merge Requests
.span6
%table
%thead
%tr
%th
Issues
%tbody
-
@issues
.
each
do
|
issue
|
%tr
%td
=
link_to
[
issue
.
project
,
issue
]
do
%span
.badge.badge-info
##{issue.id}
–
%strong
.term
=
truncate
issue
.
title
,
length:
40
%strong
.right
%span
.label
=
issue
.
project
.
name
-
if
@issues
.
blank?
%tr
%td
%h4
.nothing_here_message
No Issues
.span6
%table
%thead
%tr
%th
Wiki
%tbody
-
@wiki_pages
.
each
do
|
wiki_page
|
%tr
%td
=
link_to
project_wiki_path
(
wiki_page
.
project
,
wiki_page
)
do
%strong
.term
=
truncate
wiki_page
.
title
,
length:
40
%strong
.right
%span
.label
=
wiki_page
.
project
.
name
-
if
@wiki_pages
.
blank?
%tr
%td
%h4
.nothing_here_message
No wiki pages
:javascript
$
(
function
()
{
$
(
"
.search_results .term
"
).
highlight
(
"
#{
escape_javascript
(
params
[
:search
])
}
"
);
})
app/views/search/show.html.haml
View file @
cc64f2a8
...
@@ -6,87 +6,4 @@
...
@@ -6,87 +6,4 @@
=
search_field_tag
:search
,
params
[
:search
],
placeholder:
"issue 143"
,
class:
"input-xxlarge search-text-input"
,
id:
"dashboard_search"
=
search_field_tag
:search
,
params
[
:search
],
placeholder:
"issue 143"
,
class:
"input-xxlarge search-text-input"
,
id:
"dashboard_search"
=
submit_tag
'Search'
,
class:
"btn primary wide"
=
submit_tag
'Search'
,
class:
"btn primary wide"
-
if
params
[
:search
].
present?
-
if
params
[
:search
].
present?
%br
=
render
'search/result'
%h3
Search results
%small
(
#{
@projects
.
count
+
@merge_requests
.
count
+
@issues
.
count
+
@wiki_pages
.
count
}
)
%hr
.search_results
.row
.span6
%table
%thead
%tr
%th
Projects
%tbody
-
@projects
.
each
do
|
project
|
%tr
%td
=
link_to
project
do
%strong
.term
=
project
.
name_with_namespace
%small
.cgray
last activity at
=
project
.
last_activity_date
.
stamp
(
"Aug 25, 2011"
)
-
if
@projects
.
blank?
%tr
%td
%h4
.nothing_here_message
No Projects
%br
%table
%thead
%tr
%th
Merge Requests
%tbody
-
@merge_requests
.
each
do
|
merge_request
|
%tr
%td
=
link_to
[
merge_request
.
project
,
merge_request
]
do
%span
.badge.badge-info
##{merge_request.id}
–
%strong
.term
=
truncate
merge_request
.
title
,
length:
50
%strong
.right
%span
.label
=
merge_request
.
project
.
name
-
if
@merge_requests
.
blank?
%tr
%td
%h4
.nothing_here_message
No Merge Requests
.span6
%table
%thead
%tr
%th
Issues
%tbody
-
@issues
.
each
do
|
issue
|
%tr
%td
=
link_to
[
issue
.
project
,
issue
]
do
%span
.badge.badge-info
##{issue.id}
–
%strong
.term
=
truncate
issue
.
title
,
length:
40
%strong
.right
%span
.label
=
issue
.
project
.
name
-
if
@issues
.
blank?
%tr
%td
%h4
.nothing_here_message
No Issues
.span6
%table
%thead
%tr
%th
Wiki
%tbody
-
@wiki_pages
.
each
do
|
wiki_page
|
%tr
%td
=
link_to
project_wiki_path
(
wiki_page
.
project
,
wiki_page
)
do
%strong
.term
=
truncate
wiki_page
.
title
,
length:
40
%strong
.right
%span
.label
=
wiki_page
.
project
.
name
-
if
@wiki_pages
.
blank?
%tr
%td
%h4
.nothing_here_message
No wiki pages
:javascript
$
(
function
()
{
$
(
"
.search_results .term
"
).
highlight
(
"
#{
escape_javascript
(
params
[
:search
])
}
"
);
})
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