activity feed: show a "pull request" instead a "issue"; small refactoring

This commit is contained in:
Alexander Machehin 2015-05-08 15:47:30 +05:00
parent 5798acaa27
commit 87802c8ba1
11 changed files with 51 additions and 22 deletions

View File

@ -4,6 +4,15 @@ ActivityController = ($scope, $http, $timeout, $q, $filter, $location, ActivityF
return vm.tracker_tab if kind is 'tracker'
return vm.pull_requests_tab if kind is 'pull_requests'
calculateChangeDate = (feed)->
prev_date = null
_.each(feed, (event)->
cur_date = $filter('amDateFormat')(event.date, 'll')
event.is_date_changed = cur_date isnt prev_date
prev_date = cur_date
)
vm = this
@ -111,14 +120,6 @@ ActivityController = ($scope, $http, $timeout, $q, $filter, $location, ActivityF
vm.getCurActivity = ()->
vm.current_activity_tab[vm.current_activity_tab.filter]
vm.needShowTimeLabel = (index)->
feed = vm.getCurActivity().feed
return false unless feed
cur_date = $filter('amDateFormat')(feed[index].date, 'll')
prev_date = index is 0 or $filter('amDateFormat')(feed[index-1].date, 'll')
return cur_date isnt prev_date
vm.getTemplate = (content)->
content.kind + '.html'
@ -149,8 +150,11 @@ ActivityController = ($scope, $http, $timeout, $q, $filter, $location, ActivityF
path = Routes.own_activity_path(options)
$http.get(path).then (res)->
vm.getCurActivity().feed = res.data.feed
feed = res.data.feed
vm.getCurActivity().feed = feed
vm.getCurActivity().next_page_link = res.data.next_page_link
calculateChangeDate(feed)
true
vm.setIssuesFilter = (kind, issues_filter)->
filter = getIssuesTab(kind).filter

View File

@ -27,12 +27,14 @@ var _locales = {
'pull_requests.filter.created': '<%= I18n.t('layout.pull_requests.created') %>',
'notification.new_comment.title': 'добавил новый комментарий к задаче ',
'notification.new_pull_comment.title': 'добавил новый комментарий к пул реквесту ',
'notification.new_commit_comment.title': 'добавил новый комментарий к коммиту ',
'notification.push.delete_branch': 'удалил ветку ',
'notification.push.create_branch': 'создал новую ветку ',
'notification.push.update_branch': 'внес изменения в ветку ',
'notification.in_project': ' в проекте ',
'notification.new_issue': 'добавил новую задачу',
'notification.new_issue': 'добавил новую задачу ',
'notification.new_pull': 'добавил новый пул реквест ',
'notification.new_user.title': 'Здравствуйте, ',
'notification.new_user.content': 'Спасибо за вашу регистрацию!',
'notification.wiki.new_commit': 'обновил ',
@ -73,12 +75,14 @@ var _locales = {
'pull_requests.filter.created': '<%= I18n.t('layout.pull_requests.created') %>',
'notification.new_comment.title': 'added a new comment in issue ',
'notification.new_pull_comment.title': 'added a new comment in pull request ',
'notification.new_commit_comment.title': 'added a new comment in commit ',
'notification.push.delete_branch': 'deleted a branch ',
'notification.push.create_branch': 'created a new branch ',
'notification.push.update_branch': 'pushed to branch ',
'notification.in_project': ' in project ',
'notification.new_issue': 'added a new issue ',
'notification.new_pull': 'added a new pull request ',
'notification.new_user.title': 'Hello, ',
'notification.new_user.content': 'Thank you for your registration!',
'notification.wiki.new_commit': 'has been updated ',

View File

@ -13,6 +13,6 @@
%p
{{'notification.build_list' | i18n}}
%a{ 'ng-href' => "{{item.build_list.link}}" } {{item.build_list.id}}
{{ item.branch_name + ('notification.in_project' | i18n)}}
{{'notification.in_project' | i18n}}
%a{ 'ng-href' => "{{item.project_link}}" } {{item.project_name_with_owner}}
{{item.build_list.status_message}}

View File

@ -12,7 +12,8 @@
.timeline-body
%p
{{'notification.push.' + item.change_type + '_branch' | i18n}}
{{ item.branch_name + ('notification.in_project' | i18n)}}
%a{ 'ng-href' => "{{item.branch_link}}" } {{item.branch_name}}
{{'notification.in_project' | i18n}}
%a{ 'ng-href' => "{{item.project_link}}" } {{item.project_name_with_owner}}
.timeline-footer

View File

@ -11,7 +11,8 @@
.clearfix
.timeline-body
%p
{{'notification.new_comment.title' | i18n}}
%span{'ng-show' => 'item.issue.is_pull'} {{'notification.new_pull_comment.title' | i18n}}
%span{'ng-show' => '!item.issue.is_pull'} {{'notification.new_comment.title' | i18n}}
%a{ 'ng-href' => "{{item.issue.link}}" } {{item.issue.title}}
%blockquote{ 'ng-bind-html' => "item.body" }
@ -19,4 +20,3 @@
.timeline-footer
%a.btn.btn-primary.btn-xs{ 'ng-href' => "{{item.issue.link + '#comment' + item.issue.read_more}}" }
{{'read_more' | i18n}}
{{item.kind}}

View File

@ -11,6 +11,8 @@
.clearfix
.timeline-body
%p
{{('notification.new_issue' | i18n) + ('notification.in_project' | i18n)}}
%span{'ng-show' => 'item.issue.is_pull'} {{'notification.new_pull' | i18n}}
%span{'ng-show' => '!item.issue.is_pull'} {{'notification.new_issue' | i18n}}
{{'notification.in_project' | i18n}}
%a{ 'ng-href' => "{{item.project_link}}" } {{item.project_name_with_owner}}
%a{ 'ng-href' => "{{item.issue.link}}" } {{item.issue.title}}
%a{ 'ng-href' => "{{item.issue.link}}" } {{item.issue.title}}

View File

@ -7,7 +7,7 @@ tabset
ul.timeline
/ timeline time label
li.time-label ng-repeat-start= 'item in actCtrl.getCurActivity().feed'
span ng-show= "actCtrl.needShowTimeLabel($index)"
span ng-show= "item.is_date_changed"
| {{item.date | amDateFormat:'ll'}}
/ timeline item
li ng-include= "actCtrl.getTemplate(item)"

View File

@ -19,7 +19,7 @@ json.feed do
end if user
project_name_with_owner = "#{item.project_owner}/#{item.project_name}"
@project = Project.find_by_owner_and_name(item.data[:project_owner], item.data[:project_name])
@project = Project.find_by_owner_and_name(project_name_with_owner)
json.project_name_with_owner project_name_with_owner
json.partial! item.partial, item: item, project_name_with_owner: project_name_with_owner

View File

@ -1,6 +1,7 @@
json.change_type item.data[:change_type]
json.change_type item.data[:change_type]
json.project_link project_path(project_name_with_owner)
json.branch_name item.data[:branch_name]
json.branch_name item.data[:branch_name]
json.branch_link ref_path(@project, item.data[:branch_name])
json.last_commits do
json.array! item.data[:last_commits] do |commit|

View File

@ -1,5 +1,13 @@
json.issue do
json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id]) if item.data[:issue_serial_id].present?
if item.data[:issue_serial_id].present?
is_pull = @project.issues.where(serial_id: item.data[:issue_serial_id]).joins(:pull_request).exists?
json.is_pull is_pull
if is_pull
json.link project_pull_request_path(project_name_with_owner, item.data[:issue_serial_id])
else
json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id])
end
end
json.title short_message(item.data[:issue_title], 50)
json.read_more item.data[:comment_id]
end

View File

@ -1,5 +1,14 @@
json.project_link project_path(project_name_with_owner)
json.issue do
json.title item.data[:issue_title]
json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id]) if item.data[:issue_serial_id].present?
if item.data[:issue_serial_id].present?
is_pull = @project.issues.where(serial_id: item.data[:issue_serial_id]).joins(:pull_request).exists?
json.is_pull is_pull
if is_pull
json.link project_pull_request_path(project_name_with_owner, item.data[:issue_serial_id])
else
json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id])
end
end
end