Commit 3a50b6ca authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets Committed by Dmitriy Zaporozhets

merge request show page refactored

parent e4bd6442
[Dolphin] [Dolphin]
ShowPreview=true ShowPreview=true
Timestamp=2011,12,12,23,25,14 Timestamp=2011,12,13,12,22,12
Version=2 Version=2
var MergeRequest = { var MergeRequest = {
diff_loaded: false, diffs_loaded: false,
commits_loaded: false, commits_loaded: false,
init: init:
...@@ -9,12 +9,25 @@ var MergeRequest = { ...@@ -9,12 +9,25 @@ var MergeRequest = {
$(this).addClass("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() { $(".merge-tabs a.merge-commits-tab").live("click", function() {
if(MergeRequest.commits_loaded) { if(!MergeRequest.commits_loaded) {
$(".merge-request-commits").show();
} else {
MergeRequest.loadCommits(); 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 = { ...@@ -23,14 +36,24 @@ var MergeRequest = {
$(".dashboard-loader").show(); $(".dashboard-loader").show();
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: location.href + "/commits", url: $(".merge-commits-tab").attr("data-url"),
complete: function(){ complete: function(){
MergeRequest.commits_loaded = true; MergeRequest.commits_loaded = true;
$(".merge-request-notes, .merge-request-diffs").hide();
$(".dashboard-loader").hide()}, $(".dashboard-loader").hide()},
dataType: "script"}); dataType: "script"});
}, },
loadDiff: loadDiff:
function() { 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 { ...@@ -552,7 +552,7 @@ h4.middle-panel {
display:none; display:none;
} }
ul.merge-tabs { .merge-tabs {
margin: 0; margin: 0;
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 10px; padding: 10px;
...@@ -567,9 +567,32 @@ ul.merge-tabs { ...@@ -567,9 +567,32 @@ ul.merge-tabs {
border: 1px solid #ddd; border: 1px solid #ddd;
background:none; background:none;
padding: 4px 10px; padding: 4px 10px;
width:160px;
&.active { &.active {
background: #eaeaea; 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 ...@@ -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
......
...@@ -28,7 +28,12 @@ ...@@ -28,7 +28,12 @@
%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" })
.buttons .buttons
= 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;
= 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 :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.users_projects.find(@merge_request.author.id)) do
- 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 = @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.users_projects.find(@merge_request.assignee.id)) do
= @merge_request.assignee_name = @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" %h3= @merge_request.title
.right
= link_to 'Edit', edit_project_merge_request_path(@project, @merge_request), :class => "grey-button positive"
.clear .clear
%br %br
%br %br
%ul.merge-tabs .merge-tabs
= link_to "Notes", "#", :class => "merge-notes-tab" = link_to "Notes", "#notes", :class => "merge-notes-tab active"
= link_to "Commits","#", "data-url" => commits_project_merge_request_path(@project, @merge_request), :class => "merge-commits-tab" = link_to "Commits","#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" = 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"} %img{:src => "/assets/ajax-loader-facebook.gif", :class => "dashboard-loader"}
.merge-request-notes .merge-request-notes
...@@ -53,7 +51,6 @@ ...@@ -53,7 +51,6 @@
.clear .clear
.merge-request-commits .merge-request-commits
.merge-request-diffs .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