diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-01-11 02:52:25 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-01-28 01:20:18 +0300 |
commit | aeb9db6753cfdd56f82d80c0e2c01f63d65b705d (patch) | |
tree | 07dd8fea47384355ae52e6943bd15267b4765ee3 /app | |
parent | ac66268443b05029cbc45cc358f62b764f1ff165 (diff) |
Present group and dashboard MR list without grouping by project
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/dashboard_controller.rb | 5 | ||||
-rw-r--r-- | app/models/issue.rb | 4 | ||||
-rw-r--r-- | app/models/project.rb | 27 | ||||
-rw-r--r-- | app/views/projects/issues/_issue.html.haml | 7 | ||||
-rw-r--r-- | app/views/projects/merge_requests/_merge_request.html.haml | 3 | ||||
-rw-r--r-- | app/views/shared/_merge_requests.html.haml | 14 |
6 files changed, 24 insertions, 36 deletions
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 4dda4e51f6a..79d420a32d3 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -4,6 +4,7 @@ class DashboardController < Dashboard::ApplicationController before_action :event_filter, only: :activity before_action :projects, only: [:issues, :merge_requests] + before_action :set_show_full_reference, only: [:issues, :merge_requests] respond_to :html @@ -34,4 +35,8 @@ class DashboardController < Dashboard::ApplicationController @events = @event_filter.apply_filter(@events).with_associations @events = @events.limit(20).offset(params[:offset] || 0) end + + def set_show_full_reference + @show_full_reference = true + end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 41cca47b015..ab7473d23c3 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -97,10 +97,10 @@ class Issue < ActiveRecord::Base end end - def to_reference(from = nil, full_path: false) + def to_reference(from = nil, full: false) reference = "#{self.class.reference_prefix}#{iid}" - "#{project.to_reference(from, full_path: full_path)}#{reference}" + "#{project.to_reference(from, full: full)}#{reference}" end def referenced_merge_requests(current_user = nil) diff --git a/app/models/project.rb b/app/models/project.rb index 52df648ede6..23b98916b2e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -591,10 +591,12 @@ class Project < ActiveRecord::Base end end - def to_reference(from = nil, full_path: false) - return path_with_namespace if full_path - - path_from(from) + def to_reference(from = nil, full: false) + if full || cross_namespace_reference?(from) + path_with_namespace + elsif cross_project_reference?(from) + path + end end def to_human_reference(from_project = nil) @@ -1289,19 +1291,12 @@ class Project < ActiveRecord::Base 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) - if from.is_a?(Project) - from && namespace != from.namespace - else - from && namespace != from + case from + when Project + namespace != from.namespace + when Namespace + namespace != from end end diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml index 6cfbab92f0f..6173d9e21f6 100644 --- a/app/views/projects/issues/_issue.html.haml +++ b/app/views/projects/issues/_issue.html.haml @@ -34,13 +34,8 @@ = note_count .issue-info - - if controller_name == "dashboard" - #{issue.to_reference(full_path: true)} - - else - #{issue.to_reference(@group || @project)} - + = @show_full_reference ? issue.to_reference(full: true) : issue.to_reference(@group || @project) · - opened #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')} by #{link_to_member(@project, issue.author, avatar: false)} - if issue.milestone diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index e3b0aa7e644..a1e6d09612c 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -46,7 +46,8 @@ = note_count .merge-request-info - #{merge_request.to_reference} · + = @show_full_reference ? merge_request.to_reference(full: true) : merge_request.to_reference(@group || @project) + · opened #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')} by #{link_to_member(@project, merge_request.author, avatar: false)} - if merge_request.target_project.default_branch != merge_request.target_branch diff --git a/app/views/shared/_merge_requests.html.haml b/app/views/shared/_merge_requests.html.haml index 2f3605b4d27..773f71802c0 100644 --- a/app/views/shared/_merge_requests.html.haml +++ b/app/views/shared/_merge_requests.html.haml @@ -1,16 +1,8 @@ - if @merge_requests.to_a.any? - - @merge_requests.group_by(&:target_project).each do |group| - .panel.panel-default.panel-small - - project = group[0] - .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) + .panel.panel-default.panel-small + %ul.content-list.mr-list + = render partial: 'projects/merge_requests/merge_request', collection: @merge_requests - %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" - else |