Commit 6c47bcef authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'refactor_merge_requests'

parents 713802fd e8860594
[Dolphin] [Dolphin]
ShowPreview=true ShowPreview=true
Timestamp=2011,10,28,13,16,25 Timestamp=2011,12,13,12,22,12
Version=2 Version=2
var MergeRequest = {
diffs_loaded: false,
commits_loaded: false,
init:
function() {
$(".merge-tabs a").live("click", function() {
$(".merge-tabs a").removeClass("active");
$(this).addClass("active");
});
$(".merge-tabs a.merge-notes-tab").live("click", function() {
$(".merge-request-commits, .merge-request-diffs").hide();
$(".merge-request-notes").show();
});
$(".merge-tabs a.merge-commits-tab").live("click", function() {
if(!MergeRequest.commits_loaded) {
MergeRequest.loadCommits();
}
$(".merge-request-notes, .merge-request-diffs").hide();
$(".merge-request-commits").show();
});
$(".merge-tabs a.merge-diffs-tab").live("click", function() {
if(!MergeRequest.diffs_loaded) {
MergeRequest.loadDiff();
}
$(".merge-request-notes, .merge-request-commits").hide();
$(".merge-request-diffs").show();
});
},
loadCommits:
function() {
$(".dashboard-loader").show();
$.ajax({
type: "GET",
url: $(".merge-commits-tab").attr("data-url"),
complete: function(){
MergeRequest.commits_loaded = true;
$(".merge-request-notes, .merge-request-diffs").hide();
$(".dashboard-loader").hide()},
dataType: "script"});
},
loadDiff:
function() {
$(".dashboard-loader").show();
$.ajax({
type: "GET",
url: $(".merge-diffs-tab").attr("data-url"),
complete: function(){
MergeRequest.diffs_loaded = true;
$(".merge-request-notes, .merge-request-commits").hide();
$(".dashboard-loader").hide()},
dataType: "script"});
}
}
...@@ -438,42 +438,6 @@ body.project-page table.no-borders td{ ...@@ -438,42 +438,6 @@ body.project-page table.no-borders td{
border:none; 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;
}
}
}
}
.ajax-tab-loading { .ajax-tab-loading {
padding:40px; padding:40px;
display:none; display:none;
...@@ -587,3 +551,82 @@ h4.middle-panel { ...@@ -587,3 +551,82 @@ h4.middle-panel {
margin-right:30px; margin-right:30px;
display:none; display:none;
} }
.merge-tabs {
margin: 0;
border: 1px solid #ccc;
padding: 5px;
font-size: 12px;
background: #F7F7F7;
margin-bottom:20px;
height:26px;
.tab {
font-weight: bold;
text-transform: uppercase;
border-right: 1px solid #ddd;
background:none;
padding: 10px;
width:60px;
float:left;
position:relative;
top:-5px;
left:-5px;
height:16px;
padding-left:34px;
span {
width: 20px;
height: 20px;
display: inline-block;
position: absolute;
left: 8px;
top: 8px;
}
&.active {
background: #eaeaea;
}
}
}
.merge-notes-tab span { background: url("images.png") no-repeat -161px -1px; }
.merge-commits-tab span { background: url("images.png") no-repeat -86px 1px; }
.merge-diffs-tab span { background: url("images.png") no-repeat -118px 1px; }
.merge-tabs .dashboard-loader { padding:8px; }
.user-mention {
color: #2FA0BB;
font-weight: bold;
}
.author {
color: #999;
}
.red-button{
border-radius: 5px;
font-size: 12px;
font-weight: bold;
padding: 5px 17px;
border: 1px solid #999;
color: #666;
display: inline-block;
box-shadow: 0 1px 2px rgba(0,0,0,.3);
background: #D12F19;
color: white;
}
.positive-button{
border-radius: 5px;
font-size: 12px;
font-weight: bold;
padding: 5px 17px;
border: 1px solid #999;
color: #666;
display: inline-block;
box-shadow: 0 1px 2px rgba(0,0,0,.3);
background: #4A2;
color: white;
}
...@@ -130,7 +130,7 @@ table tr:hover, .listed_items tr.odd:hover{background-color:#FFFFCF} ...@@ -130,7 +130,7 @@ table tr:hover, .listed_items tr.odd:hover{background-color:#FFFFCF}
border-radius: 5px; border-radius: 5px;
font-size: 12px; font-size: 12px;
font-weight: bold; font-weight: bold;
padding: 6px 20px; padding: 5px 17px;
border: 1px solid #999; border: 1px solid #999;
color: #666; color: #666;
display: inline-block; display: inline-block;
......
...@@ -30,14 +30,11 @@ class MergeRequestsController < ApplicationController ...@@ -30,14 +30,11 @@ class MergeRequestsController < ApplicationController
def commits def commits
@commits = @project.repo.commits_between(@merge_request.target_branch, @merge_request.source_branch).map {|c| Commit.new(c)} @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 end
def diffs def diffs
@diffs = @merge_request.diffs @diffs = @merge_request.diffs
@commit = @merge_request.last_commit @commit = @merge_request.last_commit
render :template => "merge_requests/_diffs", :layout => false
end end
def new def new
......
...@@ -90,6 +90,10 @@ class Project < ActiveRecord::Base ...@@ -90,6 +90,10 @@ class Project < ActiveRecord::Base
users_projects.find_by_user_id(user.id) if user users_projects.find_by_user_id(user.id) if user
end end
def team_member_by_id(user_id)
users_projects.find_by_user_id(user_id)
end
def fresh_issues(n) def fresh_issues(n)
issues.includes(:project, :author).order("created_at desc").first(n) issues.includes(:project, :author).order("created_at desc").first(n)
end end
......
%div.merge-request-form-holder = form_for [@project, @merge_request] do |f|
.ui-box.width-100p %div
%h3 %span.entity-info
= @merge_request.new_record? ? "New Merge Request" : "Edit Merge Request ##{@merge_request.id}" - if @merge_request.new_record?
= form_for [@project, @merge_request] do |f| = link_to project_merge_requests_path(@project) do
.data .entity-button
Back
%i
- else
= link_to project_merge_request_path(@project, @merge_request) do
.entity-button
Back
%i
%h2= @merge_request.new_record? ? "New Merge Request" : "Edit Merge Request ##{@merge_request.id}"
%hr
%table.no-borders %table.no-borders
-if @merge_request.errors.any? -if @merge_request.errors.any?
%tr %tr
%td Errors %td{:colspan => 2}
%td
#error_explanation #error_explanation
- @merge_request.errors.full_messages.each do |msg| - @merge_request.errors.full_messages.each do |msg|
%span= msg %span= msg
%br %br
%tr
%td= f.label :title
%td= f.text_field :title
%tr %tr
%td= f.label :source_branch, "From" %td= f.label :source_branch, "From"
%td= f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }) %td= f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
%tr %tr
%td= f.label :target_branch, "To" %td= f.label :target_branch, "To"
%td= f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }) %td= f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
%tr %tr
%td= f.label :assignee_id, "Assign to" %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" }) %td= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }, :style => "width:250px")
.buttons = f.text_area :title, :style => "width:718px; height:100px", :maxlength => 255
%br
%br
.merge-tabs
= f.submit 'Save', :class => "grey-button" = f.submit 'Save', :class => "grey-button"
.right= link_to 'Back', project_merge_requests_path(@project), :class => "grey-button" &nbsp;
- unless @merge_request.new_record?
.right
= link_to 'Remove', [@project, @merge_request], :confirm => 'Are you sure?', :method => :delete, :class => "red-button"
:javascript :javascript
$(function(){ $(function(){
......
%a.update-item{:href => project_merge_request_path(merge_request.project, merge_request)} %a.update-item{:href => project_merge_request_path(merge_request.project, merge_request)}
= image_tag gravatar_icon(merge_request.author_email), :class => "left", :width => 40 = image_tag gravatar_icon(merge_request.author_email), :class => "left", :width => 40
%span.update-title %span.update-title
= merge_request.title = truncate(merge_request.title, :length => 60)
%span.update-author %span.update-author
%strong= merge_request.author_name %strong= merge_request.author_name
authored authored
......
:plain
$(".merge-request-commits").html("#{escape_javascript(render(:partial => "commits"))}");
:plain
$(".merge-request-diffs").html("#{escape_javascript(render(:partial => "diffs"))}");
.merge-request-show-holder.ui-box.width-100p %div
%h3 %span.entity-info
- if can?(current_user, :admin_project, @project) || @merge_request.author == current_user
= link_to edit_project_merge_request_path(@project, @merge_request) do
.entity-button
Edit Merge Request
%i
= image_tag gravatar_icon(@merge_request.author_email), :class => "left", :width => 40, :style => "padding-right:5px;"
%span.commit-title
%strong
= "Merge Request ##{@merge_request.id}:" = "Merge Request ##{@merge_request.id}:"
&nbsp; &nbsp;
.tag.commit.inline= @merge_request.source_branch .tag.commit.inline= @merge_request.source_branch
&rarr; &rarr;
.tag.commit.inline= @merge_request.target_branch .tag.commit.inline= @merge_request.target_branch
.right %span.commit-author
- if @merge_request.closed %strong
%span.tag.high Closed = link_to project_team_member_path(@project, @project.team_member_by_id(@merge_request.author.id)) do
- else %span.author= @merge_request.author_name
%span.tag.today Open
.data
%p= @merge_request.title
- if @merge_request.author == @merge_request.assignee
= image_tag gravatar_icon(@merge_request.assignee_email), :width => 20, :style => "padding:0 5px;"
= @merge_request.assignee_name
- else
= image_tag gravatar_icon(@merge_request.author_email), :width => 20, :style => "padding:0 5px;"
= @merge_request.author_name
&rarr; &rarr;
= image_tag gravatar_icon(@merge_request.assignee_email), :width => 20, :style => "padding:0 5px;" = link_to project_team_member_path(@project, @project.team_member_by_id(@merge_request.assignee.id)) do
= @merge_request.assignee_name %span.author= @merge_request.assignee_name
.right
%cite.cgray= @merge_request.created_at.stamp("21 Aug 2011, 11:15pm")
.clear
.buttons &nbsp;
- if can? current_user, :write_project, @project &nbsp;
- if @merge_request.closed = @merge_request.created_at.stamp("Aug 21, 2011 9:23pm")
= link_to 'Reopen', project_merge_request_path(@project, @merge_request, :merge_request => {:closed => false }, :status_only => true), :method => :put, :class => "grey-button"
- else %hr
= link_to 'Close', project_merge_request_path(@project, @merge_request, :merge_request => {:closed => true }, :status_only => true), :method => :put, :class => "grey-button" %br
.right %h3
= link_to 'Edit', edit_project_merge_request_path(@project, @merge_request), :class => "grey-button positive" = simple_format @merge_request.title
.clear .clear
%br %br
%br %br
#gitlab-tabs .merge-tabs
%ul = link_to "#notes", :class => "merge-notes-tab active tab" do
%li= link_to "Notes", "#merge-notes" %span
%li= link_to "Commits", commits_project_merge_request_path(@project, @merge_request) Notes
%li= link_to "Diff", diffs_project_merge_request_path(@project, @merge_request) = link_to "#commits", "data-url" => commits_project_merge_request_path(@project, @merge_request), :class => "merge-commits-tab tab" do
%span
Commits
= link_to "#diffs", "data-url" => diffs_project_merge_request_path(@project, @merge_request), :class => "merge-diffs-tab tab" do
%span
Diff
#merge-notes - if can?(current_user, :admin_project, @project) || @merge_request.author == current_user
.right
- if @merge_request.closed
= link_to 'Reopen', project_merge_request_path(@project, @merge_request, :merge_request => {:closed => false }, :status_only => true), :method => :put, :class => "red-button"
- else
= link_to 'Close', project_merge_request_path(@project, @merge_request, :merge_request => {:closed => true }, :status_only => true), :method => :put, :class => "positive-button", :title => "Close merge request"
%img{:src => "/assets/ajax-loader-facebook.gif", :class => "dashboard-loader"}
.merge-request-notes
.issue_notes= render "notes/notes" .issue_notes= render "notes/notes"
.loading{ :style => "display:none;"} .loading{ :style => "display:none;"}
%center= image_tag "ajax-loader.gif" %center= image_tag "ajax-loader.gif"
.clear .clear
.merge-request-commits
.merge-request-diffs
:javascript :javascript
$(function(){ $(function(){
$("#gitlab-tabs").tabs(); MergeRequest.init();
}) })
...@@ -42,8 +42,8 @@ describe "MergeRequests" do ...@@ -42,8 +42,8 @@ describe "MergeRequests" do
it { should have_content(@merge_request.title) } it { should have_content(@merge_request.title) }
it "Show page should inform user that merge request closed" do it "Show page should inform user that merge request closed" do
within ".merge-request-show-holder h3" do within ".merge-tabs" do
page.should have_content "Closed" page.should have_content "Reopen"
end end
end end
end end
...@@ -62,7 +62,7 @@ describe "MergeRequests" do ...@@ -62,7 +62,7 @@ describe "MergeRequests" do
it { current_path.should == project_merge_request_path(project, project.merge_requests.last) } it { current_path.should == project_merge_request_path(project, project.merge_requests.last) }
it "should create merge request" do it "should create merge request" do
page.should have_content "Open" page.should have_content "Close"
page.should have_content @user.name page.should have_content @user.name
end end
end end
......
/* /*
* jQuery UI CSS Framework 1.8.16 * jQuery UI CSS Framework 1.8.16 Patched for GitLab HQ
* *
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses. * Dual licensed under the MIT or GPL Version 2 licenses.
......
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