Commit e0d1fba1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Recent push event

parent 40af6e1a
...@@ -733,3 +733,16 @@ li.note { ...@@ -733,3 +733,16 @@ li.note {
.chzn-container-active .chzn-single { .chzn-container-active .chzn-single {
background:#fff; background:#fff;
} }
/**
* Push event widget
*
*/
.event_lp {
@extend .alert-info;
margin-bottom:15px;
padding:8px;
border-style: solid;
border-width: 1px;
@include border-radius(4px);
}
...@@ -50,13 +50,12 @@ ...@@ -50,13 +50,12 @@
} }
} }
.alert { .alert-info {
&.alert-info { border-color:#FDA;
border-color:#FDA; background:#FED;
background:#FED; color:#D70;
color:#D70;
}
} }
.progress .bar { .progress .bar {
background:#D80; background:#D80;
......
...@@ -63,7 +63,7 @@ class MergeRequestsController < ApplicationController ...@@ -63,7 +63,7 @@ class MergeRequestsController < ApplicationController
end end
def new def new
@merge_request = @project.merge_requests.new @merge_request = @project.merge_requests.new(params[:merge_request])
end end
def edit def edit
......
...@@ -15,6 +15,8 @@ class ProjectsController < ApplicationController ...@@ -15,6 +15,8 @@ class ProjectsController < ApplicationController
@projects = @projects.page(params[:page]).per(40) @projects = @projects.page(params[:page]).per(40)
@events = Event.where(:project_id => current_user.projects.map(&:id)).recent.limit(20) @events = Event.where(:project_id => current_user.projects.map(&:id)).recent.limit(20)
@last_push = current_user.recent_push
respond_to do |format| respond_to do |format|
format.html format.html
format.atom { render :layout => false } format.atom { render :layout => false }
...@@ -69,6 +71,7 @@ class ProjectsController < ApplicationController ...@@ -69,6 +71,7 @@ class ProjectsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
if @project.repo_exists? && @project.has_commits? if @project.repo_exists? && @project.has_commits?
@last_push = current_user.recent_push(@project.id)
render :show render :show
else else
render "projects/empty" render "projects/empty"
......
...@@ -20,4 +20,15 @@ module MergeRequestsHelper ...@@ -20,4 +20,15 @@ module MergeRequestsHelper
merge_request.author_name merge_request.author_name
end end
end end
def new_mr_path_from_push_event(event)
new_project_merge_request_path(
event.project,
:merge_request => {
:source_branch => event.branch_name,
:target_branch => event.project.root_ref,
:title => event.branch_name.titleize
}
)
end
end end
...@@ -46,4 +46,13 @@ module Account ...@@ -46,4 +46,13 @@ module Account
return 100 if projects_limit.zero? return 100 if projects_limit.zero?
(my_own_projects.count.to_f / projects_limit) * 100 (my_own_projects.count.to_f / projects_limit) * 100
end end
def recent_push project_id = nil
# Get push events not earlier than 6 hours ago
events = recent_events.code_push.where("created_at > ?", Time.now - 6.hours)
events = events.where(:project_id => project_id) if project_id
# Take only latest one
events = events.recent.limit(1).first
end
end end
- if event.allowed? - if event.allowed?
.event_feed - if event.issue?
- if event.issue? .event_feed
= render "events/event_issue", :event => event = render "events/event_issue", :event => event
- elsif event.merge_request?
- elsif event.merge_request?
.event_feed
= render "events/event_merge_request", :event => event = render "events/event_merge_request", :event => event
- elsif event.push?
- elsif event.push?
.event_feed
= render "events/event_push", :event => event = render "events/event_push", :event => event
- if event && event.branch_name && event.project.merge_requests_enabled
.event_lp
%div
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%span Your last push was to
= event.ref_type
= link_to project_commits_path(event.project, :ref => event.ref_name) do
%strong= event.ref_name
at
%strong= link_to event.project.name, event.project
%span.cgray
= time_ago_in_words(event.created_at)
ago.
= link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small padded primary" do
Merge Request
...@@ -27,3 +27,4 @@ ...@@ -27,3 +27,4 @@
- else - else
- event.commits.each do |commit| - event.commits.each do |commit|
= render "events/commit", :commit => commit, :project => project = render "events/commit", :commit => commit, :project => project
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
- else - else
%h4.nothing_here_message Projects activity will be displayed here %h4.nothing_here_message Projects activity will be displayed here
.side .side
= render "events/event_last_push", :event => @last_push
.projects_box .projects_box
%h5 %h5
Projects Projects
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
= link_to new_project_issue_path(@project), :title => "New Issue", :class => "btn small" do = link_to new_project_issue_path(@project), :title => "New Issue", :class => "btn small" do
Issue Issue
= render "events/event_last_push", :event => @last_push
- unless @events.blank? - unless @events.blank?
%br %br
%h5.cgray %h5.cgray
......
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