Commit aeb9db67 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Present group and dashboard MR list without grouping by project

parent ac662684
...@@ -4,6 +4,7 @@ class DashboardController < Dashboard::ApplicationController ...@@ -4,6 +4,7 @@ class DashboardController < Dashboard::ApplicationController
before_action :event_filter, only: :activity before_action :event_filter, only: :activity
before_action :projects, only: [:issues, :merge_requests] before_action :projects, only: [:issues, :merge_requests]
before_action :set_show_full_reference, only: [:issues, :merge_requests]
respond_to :html respond_to :html
...@@ -34,4 +35,8 @@ class DashboardController < Dashboard::ApplicationController ...@@ -34,4 +35,8 @@ class DashboardController < Dashboard::ApplicationController
@events = @event_filter.apply_filter(@events).with_associations @events = @event_filter.apply_filter(@events).with_associations
@events = @events.limit(20).offset(params[:offset] || 0) @events = @events.limit(20).offset(params[:offset] || 0)
end end
def set_show_full_reference
@show_full_reference = true
end
end end
...@@ -97,10 +97,10 @@ class Issue < ActiveRecord::Base ...@@ -97,10 +97,10 @@ class Issue < ActiveRecord::Base
end end
end end
def to_reference(from = nil, full_path: false) def to_reference(from = nil, full: false)
reference = "#{self.class.reference_prefix}#{iid}" reference = "#{self.class.reference_prefix}#{iid}"
"#{project.to_reference(from, full_path: full_path)}#{reference}" "#{project.to_reference(from, full: full)}#{reference}"
end end
def referenced_merge_requests(current_user = nil) def referenced_merge_requests(current_user = nil)
......
...@@ -591,10 +591,12 @@ class Project < ActiveRecord::Base ...@@ -591,10 +591,12 @@ class Project < ActiveRecord::Base
end end
end end
def to_reference(from = nil, full_path: false) def to_reference(from = nil, full: false)
return path_with_namespace if full_path if full || cross_namespace_reference?(from)
path_with_namespace
path_from(from) elsif cross_project_reference?(from)
path
end
end end
def to_human_reference(from_project = nil) def to_human_reference(from_project = nil)
...@@ -1289,19 +1291,12 @@ class Project < ActiveRecord::Base ...@@ -1289,19 +1291,12 @@ class Project < ActiveRecord::Base
private private
def path_from(from)
if cross_namespace_reference?(from)
path_with_namespace
elsif cross_project_reference?(from)
path
end
end
def cross_namespace_reference?(from) def cross_namespace_reference?(from)
if from.is_a?(Project) case from
from && namespace != from.namespace when Project
else namespace != from.namespace
from && namespace != from when Namespace
namespace != from
end end
end end
......
...@@ -34,13 +34,8 @@ ...@@ -34,13 +34,8 @@
= note_count = note_count
.issue-info .issue-info
- if controller_name == "dashboard" = @show_full_reference ? issue.to_reference(full: true) : issue.to_reference(@group || @project)
#{issue.to_reference(full_path: true)}
- else
#{issue.to_reference(@group || @project)}
&middot; &middot;
opened #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')} opened #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')}
by #{link_to_member(@project, issue.author, avatar: false)} by #{link_to_member(@project, issue.author, avatar: false)}
- if issue.milestone - if issue.milestone
......
...@@ -46,7 +46,8 @@ ...@@ -46,7 +46,8 @@
= note_count = note_count
.merge-request-info .merge-request-info
#{merge_request.to_reference} &middot; = @show_full_reference ? merge_request.to_reference(full: true) : merge_request.to_reference(@group || @project)
&middot;
opened #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')} opened #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')}
by #{link_to_member(@project, merge_request.author, avatar: false)} by #{link_to_member(@project, merge_request.author, avatar: false)}
- if merge_request.target_project.default_branch != merge_request.target_branch - if merge_request.target_project.default_branch != merge_request.target_branch
......
- if @merge_requests.to_a.any? - if @merge_requests.to_a.any?
- @merge_requests.group_by(&:target_project).each do |group| .panel.panel-default.panel-small
.panel.panel-default.panel-small %ul.content-list.mr-list
- project = group[0] = render partial: 'projects/merge_requests/merge_request', collection: @merge_requests
.panel-heading
= link_to project.name_with_namespace, namespace_project_merge_requests_path(project.namespace, project)
- if can?(current_user, :create_merge_request, project)
.pull-right
= link_to 'New merge request', new_namespace_project_merge_request_path(project.namespace, project)
%ul.content-list.mr-list
- group[1].each do |merge_request|
= render 'projects/merge_requests/merge_request', merge_request: merge_request
= paginate @merge_requests, theme: "gitlab" = paginate @merge_requests, theme: "gitlab"
- else - else
......
...@@ -34,11 +34,11 @@ describe Issue, models: true do ...@@ -34,11 +34,11 @@ describe Issue, models: true do
end end
end end
context 'when full_path is true' do context 'when full is true' do
it 'returns complete path to the issue' do it 'returns complete path to the issue' do
expect(issue.to_reference(full_path: true)).to eq 'sample-namespace/sample-project#1' expect(issue.to_reference(full: true)).to eq 'sample-namespace/sample-project#1'
expect(issue.to_reference(project, full_path: true)).to eq 'sample-namespace/sample-project#1' expect(issue.to_reference(project, full: true)).to eq 'sample-namespace/sample-project#1'
expect(issue.to_reference(group, full_path: true)).to eq 'sample-namespace/sample-project#1' expect(issue.to_reference(group, full: true)).to eq 'sample-namespace/sample-project#1'
end end
end end
......
...@@ -293,11 +293,11 @@ describe Project, models: true do ...@@ -293,11 +293,11 @@ describe Project, models: true do
end end
end end
context 'when full_path is true' do context 'when full is true' do
it 'returns complete path to the project' do it 'returns complete path to the project' do
expect(project.to_reference(full_path: true)).to eq 'sample-namespace/sample-project' expect(project.to_reference(full: true)).to eq 'sample-namespace/sample-project'
expect(project.to_reference(project, full_path: true)).to eq 'sample-namespace/sample-project' expect(project.to_reference(project, full: true)).to eq 'sample-namespace/sample-project'
expect(project.to_reference(group, full_path: true)).to eq 'sample-namespace/sample-project' expect(project.to_reference(group, full: true)).to eq 'sample-namespace/sample-project'
end end
end 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