Commit e0d1fba15e86771e7ecf820d1bec68aa5c0e9cb1
1 parent
40af6e1a
Exists in
master
and in
4 other branches
Recent push event
Showing
11 changed files
with
70 additions
and
11 deletions
Show diff stats
app/assets/stylesheets/common.scss
| ... | ... | @@ -733,3 +733,16 @@ li.note { |
| 733 | 733 | .chzn-container-active .chzn-single { |
| 734 | 734 | background:#fff; |
| 735 | 735 | } |
| 736 | + | |
| 737 | +/** | |
| 738 | + * Push event widget | |
| 739 | + * | |
| 740 | + */ | |
| 741 | +.event_lp { | |
| 742 | + @extend .alert-info; | |
| 743 | + margin-bottom:15px; | |
| 744 | + padding:8px; | |
| 745 | + border-style: solid; | |
| 746 | + border-width: 1px; | |
| 747 | + @include border-radius(4px); | |
| 748 | +} | ... | ... |
app/assets/stylesheets/themes/ui_modern.scss
| ... | ... | @@ -50,13 +50,12 @@ |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - .alert { | |
| 54 | - &.alert-info { | |
| 55 | - border-color:#FDA; | |
| 56 | - background:#FED; | |
| 57 | - color:#D70; | |
| 58 | - } | |
| 53 | + .alert-info { | |
| 54 | + border-color:#FDA; | |
| 55 | + background:#FED; | |
| 56 | + color:#D70; | |
| 59 | 57 | } |
| 58 | + | |
| 60 | 59 | |
| 61 | 60 | .progress .bar { |
| 62 | 61 | background:#D80; | ... | ... |
app/controllers/merge_requests_controller.rb
app/controllers/projects_controller.rb
| ... | ... | @@ -15,6 +15,8 @@ class ProjectsController < ApplicationController |
| 15 | 15 | @projects = @projects.page(params[:page]).per(40) |
| 16 | 16 | @events = Event.where(:project_id => current_user.projects.map(&:id)).recent.limit(20) |
| 17 | 17 | |
| 18 | + @last_push = current_user.recent_push | |
| 19 | + | |
| 18 | 20 | respond_to do |format| |
| 19 | 21 | format.html |
| 20 | 22 | format.atom { render :layout => false } |
| ... | ... | @@ -69,6 +71,7 @@ class ProjectsController < ApplicationController |
| 69 | 71 | respond_to do |format| |
| 70 | 72 | format.html do |
| 71 | 73 | if @project.repo_exists? && @project.has_commits? |
| 74 | + @last_push = current_user.recent_push(@project.id) | |
| 72 | 75 | render :show |
| 73 | 76 | else |
| 74 | 77 | render "projects/empty" | ... | ... |
app/helpers/merge_requests_helper.rb
| ... | ... | @@ -20,4 +20,15 @@ module MergeRequestsHelper |
| 20 | 20 | merge_request.author_name |
| 21 | 21 | end |
| 22 | 22 | end |
| 23 | + | |
| 24 | + def new_mr_path_from_push_event(event) | |
| 25 | + new_project_merge_request_path( | |
| 26 | + event.project, | |
| 27 | + :merge_request => { | |
| 28 | + :source_branch => event.branch_name, | |
| 29 | + :target_branch => event.project.root_ref, | |
| 30 | + :title => event.branch_name.titleize | |
| 31 | + } | |
| 32 | + ) | |
| 33 | + end | |
| 23 | 34 | end | ... | ... |
app/roles/account.rb
| ... | ... | @@ -46,4 +46,13 @@ module Account |
| 46 | 46 | return 100 if projects_limit.zero? |
| 47 | 47 | (my_own_projects.count.to_f / projects_limit) * 100 |
| 48 | 48 | end |
| 49 | + | |
| 50 | + def recent_push project_id = nil | |
| 51 | + # Get push events not earlier than 6 hours ago | |
| 52 | + events = recent_events.code_push.where("created_at > ?", Time.now - 6.hours) | |
| 53 | + events = events.where(:project_id => project_id) if project_id | |
| 54 | + | |
| 55 | + # Take only latest one | |
| 56 | + events = events.recent.limit(1).first | |
| 57 | + end | |
| 49 | 58 | end | ... | ... |
app/views/events/_event.html.haml
| 1 | 1 | - if event.allowed? |
| 2 | - .event_feed | |
| 3 | - - if event.issue? | |
| 2 | + - if event.issue? | |
| 3 | + .event_feed | |
| 4 | 4 | = render "events/event_issue", :event => event |
| 5 | - - elsif event.merge_request? | |
| 5 | + | |
| 6 | + - elsif event.merge_request? | |
| 7 | + .event_feed | |
| 6 | 8 | = render "events/event_merge_request", :event => event |
| 7 | - - elsif event.push? | |
| 9 | + | |
| 10 | + - elsif event.push? | |
| 11 | + .event_feed | |
| 8 | 12 | = render "events/event_push", :event => event |
| 13 | + | ... | ... |
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +- if event && event.branch_name && event.project.merge_requests_enabled | |
| 2 | + .event_lp | |
| 3 | + %div | |
| 4 | + = image_tag gravatar_icon(event.author_email), :class => "avatar" | |
| 5 | + %span Your last push was to | |
| 6 | + = event.ref_type | |
| 7 | + = link_to project_commits_path(event.project, :ref => event.ref_name) do | |
| 8 | + %strong= event.ref_name | |
| 9 | + at | |
| 10 | + %strong= link_to event.project.name, event.project | |
| 11 | + %span.cgray | |
| 12 | + = time_ago_in_words(event.created_at) | |
| 13 | + ago. | |
| 14 | + | |
| 15 | + = link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small padded primary" do | |
| 16 | + Merge Request | ... | ... |
app/views/events/_event_push.html.haml
app/views/projects/index.html.haml
app/views/projects/show.html.haml