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 {
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 {
font-size: 14px;
line-height: 24px;
......
......@@ -17,6 +17,10 @@
border-radius: $radius;
}
@mixin border-radius-left($radius) {
@include border-radius($radius 0 0 $radius)
}
@mixin linear-gradient($from, $to) {
background-image: -webkit-gradient(linear, 0 0, 0 100%, from($from), to($to));
background-image: -webkit-linear-gradient($from, $to);
......
......@@ -84,14 +84,23 @@
.label-branch {
@include border-radius(4px);
padding: 2px 4px;
padding: 3px 4px;
border: none;
font-size: 14px;
background: #474D57;
color: #fff;
font-family: $monospace_font;
text-shadow: 0 1px 1px #111;
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 {
......
......@@ -12,7 +12,7 @@ class FilterContext
def apply_filter items
if params[:project_id].present?
items = items.where(project_id: params[:project_id])
items = items.of_projects(params[:project_id])
end
if params[:search].present?
......
......@@ -21,6 +21,7 @@ module Issuable
scope :recent, -> { order("created_at DESC") }
scope :assigned, -> { where("assignee_id IS NOT NULL") }
scope :unassigned, -> { where("assignee_id IS NULL") }
scope :of_projects, ->(ids) { where(project_id: ids) }
delegate :name,
:email,
......
......@@ -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 :opened, -> { with_state(:opened) }
scope :closed, -> { with_state(:closed) }
scope :by_project, ->(project_id) {where(project_id:project_id)}
attr_accessible :title, :assignee_id, :position, :description,
:milestone_id, :label_list, :author_id_of_changes,
......
......@@ -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 :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) }
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 :of_projects, ->(ids) { where(target_project_id: ids) }
# Closed scope for merge request should return
# both merged and closed mr's
scope :closed, -> { with_states(:closed, :merged) }
......
......@@ -9,12 +9,14 @@
- else
%span.pull-right
- if merge_request.for_fork?
= "#{merge_request.source_project.path_with_namespace}/#{merge_request.source_branch}"
%i.icon-angle-right
= "#{merge_request.target_project.path_with_namespace}/#{merge_request.target_branch}"
%span.light
= "#{merge_request.source_project.path_with_namespace}"
= "#{merge_request.source_branch}"
%i.icon-angle-right.light
= "#{merge_request.target_branch}"
- else
= "#{merge_request.source_branch}"
%i.icon-angle-right
%i.icon-angle-right.light
= "#{merge_request.target_branch}"
.merge-request-info
- if merge_request.author
......
......@@ -2,10 +2,10 @@
= "Merge Request ##{@merge_request.id}:"
&nbsp;
-if @merge_request.for_fork?
%span.label-project= truncate(@merge_request.source_project.path_with_namespace, length: 25)
%span.label-branch= @merge_request.source_branch
%span.label-branch
%span.label-project= truncate(@merge_request.source_project.path_with_namespace, length: 25)
#{@merge_request.source_branch}
&rarr;
%span.label-project= truncate(@merge_request.target_project.path_with_namespace, length: 25)
%span.label-branch= @merge_request.target_branch
- else
%span.label-branch= @merge_request.source_branch
......
......@@ -21,17 +21,19 @@ describe FilterContext do
merge_request3
merge_request4
end
it 'should by default filter properly' do
merge_requests = user.cared_merge_requests
params ={}
merge_requests = FilterContext.new(merge_requests, params).execute
merge_requests.size.should == 3
end
it 'should apply blocks passed in on creation to the filters' do
merge_requests = user.cared_merge_requests
params = {:project_id => project1.id}
merge_requests = FilterContext.new(merge_requests, params).execute
merge_requests.size.should == 2
merge_requests.size.should == 1
end
end
......@@ -54,4 +56,4 @@ describe FilterContext do
issues.size.should == 1
end
end
end
\ No newline at end of file
end
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