Merge branch 'refactor_merge_requests'
This commit is contained in:
commit
6c47bcef02
|
@ -1,4 +1,4 @@
|
|||
[Dolphin]
|
||||
ShowPreview=true
|
||||
Timestamp=2011,10,28,13,16,25
|
||||
Timestamp=2011,12,13,12,22,12
|
||||
Version=2
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
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{
|
|||
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 {
|
||||
padding:40px;
|
||||
display:none;
|
||||
|
@ -587,3 +551,82 @@ h4.middle-panel {
|
|||
margin-right:30px;
|
||||
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}
|
|||
border-radius: 5px;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
padding: 6px 20px;
|
||||
padding: 5px 17px;
|
||||
border: 1px solid #999;
|
||||
color: #666;
|
||||
display: inline-block;
|
||||
|
|
|
@ -30,14 +30,11 @@ class MergeRequestsController < ApplicationController
|
|||
|
||||
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
|
||||
@diffs = @merge_request.diffs
|
||||
@commit = @merge_request.last_commit
|
||||
|
||||
render :template => "merge_requests/_diffs", :layout => false
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -90,6 +90,10 @@ class Project < ActiveRecord::Base
|
|||
users_projects.find_by_user_id(user.id) if user
|
||||
end
|
||||
|
||||
def team_member_by_id(user_id)
|
||||
users_projects.find_by_user_id(user_id)
|
||||
end
|
||||
|
||||
def fresh_issues(n)
|
||||
issues.includes(:project, :author).order("created_at desc").first(n)
|
||||
end
|
||||
|
|
|
@ -1,34 +1,49 @@
|
|||
%div.merge-request-form-holder
|
||||
.ui-box.width-100p
|
||||
%h3
|
||||
= @merge_request.new_record? ? "New Merge Request" : "Edit Merge Request ##{@merge_request.id}"
|
||||
= form_for [@project, @merge_request] do |f|
|
||||
.data
|
||||
%div
|
||||
%span.entity-info
|
||||
- if @merge_request.new_record?
|
||||
= link_to project_merge_requests_path(@project) do
|
||||
.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
|
||||
-if @merge_request.errors.any?
|
||||
%tr
|
||||
%td Errors
|
||||
%td
|
||||
%td{:colspan => 2}
|
||||
#error_explanation
|
||||
- @merge_request.errors.full_messages.each do |msg|
|
||||
%span= msg
|
||||
%br
|
||||
|
||||
%tr
|
||||
%td= f.label :title
|
||||
%td= f.text_field :title
|
||||
%tr
|
||||
%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
|
||||
%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
|
||||
%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" })
|
||||
.buttons
|
||||
%td= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }, :style => "width:250px")
|
||||
= f.text_area :title, :style => "width:718px; height:100px", :maxlength => 255
|
||||
%br
|
||||
%br
|
||||
.merge-tabs
|
||||
= f.submit 'Save', :class => "grey-button"
|
||||
.right= link_to 'Back', project_merge_requests_path(@project), :class => "grey-button"
|
||||
|
||||
- unless @merge_request.new_record?
|
||||
.right
|
||||
= link_to 'Remove', [@project, @merge_request], :confirm => 'Are you sure?', :method => :delete, :class => "red-button"
|
||||
|
||||
|
||||
|
||||
|
||||
:javascript
|
||||
$(function(){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%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
|
||||
%span.update-title
|
||||
= merge_request.title
|
||||
= truncate(merge_request.title, :length => 60)
|
||||
%span.update-author
|
||||
%strong= merge_request.author_name
|
||||
authored
|
||||
|
|
4
app/views/merge_requests/commits.js.haml
Normal file
4
app/views/merge_requests/commits.js.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
:plain
|
||||
$(".merge-request-commits").html("#{escape_javascript(render(:partial => "commits"))}");
|
||||
|
||||
|
4
app/views/merge_requests/diffs.js.haml
Normal file
4
app/views/merge_requests/diffs.js.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
:plain
|
||||
$(".merge-request-diffs").html("#{escape_javascript(render(:partial => "diffs"))}");
|
||||
|
||||
|
|
@ -1,59 +1,69 @@
|
|||
.merge-request-show-holder.ui-box.width-100p
|
||||
%h3
|
||||
%div
|
||||
%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}:"
|
||||
|
||||
.tag.commit.inline= @merge_request.source_branch
|
||||
→
|
||||
.tag.commit.inline= @merge_request.target_branch
|
||||
.right
|
||||
- if @merge_request.closed
|
||||
%span.tag.high Closed
|
||||
- else
|
||||
%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
|
||||
%span.commit-author
|
||||
%strong
|
||||
= link_to project_team_member_path(@project, @project.team_member_by_id(@merge_request.author.id)) do
|
||||
%span.author= @merge_request.author_name
|
||||
→
|
||||
= image_tag gravatar_icon(@merge_request.assignee_email), :width => 20, :style => "padding:0 5px;"
|
||||
= @merge_request.assignee_name
|
||||
.right
|
||||
%cite.cgray= @merge_request.created_at.stamp("21 Aug 2011, 11:15pm")
|
||||
.clear
|
||||
= link_to project_team_member_path(@project, @project.team_member_by_id(@merge_request.assignee.id)) do
|
||||
%span.author= @merge_request.assignee_name
|
||||
|
||||
.buttons
|
||||
- if can? current_user, :write_project, @project
|
||||
|
||||
|
||||
= @merge_request.created_at.stamp("Aug 21, 2011 9:23pm")
|
||||
|
||||
%hr
|
||||
%br
|
||||
%h3
|
||||
= simple_format @merge_request.title
|
||||
|
||||
.clear
|
||||
%br
|
||||
%br
|
||||
|
||||
.merge-tabs
|
||||
= link_to "#notes", :class => "merge-notes-tab active tab" do
|
||||
%span
|
||||
Notes
|
||||
= 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
|
||||
|
||||
- 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 => "grey-button"
|
||||
= 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 => "grey-button"
|
||||
.right
|
||||
= link_to 'Edit', edit_project_merge_request_path(@project, @merge_request), :class => "grey-button positive"
|
||||
= 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"}
|
||||
|
||||
.clear
|
||||
%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)
|
||||
|
||||
#merge-notes
|
||||
.merge-request-notes
|
||||
.issue_notes= render "notes/notes"
|
||||
.loading{ :style => "display:none;"}
|
||||
%center= image_tag "ajax-loader.gif"
|
||||
.clear
|
||||
|
||||
.merge-request-commits
|
||||
.merge-request-diffs
|
||||
|
||||
|
||||
:javascript
|
||||
$(function(){
|
||||
$("#gitlab-tabs").tabs();
|
||||
MergeRequest.init();
|
||||
})
|
||||
|
|
|
@ -42,8 +42,8 @@ describe "MergeRequests" do
|
|||
|
||||
it { should have_content(@merge_request.title) }
|
||||
it "Show page should inform user that merge request closed" do
|
||||
within ".merge-request-show-holder h3" do
|
||||
page.should have_content "Closed"
|
||||
within ".merge-tabs" do
|
||||
page.should have_content "Reopen"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -62,7 +62,7 @@ describe "MergeRequests" do
|
|||
it { current_path.should == project_merge_request_path(project, project.merge_requests.last) }
|
||||
|
||||
it "should create merge request" do
|
||||
page.should have_content "Open"
|
||||
page.should have_content "Close"
|
||||
page.should have_content @user.name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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)
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
|
|
Loading…
Reference in a new issue