Commit 18be3e4c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

merge request show page refactored

parent 4e00330b
[Dolphin]
ShowPreview=true
Timestamp=2011,12,12,23,25,14
Timestamp=2011,12,13,12,22,12
Version=2
var MergeRequest = {
diff_loaded: false,
diffs_loaded: false,
commits_loaded: false,
init:
......@@ -9,12 +9,25 @@ var MergeRequest = {
$(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) {
$(".merge-request-commits").show();
} else {
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();
});
},
......@@ -23,14 +36,24 @@ var MergeRequest = {
$(".dashboard-loader").show();
$.ajax({
type: "GET",
url: location.href + "/commits",
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"});
}
}
......@@ -552,7 +552,7 @@ h4.middle-panel {
display:none;
}
ul.merge-tabs {
.merge-tabs {
margin: 0;
border: 1px solid #ccc;
padding: 10px;
......@@ -567,9 +567,32 @@ ul.merge-tabs {
border: 1px solid #ddd;
background:none;
padding: 4px 10px;
width:160px;
&.active {
background: #eaeaea;
}
}
}
.merge-tabs .reopen-request {
@include round-borders-all(4px);
padding:2px 4px;
border:1px solid #aaa;
text-shadow:none;
background: #D12F19;
color:white;
}
.merge-tabs .close-request {
@include round-borders-all(4px);
padding:2px 4px;
border:1px solid #aaa;
text-shadow:none;
background: #44aa22;
color:white;
}
.user-mention {
color: #2FA0BB;
font-weight: bold;
}
......@@ -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
......
......@@ -28,7 +28,12 @@
%td= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" })
.buttons
= f.submit 'Save', :class => "grey-button"
.right= link_to 'Back', project_merge_requests_path(@project), :class => "grey-button"
&nbsp;
= 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 => "grey-button"
:javascript
$(function(){
......
%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
......
: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
%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}:"
&nbsp;
.tag.commit.inline= @merge_request.source_branch
&rarr;
.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;"
%span.commit-author
%strong
= link_to project_team_member_path(@project, @project.users_projects.find(@merge_request.author.id)) do
= @merge_request.author_name
&rarr;
= image_tag gravatar_icon(@merge_request.assignee_email), :width => 20, :style => "padding:0 5px;"
= link_to project_team_member_path(@project, @project.users_projects.find(@merge_request.assignee.id)) do
= @merge_request.assignee_name
.right
%cite.cgray= @merge_request.created_at.stamp("21 Aug 2011, 11:15pm")
.clear
.buttons
- if can? current_user, :write_project, @project
- 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"
- 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"
&nbsp;
&nbsp;
= @merge_request.created_at.stamp("Aug 21, 2011 9:23pm")
%hr
%h3= @merge_request.title
.clear
%br
%br
%ul.merge-tabs
= link_to "Notes", "#", :class => "merge-notes-tab"
= link_to "Commits","#", "data-url" => commits_project_merge_request_path(@project, @merge_request), :class => "merge-commits-tab"
= link_to "Diff", diffs_project_merge_request_path(@project, @merge_request), :class => "merge-diffs-tab"
.merge-tabs
= link_to "Notes", "#notes", :class => "merge-notes-tab active"
= link_to "Commits","#commits", "data-url" => commits_project_merge_request_path(@project, @merge_request), :class => "merge-commits-tab"
= link_to "Diff", "#diffs", "data-url" => diffs_project_merge_request_path(@project, @merge_request), :class => "merge-diffs-tab"
- 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 => "reopen-request"
- else
= link_to 'Close', project_merge_request_path(@project, @merge_request, :merge_request => {:closed => true }, :status_only => true), :method => :put, :class => "close-request", :title => "Close merge request"
%img{:src => "/assets/ajax-loader-facebook.gif", :class => "dashboard-loader"}
.merge-request-notes
......@@ -53,7 +51,6 @@
.clear
.merge-request-commits
.merge-request-diffs
......
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