Commit 7fefb039 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix filter context. Dont duplicate target project name for MR

parent 02c3bb7a
...@@ -364,18 +364,6 @@ img.emoji { ...@@ -364,18 +364,6 @@ img.emoji {
margin-bottom: 10px; margin-bottom: 10px;
} }
.label-project {
@include border-radius(4px);
padding: 2px 4px;
border: none;
font-size: 14px;
background: #474D57;
color: #fff;
font-family: $monospace_font;
text-shadow: 0 1px 1px #111;
font-weight: normal;
}
.group-name { .group-name {
font-size: 14px; font-size: 14px;
line-height: 24px; line-height: 24px;
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
border-radius: $radius; border-radius: $radius;
} }
@mixin border-radius-left($radius) {
@include border-radius($radius 0 0 $radius)
}
@mixin linear-gradient($from, $to) { @mixin linear-gradient($from, $to) {
background-image: -webkit-gradient(linear, 0 0, 0 100%, from($from), to($to)); background-image: -webkit-gradient(linear, 0 0, 0 100%, from($from), to($to));
background-image: -webkit-linear-gradient($from, $to); background-image: -webkit-linear-gradient($from, $to);
......
...@@ -84,14 +84,23 @@ ...@@ -84,14 +84,23 @@
.label-branch { .label-branch {
@include border-radius(4px); @include border-radius(4px);
padding: 2px 4px; padding: 3px 4px;
border: none; border: none;
font-size: 14px; font-size: 14px;
background: #474D57; background: #474D57;
color: #fff; color: #fff;
font-family: $monospace_font; font-family: $monospace_font;
text-shadow: 0 1px 1px #111;
font-weight: normal; font-weight: normal;
overflow: hidden;
.label-project {
@include border-radius-left(4px);
padding: 3px 4px;
background: #29A;
position: relative;
left: -4px;
letter-spacing: -1px;
}
} }
.mr-list { .mr-list {
......
...@@ -12,7 +12,7 @@ class FilterContext ...@@ -12,7 +12,7 @@ class FilterContext
def apply_filter items def apply_filter items
if params[:project_id].present? if params[:project_id].present?
items = items.where(project_id: params[:project_id]) items = items.of_projects(params[:project_id])
end end
if params[:search].present? if params[:search].present?
......
...@@ -21,6 +21,7 @@ module Issuable ...@@ -21,6 +21,7 @@ module Issuable
scope :recent, -> { order("created_at DESC") } scope :recent, -> { order("created_at DESC") }
scope :assigned, -> { where("assignee_id IS NOT NULL") } scope :assigned, -> { where("assignee_id IS NOT NULL") }
scope :unassigned, -> { where("assignee_id IS NULL") } scope :unassigned, -> { where("assignee_id IS NULL") }
scope :of_projects, ->(ids) { where(project_id: ids) }
delegate :name, delegate :name,
:email, :email,
......
...@@ -27,7 +27,6 @@ class Issue < ActiveRecord::Base ...@@ -27,7 +27,6 @@ class Issue < ActiveRecord::Base
scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) } scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) }
scope :opened, -> { with_state(:opened) } scope :opened, -> { with_state(:opened) }
scope :closed, -> { with_state(:closed) } scope :closed, -> { with_state(:closed) }
scope :by_project, ->(project_id) {where(project_id:project_id)}
attr_accessible :title, :assignee_id, :position, :description, attr_accessible :title, :assignee_id, :position, :description,
:milestone_id, :label_list, :author_id_of_changes, :milestone_id, :label_list, :author_id_of_changes,
......
...@@ -93,8 +93,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -93,8 +93,8 @@ class MergeRequest < ActiveRecord::Base
scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) } scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) }
scope :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) } scope :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) }
scope :by_milestone, ->(milestone) { where(milestone_id: milestone) } scope :by_milestone, ->(milestone) { where(milestone_id: milestone) }
scope :by_project, ->(project_id) { where("source_project_id = :project_id OR target_project_id = :project_id", project_id: project_id) }
scope :in_projects, ->(project_ids) { where("source_project_id in (:project_ids) OR target_project_id in (:project_ids)", project_ids: project_ids) } scope :in_projects, ->(project_ids) { where("source_project_id in (:project_ids) OR target_project_id in (:project_ids)", project_ids: project_ids) }
scope :of_projects, ->(ids) { where(target_project_id: ids) }
# Closed scope for merge request should return # Closed scope for merge request should return
# both merged and closed mr's # both merged and closed mr's
scope :closed, -> { with_states(:closed, :merged) } scope :closed, -> { with_states(:closed, :merged) }
......
...@@ -9,12 +9,14 @@ ...@@ -9,12 +9,14 @@
- else - else
%span.pull-right %span.pull-right
- if merge_request.for_fork? - if merge_request.for_fork?
= "#{merge_request.source_project.path_with_namespace}/#{merge_request.source_branch}" %span.light
%i.icon-angle-right = "#{merge_request.source_project.path_with_namespace}"
= "#{merge_request.target_project.path_with_namespace}/#{merge_request.target_branch}" = "#{merge_request.source_branch}"
%i.icon-angle-right.light
= "#{merge_request.target_branch}"
- else - else
= "#{merge_request.source_branch}" = "#{merge_request.source_branch}"
%i.icon-angle-right %i.icon-angle-right.light
= "#{merge_request.target_branch}" = "#{merge_request.target_branch}"
.merge-request-info .merge-request-info
- if merge_request.author - if merge_request.author
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
= "Merge Request ##{@merge_request.id}:" = "Merge Request ##{@merge_request.id}:"
&nbsp; &nbsp;
-if @merge_request.for_fork? -if @merge_request.for_fork?
%span.label-project= truncate(@merge_request.source_project.path_with_namespace, length: 25) %span.label-branch
%span.label-branch= @merge_request.source_branch %span.label-project= truncate(@merge_request.source_project.path_with_namespace, length: 25)
#{@merge_request.source_branch}
&rarr; &rarr;
%span.label-project= truncate(@merge_request.target_project.path_with_namespace, length: 25)
%span.label-branch= @merge_request.target_branch %span.label-branch= @merge_request.target_branch
- else - else
%span.label-branch= @merge_request.source_branch %span.label-branch= @merge_request.source_branch
......
...@@ -21,17 +21,19 @@ describe FilterContext do ...@@ -21,17 +21,19 @@ describe FilterContext do
merge_request3 merge_request3
merge_request4 merge_request4
end end
it 'should by default filter properly' do it 'should by default filter properly' do
merge_requests = user.cared_merge_requests merge_requests = user.cared_merge_requests
params ={} params ={}
merge_requests = FilterContext.new(merge_requests, params).execute merge_requests = FilterContext.new(merge_requests, params).execute
merge_requests.size.should == 3 merge_requests.size.should == 3
end end
it 'should apply blocks passed in on creation to the filters' do it 'should apply blocks passed in on creation to the filters' do
merge_requests = user.cared_merge_requests merge_requests = user.cared_merge_requests
params = {:project_id => project1.id} params = {:project_id => project1.id}
merge_requests = FilterContext.new(merge_requests, params).execute merge_requests = FilterContext.new(merge_requests, params).execute
merge_requests.size.should == 2 merge_requests.size.should == 1
end end
end end
...@@ -54,4 +56,4 @@ describe FilterContext do ...@@ -54,4 +56,4 @@ describe FilterContext do
issues.size.should == 1 issues.size.should == 1
end end
end end
end end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment