Add first version of new design to activity feed. Add new scope to BuildList model. Fix one moment into observer.

This commit is contained in:
konstantin.grabar 2012-03-05 13:11:50 +04:00
parent 0c194f5b50
commit c176304088
15 changed files with 192 additions and 60 deletions

View File

@ -1,5 +1,5 @@
module ActivityFeedsHelper
def render_activity_feed(activity_feed)
render :partial => activity_feed.partial, :locals => activity_feed.data
render :partial => activity_feed.partial, :locals => activity_feed.data.merge(:activity_feed => activity_feed)
end
end

View File

@ -18,7 +18,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
ActivityFeed.create(
:user => recipient,
:kind => 'new_issue_notification',
:data => {:user_name => recipient.name, :issue_serial_id => record.serial_id, :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name}
:data => {:user_name => record.user.name, :issue_serial_id => record.serial_id, :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name}
)
end
@ -58,7 +58,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
)
end
end
when 'GitHook'
change_type = record.change_type
branch_name = record.refname.match(/\/([\w\d]+)$/)[1]
@ -86,7 +86,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
:data => options
)
end
when 'Gollum::Committer'
actor = User.find_by_uname(record.actor.name)
project_name = record.wiki.path.match(/\/(\w+)\.wiki\.git$/)[1]

View File

@ -62,6 +62,7 @@ class BuildList < ActiveRecord::Base
where(["status in (?) OR (status in (?) AND notified_at >= ?)", [WAITING_FOR_RESPONSE, BUILD_PENDING, BuildServer::BUILD_STARTED], outdatable_statuses, Time.now - 2.days])
}
scope :for_status, lambda {|status| where(:status => status) }
scope :for_user, lambda { |user| where(:user_id => user.id) }
scope :scoped_to_arch, lambda {|arch| where(:arch_id => arch) }
scope :scoped_to_project_version, lambda {|project_version| where(:project_version => project_version) }
scope :scoped_to_is_circle, lambda {|is_circle| where(:is_circle => is_circle) }

View File

@ -0,0 +1,47 @@
.bordered
= link_to t("layout.activity_feed.new_project"), new_project_path, :class => 'button'
%h3= t("layout.activity_feed.my_last_projects")
%table
%tbody
- current_user.projects.each do |project|
%tr
%td
- if project.public?
= image_tag("unlock.png")
- else
= image_tag("lock.png")
%td
= link_to "#{project.owner.uname}/#{project.name}", project_path(project)
%tr
%td
\ 
%td
= link_to t("layout.activity_feed.all_my_projects"), projects_path
.block
%h3= t("layout.activity_feed.my_builds_by_day")
%table{:cellpadding => "0", :cellspacing => "0"}
%tbody
%tr
%td.first
= link_to t("layout.build_lists.statuses.#{:build_published}"), build_lists_path(:filter => {:status => BuildList::BUILD_PUBLISHED})
%td= BuildList.for_status(BuildList::BUILD_PUBLISHED).for_user(current_user).count
%tr
%td.first
= link_to t("layout.build_lists.statuses.#{:success}"), build_lists_path(:filter => {:status => BuildServer::SUCCESS})
%td= BuildList.for_status(BuildServer::SUCCESS).for_user(current_user).count
%tr
%td.first
= link_to t("layout.build_lists.statuses.#{:build_started}"), build_lists_path(:filter => {:status => BuildServer::BUILD_STARTED})
%td= BuildList.for_status(BuildServer::BUILD_STARTED).for_user(current_user).count
%tr
%td.first
= link_to t("layout.build_lists.statuses.#{:build_pending}"), build_lists_path(:filter => {:status => BuildList::BUILD_PENDING})
%td= BuildList.for_status(BuildList::BUILD_PENDING).for_user(current_user).count
%tr
%td.first
= link_to t("layout.build_lists.statuses.#{:build_error}"), build_lists_path(:filter => {:status => BuildServer::BUILD_ERROR})
%td= BuildList.for_status(BuildServer::BUILD_ERROR).for_user(current_user).count
%tr
%td.first
= link_to t("layout.activity_feed.all_my_builds"), build_lists_path
%td  

View File

@ -1,21 +1,6 @@
%a{ :name => "comments" }
.block#block-list
.content
%h2.title
= t("layout.activity_feed.header")
.inner
%ul.list
- @activity_feeds.each do |activity_feed|
%li
.left
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%br
= activity_feed.created_at
%br
%br
.item
= render_activity_feed(activity_feed)
%br
%br
%br
%h3.fix= t("layout.activity_feed.header")
- @activity_feeds.each do |activity_feed|
.activity
= render_activity_feed(activity_feed)
- content_for :sidebar, render('sidebar')

View File

@ -1,3 +1,13 @@
%p== Branch #{ branch_name } has been deleted
%p== Into project #{ link_to(project_name, project_path(project_id)) }
.top
.image
= image_tag(gravatar_url(activity_feed.user.email, 30))
.text
%span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%span.date= activity_feed.created_at
%br
%span.subject Branch #{ branch_name } has been deleted
.both
.fulltext
Into project #{ link_to(project_name, project_path(project_id)) }

View File

