Commit e0d1fba1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Recent push event

parent 40af6e1a
......@@ -733,3 +733,16 @@ li.note {
.chzn-container-active .chzn-single {
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 @@
}
}
.alert {
&.alert-info {
border-color:#FDA;
background:#FED;
color:#D70;
}
.alert-info {
border-color:#FDA;
background:#FED;
color:#D70;
}
.progress .bar {
background:#D80;
......
......@@ -63,7 +63,7 @@ class MergeRequestsController < ApplicationController
end
def new
@merge_request = @project.merge_requests.new
@merge_request = @project.merge_requests.new(params[:merge_request])
end
def edit
......
......@@ -15,6 +15,8 @@ class ProjectsController < ApplicationController
@projects = @projects.page(params[:page]).per(40)
@events = Event.where(:project_id => current_user.projects.map(&:id)).recent.limit(20)
@last_push = current_user.recent_push
respond_to do |format|
format.html
format.atom { render :layout => false }
......@@ -69,6 +71,7 @@ class ProjectsController < ApplicationController
respond_to do |format|
format.html do
if @project.repo_exists? && @project.has_commits?
@last_push = current_user.recent_push(@project.id)
render :show
else
render "projects/empty"
......
......@@ -20,4 +20,15 @@ module MergeRequestsHelper
merge_request.author_name
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
......@@ -46,4 +46,13 @@ module Account
return 100 if projects_limit.zero?
(my_own_projects.count.to_f / projects_limit) * 100
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
- if event.allowed?
.event_feed
- if event.issue?
- if event.issue?
.event_feed
= render "events/event_issue", :event => event
- elsif event.merge_request?
- elsif event.merge_request?
.event_feed
= render "events/event_merge_request", :event => event
- elsif event.push?
- elsif event.push?
.event_feed
= 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 @@
- else
- event.commits.each do |commit|
= render "events/commit", :commit => commit, :project => project
......@@ -14,6 +14,7 @@
- else
%h4.nothing_here_message Projects activity will be displayed here
.side
= render "events/event_last_push", :event => @last_push
.projects_box
%h5
Projects
......
......@@ -24,6 +24,7 @@
= link_to new_project_issue_path(@project), :title => "New Issue", :class => "btn small" do
Issue
= render "events/event_last_push", :event => @last_push
- unless @events.blank?
%br
%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