diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 47ec5f5a..3a5af7c6 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -49,3 +49,4 @@ .no-padding { padding:0 !important; } + diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index fb37d6cd..4f3e9894 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -426,3 +426,39 @@ body.project-page table.no-borders tr, body.project-page table.no-borders td{ border:none; } + +#gitlab-tabs { + .ui-tabs-nav { + border-bottom: 1px solid #DEDFE1; + + li { + background: none; + border:none; + font-size: 16px; + margin: 0; + padding: 0; + + a { + margin: 0; + padding: 10px 16px; + width:150px; + } + + &.ui-tabs-selected { + background-image: -webkit-gradient(linear, 0 0, 0 26, color-stop(0.076, #fefefe), to(#F6F7F8)); + background-image: -webkit-linear-gradient(#fefefe 7.6%, #F6F7F8); + background-image: -moz-linear-gradient(#fefefe 7.6%, #F6F7F8); + background-image: -o-linear-gradient(#fefefe 7.6%, #F6F7F8); + font-weight: bold; + border:1px solid #DEDFE1; + border-bottom: 1px solid #DEDFE1; + -webkit-border-top-left-radius: 5px; + -webkit-border-top-right-radius: 5px; + -moz-border-radius-topleft: 5px; + -moz-border-radius-topright: 5px; + border-top-left-radius: 5px; + border-top-right-radius: 5px; + } + } + } +} diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index 92387160..c83423ed 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -1,7 +1,7 @@ class MergeRequestsController < ApplicationController before_filter :authenticate_user! before_filter :project - before_filter :merge_request, :only => [:edit, :update, :destroy, :show] + before_filter :merge_request, :only => [:edit, :update, :destroy, :show, :commits, :diffs] layout "project" # Authorize @@ -19,7 +19,24 @@ class MergeRequestsController < ApplicationController head(404)and return end + @notes = @merge_request.notes.inc_author.order("created_at DESC").limit(20) + @note = @project.notes.new(:noteable => @merge_request) + + respond_to do |format| + format.html + format.js { respond_with_notes } + end + end + + def commits @commits = @project.repo.commits_between(@merge_request.target_branch, @merge_request.source_branch).map {|c| Commit.new(c)} + render :template => "merge_requests/_commits", :layout => false + end + + def diffs + @commit = @project.commit(@merge_request.source_branch) + @diffs = @project.repo.diff(@merge_request.target_branch, @merge_request.source_branch) + render :template => "merge_requests/_diffs", :layout => false end def new diff --git a/app/views/merge_requests/_commits.html.haml b/app/views/merge_requests/_commits.html.haml new file mode 100644 index 00000000..508aa231 --- /dev/null +++ b/app/views/merge_requests/_commits.html.haml @@ -0,0 +1,17 @@ +- if @commits.size > 0 + .merge-request-commits.ui-box.width-100p + - @commits.each do |commit| + %a{ :class => "commit", :href => project_commit_path(@project, :id => commit.id) } + - if commit.author_email + = image_tag gravatar_icon(commit.author_email), :class => "left", :width => 40, :style => "padding-right:5px;" + - else + = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" + %span.update-title + = truncate commit.safe_message, :length => 60 + %span.update-author + %strong= commit.author_name + authored + = time_ago_in_words(commit.created_at) + ago + .clear + diff --git a/app/views/merge_requests/_diffs.html.haml b/app/views/merge_requests/_diffs.html.haml new file mode 100644 index 00000000..eb44de68 --- /dev/null +++ b/app/views/merge_requests/_diffs.html.haml @@ -0,0 +1,22 @@ +- @diffs.each do |diff| + - next if diff.diff.empty? + - file = (@commit.tree / diff.b_path) + - next unless file + .diff_file + .diff_file_header + - if diff.deleted_file + %strong{:id => "#{diff.b_path}"}= diff.a_path + - else + = link_to tree_file_project_ref_path(@project, @commit.id, diff.b_path) do + %strong{:id => "#{diff.b_path}"}= diff.b_path + %br/ + .diff_file_content + - if file.text? + = render :partial => "commits/text_file", :locals => { :diff => diff } + - elsif file.image? + .diff_file_content_image + %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} + - else + %p + %center No preview for this file type + diff --git a/app/views/merge_requests/_form.html.haml b/app/views/merge_requests/_form.html.haml index 8c0ca202..d0848e64 100644 --- a/app/views/merge_requests/_form.html.haml +++ b/app/views/merge_requests/_form.html.haml @@ -18,11 +18,11 @@ %td= f.label :title %td= f.text_field :title %tr - %td= f.label :target_branch, "From" - %td= f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }) - %tr - %td= f.label :source_branch, "To" + %td= f.label :source_branch, "From" %td= f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }) + %tr + %td= f.label :target_branch, "To" + %td= f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }) %tr %td= f.label :assignee_id, "Assign to" %td= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) diff --git a/app/views/merge_requests/show.html.haml b/app/views/merge_requests/show.html.haml index 5ee56cae..96afb47a 100644 --- a/app/views/merge_requests/show.html.haml +++ b/app/views/merge_requests/show.html.haml @@ -40,20 +40,20 @@ %br %br +#gitlab-tabs + %ul + %li= link_to "Notes", "#merge-notes" + %li= link_to "Commits", commits_project_merge_request_path(@project, @merge_request) + %li= link_to "Diff", diffs_project_merge_request_path(@project, @merge_request) -- if @commits.size > 0 - .merge-request-commits.ui-box.width-100p - - @commits.each do |commit| - %a{ :class => "commit", :href => project_commit_path(@project, :id => commit.id) } - - if commit.author_email - = image_tag gravatar_icon(commit.author_email), :class => "left", :width => 40, :style => "padding-right:5px;" - - else - = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" - %span.update-title - = commit.id.to_s - %span.update-author - %strong= commit.author_name - authored - = time_ago_in_words(commit.created_at) - ago - .clear + #merge-notes + .issue_notes= render "notes/notes" + .loading{ :style => "display:none;"} + %center= image_tag "ajax-loader.gif" + .clear + + +:javascript + $(function(){ + $("#gitlab-tabs").tabs(); + }) diff --git a/config/routes.rb b/config/routes.rb index 1426d5f2..c74cf226 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -59,7 +59,12 @@ Gitlab::Application.routes.draw do end end - resources :merge_requests + resources :merge_requests do + member do + get :diffs + get :commits + end + end resources :snippets resources :commits resources :team_members