Commit 512cd02335de9de22aab688743a01fa868229f0d

Authored by Dmitriy Zaporozhets
1 parent 21c70354

Dashboard/Group issues and mr pages refactoring

app/assets/stylesheets/gitlab_bootstrap/nav.scss
... ... @@ -10,6 +10,7 @@
10 10 > li > a {
11 11 @include border-radius(0);
12 12 }
  13 +
13 14 &.nav-stacked {
14 15 > li > a {
15 16 border-left: 4px solid #EEE;
... ... @@ -30,6 +31,12 @@
30 31 }
31 32 }
32 33 }
  34 +
  35 + &.nav-pills-small {
  36 + > li > a {
  37 + padding: 8px 12px;
  38 + }
  39 + }
33 40 }
34 41  
35 42 .nav-pills > .active > a > i[class^="icon-"] { background: inherit; }
... ...
app/contexts/filter_context.rb
... ... @@ -11,7 +11,7 @@ class FilterContext
11 11 end
12 12  
13 13 def apply_filter items
14   - if params[:project_id]
  14 + if params[:project_id].present?
15 15 items = items.where(project_id: params[:project_id])
16 16 end
17 17  
... ...
app/helpers/dashboard_helper.rb
1 1 module DashboardHelper
2   - def dashboard_filter_path(entity, options={})
  2 + def filter_path(entity, options={})
