Commit 2ec12c9b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Impoved merge requests show page. Minor style improvements across project

parent e2b39517
...@@ -41,6 +41,10 @@ a:focus { ...@@ -41,6 +41,10 @@ a:focus {
.label { .label {
background-color: #474D57; background-color: #474D57;
&.pushed {
background-color: $link_color;
}
} }
.pretty_label { .pretty_label {
...@@ -865,7 +869,7 @@ p.time { ...@@ -865,7 +869,7 @@ p.time {
} }
} }
padding: 10px 5px; padding: 15px 5px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
border-bottom: 1px solid rgba(0, 0, 0, 0.05); border-bottom: 1px solid rgba(0, 0, 0, 0.05);
&:last-child { border:none } &:last-child { border:none }
...@@ -963,3 +967,17 @@ p.time { ...@@ -963,3 +967,17 @@ p.time {
.highlight_word { .highlight_word {
background:#EEDC94; background:#EEDC94;
} }
.status_info {
font-size:14px;
padding:5px 15px;
line-height:24px;
width:60px;
text-align:center;
float:left;
margin-right:20px;
}
.merge_request_status_holder {
margin-bottom:20px;
}
...@@ -45,9 +45,6 @@ class MergeRequestsController < ApplicationController ...@@ -45,9 +45,6 @@ class MergeRequestsController < ApplicationController
# or from cache if already merged # or from cache if already merged
@commits = @merge_request.commits @commits = @merge_request.commits
# Close MR if nothing to merge
#@merge_request.mark_as_merged! if @merge_request.probably_merged?
respond_to do |format| respond_to do |format|
format.html format.html
format.js format.js
...@@ -75,8 +72,7 @@ class MergeRequestsController < ApplicationController ...@@ -75,8 +72,7 @@ class MergeRequestsController < ApplicationController
respond_to do |format| respond_to do |format|
if @merge_request.save if @merge_request.save
@merge_request.reloaded_commits @merge_request.reload_code
@merge_request.reloaded_diffs
format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.' } format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.' }
format.json { render json: @merge_request, status: :created, location: @merge_request } format.json { render json: @merge_request, status: :created, location: @merge_request }
else else
...@@ -89,6 +85,7 @@ class MergeRequestsController < ApplicationController ...@@ -89,6 +85,7 @@ class MergeRequestsController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id)) if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id))
@merge_request.reload_code
format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' } format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' }
format.json { head :ok } format.json { head :ok }
else else
......
...@@ -41,12 +41,21 @@ class MergeRequest < ActiveRecord::Base ...@@ -41,12 +41,21 @@ class MergeRequest < ActiveRecord::Base
where("title like :query", :query => "%#{query}%") where("title like :query", :query => "%#{query}%")
end end
def self.find_all_by_branch(branch_name)
where("source_branch like :branch or target_branch like :branch", :branch => branch_name)
end
def validate_branches def validate_branches
if target_branch == source_branch if target_branch == source_branch
errors.add :base, "You can not use same branch for source and target branches" errors.add :base, "You can not use same branch for source and target branches"
end end
end end
def reload_code
self.reloaded_commits
self.reloaded_diffs
end
def new? def new?
today? && created_at == updated_at today? && created_at == updated_at
end end
...@@ -72,10 +81,19 @@ class MergeRequest < ActiveRecord::Base ...@@ -72,10 +81,19 @@ class MergeRequest < ActiveRecord::Base
commits.first commits.first
end end
def merged?
merged && merge_event
end
def merge_event def merge_event
self.project.events.where(:target_id => self.id, :target_type => "MergeRequest", :action => Event::Merged).last self.project.events.where(:target_id => self.id, :target_type => "MergeRequest", :action => Event::Merged).last
end end
def closed_event
self.project.events.where(:target_id => self.id, :target_type => "MergeRequest", :action => Event::Closed).last
end
# Return the number of +1 comments (upvotes) # Return the number of +1 comments (upvotes)
def upvotes def upvotes
notes.select(&:upvote?).size notes.select(&:upvote?).size
...@@ -115,6 +133,17 @@ class MergeRequest < ActiveRecord::Base ...@@ -115,6 +133,17 @@ class MergeRequest < ActiveRecord::Base
sort_by(&:created_at). sort_by(&:created_at).
reverse reverse
end end
def merge!(user_id)
self.mark_as_merged!
Event.create(
:project => self.project,
:action => Event::Merged,
:target_id => self.id,
:target_type => "MergeRequest",
:author_id => user_id
)
end
end end
# == Schema Information # == Schema Information
# #
......
...@@ -80,35 +80,18 @@ class Project < ActiveRecord::Base ...@@ -80,35 +80,18 @@ class Project < ActiveRecord::Base
def update_merge_requests(oldrev, newrev, ref, author_key_id) def update_merge_requests(oldrev, newrev, ref, author_key_id)
return true unless ref =~ /heads/ return true unless ref =~ /heads/
branch_name = ref.gsub("refs/heads/", "") branch_name = ref.gsub("refs/heads/", "")
user = Key.find_by_identifier(author_key_id).user
key = Key.find_by_identifier(author_key_id)
user = key.user
c_ids = self.commits_between(oldrev, newrev).map(&:id) c_ids = self.commits_between(oldrev, newrev).map(&:id)
# update commits & diffs for existing MR # Update code for merge requests
mrs = self.merge_requests.opened.where(:source_branch => branch_name).all mrs = self.merge_requests.opened.find_all_by_branch(branch_name).all
mrs.each do |merge_request| mrs.each { |merge_request| merge_request.reload_code }
merge_request.reloaded_commits
merge_request.reloaded_diffs
end
# Close merge requests # Close merge requests
mrs = self.merge_requests.opened.where(:target_branch => branch_name).all mrs = self.merge_requests.opened.where(:target_branch => branch_name).all
mrs.each do |merge_request| mrs = mrs.select(&:last_commit).select { |mr| c_ids.include?(mr.last_commit.id) }
next unless merge_request.last_commit mrs.each { |merge_request| merge_request.merge!(user.id) }
# Mark as merged & create event if merged
if c_ids.include?(merge_request.last_commit.id)
merge_request.mark_as_merged!
Event.create(
:project => self,
:action => Event::Merged,
:target_id => merge_request.id,
:target_type => "MergeRequest",
:author_id => user.id
)
end
end
true true
end end
......
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name} %strong #{event.author_name}
- if event.closed? %span.label.important
closed - if event.closed?
- else closed
reopened - else
issue reopened
&nbsp;issue
= link_to project_issue_path(event.project, event.issue) do = link_to project_issue_path(event.project, event.issue) do
%strong= truncate event.issue_title %strong= truncate event.issue_title
at at
......
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name} %strong #{event.author_name}
- if event.closed? %span.label.important
closed - if event.closed?
- else closed
reopened - else
merge request reopened
&nbsp;merge request
= link_to project_merge_request_path(event.project, event.merge_request) do = link_to project_merge_request_path(event.project, event.merge_request) do
%strong= truncate event.merge_request_title %strong= truncate event.merge_request_title
at at
...@@ -12,7 +13,6 @@ at ...@@ -12,7 +13,6 @@ at
%span.cgray %span.cgray
= time_ago_in_words(event.created_at) = time_ago_in_words(event.created_at)
ago. ago.
%br
%span.label= event.merge_request.source_branch %span.label= event.merge_request.source_branch
&rarr; &rarr;
%span.label= event.merge_request.target_branch %span.label= event.merge_request.target_branch
......
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name} %strong #{event.author_name}
created new issue %span.label.success created
&nbsp;new issue
= link_to project_issue_path(event.project, event.issue) do = link_to project_issue_path(event.project, event.issue) do
%strong= truncate event.issue_title %strong= truncate event.issue_title
at at
......
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name} %strong #{event.author_name}
requested merge %span.label.success requested
&nbsp;merge
= link_to project_merge_request_path(event.project, event.merge_request) do = link_to project_merge_request_path(event.project, event.merge_request) do
%strong= truncate event.merge_request_title %strong= truncate event.merge_request_title
at at
...@@ -8,7 +9,6 @@ at ...@@ -8,7 +9,6 @@ at
%span.cgray %span.cgray
= time_ago_in_words(event.created_at) = time_ago_in_words(event.created_at)
ago. ago.
%br
%span.label= event.merge_request.source_branch %span.label= event.merge_request.source_branch
&rarr; &rarr;
%span.label= event.merge_request.target_branch %span.label= event.merge_request.target_branch
......
- if event.new_branch? || event.new_tag? - if event.new_branch? || event.new_tag?
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name} %strong #{event.author_name}
pushed new %span.label.pushed pushed
&nbsp;new
- if event.new_tag? - if event.new_tag?
tag tag
= link_to project_commits_path(event.project, :ref => event.tag_name) do = link_to project_commits_path(event.project, :ref => event.tag_name) do
...@@ -18,7 +19,8 @@ ...@@ -18,7 +19,8 @@
- else - else
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name} %strong #{event.author_name}
pushed to %span.label.pushed pushed
&nbsp;to
= link_to project_commits_path(event.project, :ref => event.branch_name) do = link_to project_commits_path(event.project, :ref => event.branch_name) do
%strong= event.branch_name %strong= event.branch_name
at at
...@@ -30,10 +32,10 @@ ...@@ -30,10 +32,10 @@
= link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do = link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do
Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]} Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]}
- @project = event.project - @project = event.project
%ul.unstyled %ul.unstyled.event_commits
- if event.commits.size > 4 - if event.commits.size > 3
= render event.commits[0..2] = render event.commits[0...2]
%li ... and #{event.commits.size - 3} more commits %li ... and #{event.commits.size - 2} more commits
- else - else
= render event.commits = render event.commits
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
- if issue.today? - if issue.today?
%span.label.success today %span.label.success today
- if issue.notes.any? - if issue.notes.any?
%span.label= pluralize issue.notes.count, 'note' %span.pretty_label= pluralize issue.notes.count, 'note'
- if issue.upvotes > 0 - if issue.upvotes > 0
%span.label.success= "+#{issue.upvotes}" %span.label.success= "+#{issue.upvotes}"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
:javascript :javascript
$(function(){ $(function(){
var modal = $('#modal_merge_info').modal({modal: true}); var modal = $('#modal_merge_info').modal({modal: true});
$('.info_link').bind("click", function(){ $('.how_to_merge_link').bind("click", function(){
modal.show(); modal.show();
}); });
$('.modal-header .close').bind("click", function(){ $('.modal-header .close').bind("click", function(){
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
= time_ago_in_words(merge_request.created_at) = time_ago_in_words(merge_request.created_at)
ago ago
- if merge_request.notes.any? - if merge_request.notes.any?
%span.label= pluralize merge_request.notes.count, 'note' %span.pretty_label= pluralize merge_request.notes.count, 'note'
- if merge_request.upvotes > 0 - if merge_request.upvotes > 0
%span.label.success= "+#{merge_request.upvotes}" %span.label.success= "+#{merge_request.upvotes}"
.right .right
......
...@@ -26,23 +26,23 @@ ...@@ -26,23 +26,23 @@
%hr %hr
- if @merge_request.closed .merge_request_status_holder
.alert-message.error Closed - if @merge_request.closed
- if @merge_request.merged %h5
- event = @merge_request.merge_event .alert-message.error.status_info Closed
%div - if @merge_request.merged?
%p %span
%strong #{event.author_name} Merged by #{@merge_request.merge_event.author_name}
merged this request %small #{time_ago_in_words(@merge_request.merge_event.created_at)} ago.
%span.cgray - elsif @merge_request.closed_event
= time_ago_in_words(event.created_at) %span
ago. Closed by #{@merge_request.closed_event.author_name}
%br %small #{time_ago_in_words(@merge_request.closed_event.created_at)} ago.
- else %br
.alert-message.success - else
= link_to "#", :class => "info_link", :title => "How To Merge" do %h5
= image_tag "Info-UI.PNG" .alert-message.success.status_info Open
Open = link_to "How to merge", "#", :class => "vlink how_to_merge_link", :title => "How To Merge"
= render "merge_requests/how_to_merge" = render "merge_requests/how_to_merge"
......
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