@ -1,7 +1,19 @@
%p== Branch #{ branch_name } has been #{ change_type }d
%p== Into project #{ link_to(project_name, project_path(project_id)) }
- last_commits.each do |commit|
= link_to commit[0], commit_path(project_id, commit[0])
= commit[1]
.top
.image
= image_tag(gravatar_url(activity_feed.user.email, 30))
.text
%span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%span.date= activity_feed.created_at
%br
%span.subject Branch #{ branch_name } has been #{ change_type }d
.both
.fulltext
Into project #{ link_to(project_name, project_path(project_id)) }
%br
%br
- last_commits.each do |commit|
= link_to commit[0], commit_path(project_id, commit[0])
= commit[1]
%br

View File

@ -1,3 +1,13 @@
%p== #{ t("notifications.bodies.issue_assign_notification.title", :user_name => user_name) }
%p= raw t("notifications.bodies.issue_assign_notification.content", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id)))
.top
.image
= image_tag(gravatar_url(activity_feed.user.email, 30))
.text
%span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%span.date= activity_feed.created_at
%br
%span.subject #{ t("notifications.bodies.issue_assign_notification.title", :user_name => user_name) }
.both
.fulltext
= raw t("notifications.bodies.issue_assign_notification.content", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id)))

View File

@ -1,5 +1,16 @@
%p== #{ t("notifications.bodies.new_comment_notification.title", :user_name => user_name) }
%p= raw t("notifications.bodies.new_comment_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))})
%p "#{ comment_body }"
.top
.image
= image_tag(gravatar_url(activity_feed.user.email, 30))
.text
%span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%span.date= activity_feed.created_at
%br
%span.subject #{ t("notifications.bodies.new_comment_notification.title", :user_name => user_name) }
.both
.fulltext
= raw t("notifications.bodies.new_comment_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))})
%br
%br
"#{ comment_body }"

View File

@ -1,5 +1,16 @@
%p== #{ t("notifications.bodies.new_commit_comment_notification.title", :user_name => user_name) }
%p= raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_id, commit_id))})
%p "#{ comment_body }"
.top
.image
= image_tag(gravatar_url(activity_feed.user.email, 30))
.text
%span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%span.date= activity_feed.created_at
%br
%span.subject #{ t("notifications.bodies.new_commit_comment_notification.title", :user_name => user_name) }
.both
.fulltext
= raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_id, commit_id))})
%br
%br
"#{ comment_body }"

View File

@ -1,3 +1,13 @@
%p== #{ t("notifications.bodies.new_issue_notification.title", :user_name => user_name) }
%p= raw t("notifications.bodies.new_issue_notification.content", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id)), :project_link => link_to(project_name, project_path(project_id)))
.top
.image
= image_tag(gravatar_url(activity_feed.user.email, 30))
.text
%span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%span.date= activity_feed.created_at
%br
%span.subject #{ t("notifications.bodies.new_issue_notification.title", :user_name => user_name) }
.both
.fulltext
= raw t("notifications.bodies.new_issue_notification.content", :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id)), :project_link => link_to(project_name, project_path(project_id)))

View File

@ -1,5 +1,15 @@
%p== #{ t("notifications.bodies.new_user_notification.title", :user_name => user_name) }
%p #{ t("notifications.bodies.new_user_notification.content") }
%p #{ t("notifications.bodies.new_user_notification.email", :user_email => user_email) }
.top
.image
= image_tag(gravatar_url(activity_feed.user.email, 30))
.text
%span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%span.date= activity_feed.created_at
%br
%span.subject #{ t("notifications.bodies.new_user_notification.title", :user_name => user_name) }
.both
.fulltext
#{ t("notifications.bodies.new_user_notification.content") }
%br
#{ t("notifications.bodies.new_user_notification.email", :user_email => user_email) }

View File

@ -1,2 +1,17 @@
%p== User #{ link_to user_name, user_path(user_id) } has been update wiki #{ link_to "history", compare_versions_project_wiki_index_path(project_id, commit_sha) }
%p== Into project #{ link_to(project_name, project_path(project_id)) }
.top
.image
= image_tag(gravatar_url(activity_feed.user.email, 30))
.text
%span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%span.date= activity_feed.created_at
%br
%span.subject
-#TODO: Fix wiki compare routes.
-# User #{ link_to user_name, user_path(user_id) } has been update wiki #{ link_to "history", compare_versions_project_wiki_index_path(project_id, commit_sha) }
.both
.fulltext
-#TODO: Fix wiki compare routes.
-#%p== User #{ link_to user_name, user_path(user_id) } has been update wiki #{ link_to "history", compare_versions_project_wiki_index_path(project_id, commit_sha) }
Into project #{ link_to(project_name, project_path(project_id)) }

View File

@ -2,6 +2,11 @@ en:
layout:
activity_feed:
header: Activity Feed
my_last_projects: My last projects
all_my_projects: All my projects
all_my_builds: All my builds
my_builds_by_day: My buils for last 24 hours
new_project: Create project
notifications:
subjects:

View File

@ -1,7 +1,12 @@
ru:
layout:
activity_feed:
header: Лента активности
activity_feed:
header: Лента активности
my_last_projects: Мои последние проекты
all_my_projects: Все мои проекты
all_my_builds: Все мои сборки
my_builds_by_day: Мои сборки за 24 часа
new_project: Создать проект
notifications:
subjects:
@ -28,4 +33,4 @@ ru:
issue_assign_notification:
title: Здравствуйте, %{user_name}.
content: Вам была назначена задача %{issue_link}
invite_approve_notification: Приглашение в ABF
invite_approve_notification: Приглашение в ABF