3 3 exist_opts = {
4 4 status: params[:status],
5 5 project_id: params[:project_id],
... ... @@ -7,12 +7,9 @@ module DashboardHelper
7 7  
8 8 options = exist_opts.merge(options)
9 9  
10   - case entity
11   - when 'issue' then
12   - issues_dashboard_path(options)
13   - when 'merge_request'
14   - merge_requests_dashboard_path(options)
15   - end
  10 + path = request.path
  11 + path << "?#{options.to_param}"
  12 + path
16 13 end
17 14  
18 15 def entities_per_project project, entity
... ...
app/helpers/groups_helper.rb
1 1 module GroupsHelper
2   - def group_filter_path(entity, options={})
3   - exist_opts = {
4   - status: params[:status],
5   - project_id: params[:project_id],
6   - }
7   -
8   - options = exist_opts.merge(options)
9   -
10   - case entity
11   - when 'issue' then
12   - issues_group_path(@group, options)
13   - when 'merge_request'
14   - merge_requests_group_path(@group, options)
15   - end
16   - end
17   -
18 2 def remove_user_from_group_message(group, user)
19 3 "You are going to remove #{user.name} from #{group.name} Group. Are you sure?"
20 4 end
... ...
app/views/dashboard/_filter.html.haml
... ... @@ -1,27 +0,0 @@
1   -= form_tag dashboard_filter_path(entity), method: 'get' do
2   - %fieldset
3   - %ul.nav.nav-pills.nav-stacked
4   - %li{class: ("active" if !params[:status])}
5   - = link_to dashboard_filter_path(entity, status: nil) do
6   - Open
7   - %li{class: ("active" if params[:status] == 'closed')}
8   - = link_to dashboard_filter_path(entity, status: 'closed') do
9   - Closed
10   - %li{class: ("active" if params[:status] == 'all')}
11   - = link_to dashboard_filter_path(entity, status: 'all') do
12   - All
13   -
14   - %fieldset
15   - %legend Projects:
16   - %ul.nav.nav-pills.nav-stacked
17   - - @projects.each do |project|
18   - - unless entities_per_project(project, entity).zero?
19   - %li{class: ("active" if params[:project_id] == project.id.to_s)}
20   - = link_to dashboard_filter_path(entity, project_id: project.id) do
21   - = project.name_with_namespace
22   - %small.pull-right= entities_per_project(project, entity)
23   -
24   - %fieldset
25   - %hr
26   - = link_to "Reset", dashboard_filter_path(entity), class: 'btn pull-right'
27   -
app/views/dashboard/issues.html.haml
... ... @@ -8,23 +8,6 @@
8 8  
9 9 .row
10 10 .span3
11   - = render 'filter', entity: 'issue'
  11 + = render 'shared/filter', entity: 'issue'
12 12 .span9
13   - - if @issues.any?
14   - - @issues.group_by(&:project).each do |group|
15   - %div.ui-box
16   - - project = group[0]
17   - .title
18   - = link_to_project project
19   - &nbsp;
20   - %i.icon-angle-right
21   - &nbsp;
22   - = link_to 'issues', project_issues_path(project)
23   -
24   - %ul.well-list.issues-list
25   - - group[1].each do |issue|
26   - = render 'projects/issues/issue', issue: issue
27   - %hr
28   - = paginate @issues, theme: "gitlab"
29   - - else
30   - %p.nothing_here_message Nothing to show here
  13 + = render 'shared/issues'
... ...
app/views/dashboard/merge_requests.html.haml
... ... @@ -8,6 +8,6 @@
8 8 %hr
9 9 .row
10 10 .span3
11   - = render 'filter', entity: 'merge_request'
  11 + = render 'shared/filter', entity: 'merge_request'
12 12 .span9
13 13 = render 'shared/merge_requests'
... ...
app/views/groups/issues.html.haml
... ... @@ -6,18 +6,6 @@
6 6 %hr
7 7 .row
8 8 .span3
9   - = render 'filter', entity: 'issue'
  9 + = render 'shared/filter', entity: 'issue'
10 10 .span9
11   - - if @issues.any?
12   - - @issues.group_by(&:project).each do |group|
13   - %div.ui-box
14   - - project = group[0]
15   - .title
16   - = link_to_project project
17   - %ul.well-list.issues-list
18   - - group[1].each do |issue|
19   - = render 'projects/issues/issue', issue: issue
20   - %hr
21   - = paginate @issues, theme: "gitlab"
22   - - else
23   - %p.nothing_here_message Nothing to show here
  11 + = render 'shared/issues'
... ...
app/views/groups/merge_requests.html.haml
... ... @@ -6,6 +6,6 @@
6 6 %hr
7 7 .row
8 8 .span3
9   - = render 'filter', entity: 'merge_request'
  9 + = render 'shared/filter', entity: 'merge_request'
10 10 .span9
11 11 = render 'shared/merge_requests'
... ...
app/views/shared/_filter.html.haml 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 += form_tag filter_path(entity), method: 'get' do
  2 + %fieldset
  3 + %ul.nav.nav-pills.nav-stacked
  4 + %li{class: ("active" if params[:status].blank?)}
  5 + = link_to filter_path(entity, status: nil) do
  6 + Open
  7 + %li{class: ("active" if params[:status] == 'closed')}
  8 + = link_to filter_path(entity, status: 'closed') do
  9 + Closed
  10 + %li{class: ("active" if params[:status] == 'all')}
  11 + = link_to filter_path(entity, status: 'all') do
  12 + All
  13 +
  14 + %fieldset
  15 + %legend Projects:
  16 + %ul.nav.nav-pills.nav-pills-small.nav-stacked
  17 + - @projects.each do |project|
  18 + - unless entities_per_project(project, entity).zero?
  19 + %li{class: ("active" if params[:project_id] == project.id.to_s)}
  20 + = link_to filter_path(entity, project_id: project.id) do
  21 + = project.name_with_namespace
  22 + %small.pull-right= entities_per_project(project, entity)
  23 +
  24 + %fieldset
  25 + - if params[:status].present? || params[:project_id].present?
  26 + = link_to filter_path(entity, status: nil, project_id: nil), class: 'pull-right cgray' do
  27 + %i.icon-remove
  28 + Clear filter
  29 +
... ...
app/views/shared/_issues.html.haml 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +- if @issues.any?
  2 + - @issues.group_by(&:project).each do |group|
  3 + %div.ui-box
  4 + - project = group[0]
  5 + .title
  6 + = link_to_project project
  7 + &nbsp;
  8 + %i.icon-angle-right
  9 + &nbsp;
  10 + = link_to 'issues', project_issues_path(project)
  11 +
  12 + %ul.well-list.issues-list
  13 + - group[1].each do |issue|
  14 + = render 'projects/issues/issue', issue: issue
  15 + %hr
  16 + = paginate @issues, theme: "gitlab"
  17 +- else
  18 + %p.nothing_here_message Nothing to show here
  19 +
... ...