Commit 77cf6620 authored by randx's avatar randx

Pushed widget improved

parent ed247b38
...@@ -88,4 +88,9 @@ module ApplicationHelper ...@@ -88,4 +88,9 @@ module ApplicationHelper
def app_theme def app_theme
Gitlab::Theme.css_class_by_id(current_user.try(:theme_id)) Gitlab::Theme.css_class_by_id(current_user.try(:theme_id))
end end
def show_last_push_widget?(event)
event && event.last_push_to_non_root? &&
event.project && event.project.merge_requests_enabled
end
end end
...@@ -48,8 +48,8 @@ module Account ...@@ -48,8 +48,8 @@ module Account
end end
def recent_push project_id = nil def recent_push project_id = nil
# Get push events not earlier than 6 hours ago # Get push events not earlier than 2 hours ago
events = recent_events.code_push.where("created_at > ?", Time.now - 6.hours) events = recent_events.code_push.where("created_at > ?", Time.now - 2.hours)
events = events.where(:project_id => project_id) if project_id events = events.where(:project_id => project_id) if project_id
# Take only latest one # Take only latest one
......
...@@ -9,6 +9,10 @@ module PushEvent ...@@ -9,6 +9,10 @@ module PushEvent
data[:ref]["refs/tags"] data[:ref]["refs/tags"]
end end
def branch?
data[:ref]["refs/heads"]
end
def new_branch? def new_branch?
commit_from =~ /^00000/ commit_from =~ /^00000/
end end
...@@ -87,4 +91,8 @@ module PushEvent ...@@ -87,4 +91,8 @@ module PushEvent
def push_with_commits? def push_with_commits?
md_ref? && commits.any? && parent_commit && last_commit md_ref? && commits.any? && parent_commit && last_commit
end end
def last_push_to_non_root?
branch? && project.default_branch != branch_name
end
end end
- if event && event.branch_name - if show_last_push_widget?(event)
.event_lp .event_lp
%div %div
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%span Your last push was to %span Your pushed to
= event.ref_type = event.ref_type
= link_to project_commits_path(event.project, :ref => event.ref_name) do = link_to project_commits_path(event.project, :ref => event.ref_name) do
%strong= event.ref_name %strong= event.ref_name
...@@ -12,6 +12,5 @@ ...@@ -12,6 +12,5 @@
= time_ago_in_words(event.created_at) = time_ago_in_words(event.created_at)
ago. ago.
- if event.project.merge_requests_enabled = link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small padded primary" do
= link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small padded primary" do Create Merge Request
Create Merge Request
...@@ -21,12 +21,6 @@ ...@@ -21,12 +21,6 @@
Issue Issue
= render "events/event_last_push", :event => @last_push = render "events/event_last_push", :event => @last_push
- unless @events.blank? .content_list= render @events
%br
%h5.cgray
%span.ico.activities
Recent Activity
%hr
.content_list= render @events
...@@ -42,7 +42,7 @@ Given /^project "(.*?)" has push event$/ do |arg1| ...@@ -42,7 +42,7 @@ Given /^project "(.*?)" has push event$/ do |arg1|
end end
Then /^I should see last push widget$/ do Then /^I should see last push widget$/ do
page.should have_content "Your last push was to branch new_design" page.should have_content "Your pushed to branch new_design"
page.should have_link "Create Merge Request" page.should have_link "Create Merge Request"
end end
......
...@@ -11,7 +11,7 @@ describe "Last Push widget" do ...@@ -11,7 +11,7 @@ describe "Last Push widget" do
end end
it "should display last push widget with link to merge request page" do it "should display last push widget with link to merge request page" do
page.should have_content "Your last push was to branch new_design" page.should have_content "Your pushed to branch new_design"
page.should have_link "Create Merge Request" page.should have_link "Create Merge Request"
end end
......
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