Commit 7fefb0397eea99910537541bbba70d0a68a44644

Authored by Dmitriy Zaporozhets
1 parent 02c3bb7a

Fix filter context. Dont duplicate target project name for MR

app/assets/stylesheets/common.scss
... ... @@ -364,18 +364,6 @@ img.emoji {
364 364 margin-bottom: 10px;
365 365 }
366 366  
367   -.label-project {
368   - @include border-radius(4px);
369   - padding: 2px 4px;
370   - border: none;
371   - font-size: 14px;
372   - background: #474D57;
373   - color: #fff;
374   - font-family: $monospace_font;
375   - text-shadow: 0 1px 1px #111;
376   - font-weight: normal;
377   -}
378   -
379 367 .group-name {
380 368 font-size: 14px;
381 369 line-height: 24px;
... ...
app/assets/stylesheets/gitlab_bootstrap/mixins.scss
... ... @@ -17,6 +17,10 @@
17 17 border-radius: $radius;
18 18 }
19 19  
  20 +@mixin border-radius-left($radius) {
  21 + @include border-radius($radius 0 0 $radius)
  22 +}
  23 +
20 24 @mixin linear-gradient($from, $to) {
21 25 background-image: -webkit-gradient(linear, 0 0, 0 100%, from($from), to($to));
22 26 background-image: -webkit-linear-gradient($from, $to);
... ...
app/assets/stylesheets/sections/merge_requests.scss
... ... @@ -84,14 +84,23 @@
84 84  
85 85 .label-branch {
86 86 @include border-radius(4px);
87   - padding: 2px 4px;
  87 + padding: 3px 4px;
88 88 border: none;
89 89 font-size: 14px;
90 90 background: #474D57;
91 91 color: #fff;
92 92 font-family: $monospace_font;
93   - text-shadow: 0 1px 1px #111;
94 93 font-weight: normal;
  94 + overflow: hidden;
  95 +
  96 + .label-project {
  97 + @include border-radius-left(4px);
  98 + padding: 3px 4px;
  99 + background: #29A;
  100 + position: relative;
  101 + left: -4px;
  102 + letter-spacing: -1px;
  103 + }
95 104 }
96 105  
97 106 .mr-list {
... ...
app/contexts/filter_context.rb
... ... @@ -12,7 +12,7 @@ class FilterContext
12 12  
13 13 def apply_filter items
14 14 if params[:project_id].present?
15   - items = items.where(project_id: params[:project_id])
  15 + items = items.of_projects(params[:project_id])
16 16 end
17 17  
18 18 if params[:search].present?
... ...
app/models/concerns/issuable.rb
... ... @@ -21,6 +21,7 @@ module Issuable
21 21 scope :recent, -> { order("created_at DESC") }
22 22 scope :assigned, -> { where("assignee_id IS NOT NULL") }
23 23 scope :unassigned, -> { where("assignee_id IS NULL") }
  24 + scope :of_projects, ->(ids) { where(project_id: ids) }
24 25  
25 26 delegate :name,
26 27 :email,
... ...
app/models/issue.rb
... ... @@ -27,7 +27,6 @@ class Issue < ActiveRecord::Base
27 27 scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) }
28 28 scope :opened, -> { with_state(:opened) }
29 29 scope :closed, -> { with_state(:closed) }
30   - scope :by_project, ->(project_id) {where(project_id:project_id)}
31 30  
32 31 attr_accessible :title, :assignee_id, :position, :description,
33 32 :milestone_id, :label_list, :author_id_of_changes,
... ...
app/models/merge_request.rb
... ... @@ -93,8 +93,8 @@ class MergeRequest < ActiveRecord::Base
93 93 scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) }
94 94 scope :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) }
95 95 scope :by_milestone, ->(milestone) { where(milestone_id: milestone) }
96   - scope :by_project, ->(project_id) { where("source_project_id = :project_id OR target_project_id = :project_id", project_id: project_id) }
97 96 scope :in_projects, ->(project_ids) { where("source_project_id in (:project_ids) OR target_project_id in (:project_ids)", project_ids: project_ids) }
  97 + scope :of_projects, ->(ids) { where(target_project_id: ids) }
98 98 # Closed scope for merge request should return
99 99 # both merged and closed mr's
100 100 scope :closed, -> { with_states(:closed, :merged) }
... ...
app/views/projects/merge_requests/_merge_request.html.haml
... ... @@ -9,12 +9,14 @@
9 9 - else
10 10 %span.pull-right
11 11 - if merge_request.for_fork?
12   - = "#{merge_request.source_project.path_with_namespace}/#{merge_request.source_branch}"
13   - %i.icon-angle-right
14   - = "#{merge_request.target_project.path_with_namespace}/#{merge_request.target_branch}"
  12 + %span.light
  13 + = "#{merge_request.source_project.path_with_namespace}"
  14 + = "#{merge_request.source_branch}"
  15 + %i.icon-angle-right.light
  16 + = "#{merge_request.target_branch}"
15 17 - else
16 18 = "#{merge_request.source_branch}"
17   - %i.icon-angle-right
  19 + %i.icon-angle-right.light
18 20 = "#{merge_request.target_branch}"
19 21 .merge-request-info
20 22 - if merge_request.author
... ...
app/views/projects/merge_requests/show/_mr_title.html.haml
... ... @@ -2,10 +2,10 @@
2 2 = "Merge Request ##{@merge_request.id}:"
3 3  
4 4 -if @merge_request.for_fork?
5   - %span.label-project= truncate(@merge_request.source_project.path_with_namespace, length: 25)
6   - %span.label-branch= @merge_request.source_branch
  5 + %span.label-branch
  6 + %span.label-project= truncate(@merge_request.source_project.path_with_namespace, length: 25)
  7 + #{@merge_request.source_branch}
7 8 →
8   - %span.label-project= truncate(@merge_request.target_project.path_with_namespace, length: 25)
9 9 %span.label-branch= @merge_request.target_branch
10 10 - else
11 11 %span.label-branch= @merge_request.source_branch
... ...
spec/contexts/filter_context_spec.rb
... ... @@ -21,17 +21,19 @@ describe FilterContext do
21 21 merge_request3
22 22 merge_request4
23 23 end
  24 +
24 25 it 'should by default filter properly' do
25 26 merge_requests = user.cared_merge_requests
26 27 params ={}
27 28 merge_requests = FilterContext.new(merge_requests, params).execute
28 29 merge_requests.size.should == 3
29 30 end
  31 +
30 32 it 'should apply blocks passed in on creation to the filters' do
31 33 merge_requests = user.cared_merge_requests
32 34 params = {:project_id => project1.id}
33 35 merge_requests = FilterContext.new(merge_requests, params).execute
34   - merge_requests.size.should == 2
  36 + merge_requests.size.should == 1
35 37 end
36 38 end
37 39  
... ... @@ -54,4 +56,4 @@ describe FilterContext do
54 56 issues.size.should == 1
55 57 end
56 58 end
57   -end
58 59 \ No newline at end of file
  60 +end
... ...