Merge pull request #128 from abf/rosa-build:98-common_tracker

[refs #98] common tracker for issues and pull requests
This commit is contained in:
warpc 2013-05-16 12:29:14 +04:00
commit d092a355a3
35 changed files with 138 additions and 39 deletions

View File

@ -2026,3 +2026,11 @@ article .activity .top {
} }
th { text-align: center; } th { text-align: center; }
} }
.activity-tabs {
margin: 10px 0 0 0;
background: none;
-webkit-box-shadow: 0;
-moz-box-shadow: 0;
box-shadow: 0;
}

View File

@ -1,15 +0,0 @@
# -*- encoding : utf-8 -*-
class ActivityFeedsController < ApplicationController
before_filter :authenticate_user!
def index
@filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all
@activity_feeds = current_user.activity_feeds
@activity_feeds = @activity_feeds.where(:kind => "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all
@activity_feeds = @activity_feeds.paginate :page => params[:page]
respond_to do |format|
format.html { request.xhr? ? render('_list', :layout => false) : render('index') }
format.atom
end
end
end

View File

@ -0,0 +1,62 @@
# -*- encoding : utf-8 -*-
class HomeController < ApplicationController
before_filter :authenticate_user!, :only => [:activity, :issues, :pull_requests]
def root
render 'pages/tour/abf-tour-project-description-1', :layout => 'tour'
end
def activity
@filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all
@activity_feeds = current_user.activity_feeds
@activity_feeds = @activity_feeds.where(:kind => "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all
@activity_feeds = @activity_feeds.paginate :page => params[:page]
respond_to do |format|
format.html { request.xhr? ? render('_list', :layout => false) : render('activity') }
format.atom
end
end
def issues
@created_issues = current_user.issues
@assigned_issues = Issue.where(:assignee_id => current_user.id)
pr_ids = Project.accessible_by(current_ability, :membered).uniq.pluck(:id)
@all_issues = Issue.where(:project_id => pr_ids)
@created_issues, @assigned_issues, @all_issues =
if action_name == 'issues'
[@created_issues.without_pull_requests,
@assigned_issues.without_pull_requests,
@all_issues.without_pull_requests]
else
[@created_issues.joins(:pull_request),
@assigned_issues.joins(:pull_request),
@all_issues.joins(:pull_request)]
end
case params[:filter]
when 'created'
@issues = @created_issues
when 'assigned'
@issues = @assigned_issues
else
params[:filter] = 'all' # default
@issues = @all_issues
end
@filter = params[:filter]
@opened_issues, @closed_issues = @issues.not_closed_or_merged.count, @issues.closed_or_merged.count
@status = params[:status] == 'closed' ? :closed : :open
@issues = @issues.send( (@status == :closed) ? :closed_or_merged : :not_closed_or_merged )
@sort = params[:sort] == 'updated' ? :updated : :created
@direction = params[:direction] == 'asc' ? :asc : :desc
@issues = @issues.order("issues.#{@sort}_at #{@direction}")
.includes(:assignee, :user, :pull_request).uniq
.paginate :per_page => 20, :page => params[:page]
render 'issues', :layout => request.xhr? ? 'with_sidebar' : 'application'
end
def pull_requests
issues
end
end

View File

@ -1,11 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class PagesController < ApplicationController class PagesController < ApplicationController
# before_filter :authenticate_user!, :except => [:show, :main, :forbidden]
# load_and_authorize_resource
def root
render 'pages/tour/abf-tour-project-description-1', :layout => 'tour'
end
def tour_inside def tour_inside
@entries = case params[:id] @entries = case params[:id]

View File

@ -13,7 +13,7 @@ class Projects::IssuesController < Projects::BaseController
def index(status = 200) def index(status = 200)
@labels = params[:labels] || [] @labels = params[:labels] || []
@issues = @project.issues.without_pull_requests @issues = @project.issues.without_pull_requests
@issues = @issues.where(:assignee_id => current_user.id) if @is_assigned_to_me = params[:filter] == 'to_me' @issues = @issues.where(:assignee_id => current_user.id) if @is_assigned_to_me = params[:filter] == 'assigned'
@issues = @issues.joins(:labels).where(:labels => {:name => @labels}) unless @labels == [] @issues = @issues.joins(:labels).where(:labels => {:name => @labels}) unless @labels == []
# Using mb_chars for correct transform to lowercase ('Русский Текст'.downcase => "Русский Текст") # Using mb_chars for correct transform to lowercase ('Русский Текст'.downcase => "Русский Текст")
@issues = @issues.search(params[:search_issue]) if params[:search_issue] !~ /#{t('layout.issues.search')}/ @issues = @issues.search(params[:search_issue]) if params[:search_issue] !~ /#{t('layout.issues.search')}/

View File

@ -1,6 +1,6 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class Users::UsersController < Users::BaseController class Users::UsersController < Users::BaseController
skip_before_filter :authenticate_user! skip_before_filter :authenticate_user!, :only => [:allowed, :check, :discover]
before_filter :find_user_by_key, :only => [:allowed, :discover] before_filter :find_user_by_key, :only => [:allowed, :discover]
def allowed def allowed

View File

@ -15,7 +15,7 @@ class ActivityFeed < ActiveRecord::Base
self.per_page = 10 self.per_page = 10
def partial def partial
'activity_feeds/partials/' + self.kind 'home/partials/' + self.kind
end end
end end

View File

@ -28,6 +28,7 @@ class User < Avatar
has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy
has_many :issues
has_many :assigned_issues, :foreign_key => :assignee_id, :class_name => 'Issue', :dependent => :nullify has_many :assigned_issues, :foreign_key => :assignee_id, :class_name => 'Issue', :dependent => :nullify
has_many :key_pairs has_many :key_pairs

View File

@ -1,4 +1,4 @@
.sub-menu .sub-menu.activity-tabs
%nav %nav
%ul %ul
- (collection = t 'feed_menu').each do |base, title| - (collection = t 'feed_menu').each do |base, title|

View File

@ -0,0 +1,7 @@
- content_for :feed_tabs do
.sub-menu
%nav
%ul
%li= link_to t('activity_menu.activity_feed'), root_path, :class => action_name == 'activity' ? 'active' : ''
%li= link_to t('activity_menu.tracker'), issues_path, :class => action_name == 'issues' ? 'active' : ''
%li= link_to t('activity_menu.pull_requests'), pull_requests_path, :class => action_name == 'pull_requests' ? 'active' : ''

View File

@ -2,7 +2,8 @@
%h3.fix %h3.fix
= t("layout.activity_feed.header") = t("layout.activity_feed.header")
= link_to image_tag("rss.ico", :width => '15px', :height => '15px', :class => 'atom_icon'), atom_activity_feeds_path(:format => 'atom', :token => current_user.authentication_token) = link_to image_tag("rss.ico", :width => '15px', :height => '15px', :class => 'atom_icon'), atom_activity_feeds_path(:format => 'atom', :token => current_user.authentication_token)
=render 'feed_tabs'
=render 'list' =render 'list'
- content_for :sidebar, render('sidebar') - content_for :sidebar, render('sidebar')
- content_for :feed_tabs, render('feed_tabs') - render 'top_menu'

View File

@ -0,0 +1,12 @@
-set_meta_tags :title => t("users.users.#{action_name}_index.title")
-render 'top_menu'
-content_for :sidebar do
=form_tag send("#{action_name}_path"), :id => 'filter_issues', :method => :get do
.bordered
%table
-%w[all assigned created].each do |filter|
%tr
%td.width18=radio_button_tag :myradio, filter, filter == @filter, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'}
%td.width135=t("layout.#{action_name}.#{filter}")
%td.width30.right=instance_variable_get("@#{filter}_issues").count
=render 'projects/issues/issues_table', :issues => @issues

View File

@ -5,11 +5,11 @@
%table %table
%tr %tr
%td.width18=radio_button_tag :myradio, 'all', !@is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'} %td.width18=radio_button_tag :myradio, 'all', !@is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'}
%td.width135=t("layout.issues.all") %td.width135=t('layout.issues.all')
%td.width30.right=@project.issues.without_pull_requests.count %td.width30.right=@project.issues.without_pull_requests.count
%tr %tr
%td=radio_button_tag :myradio, 'to_me', @is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'} %td=radio_button_tag :myradio, 'assigned', @is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'}
%td=t("layout.issues.to_me") %td=t('layout.issues.assigned')
%td.width30.right=@project.issues.without_pull_requests.where(:assignee_id => current_user.id).count %td.width30.right=@project.issues.without_pull_requests.where(:assignee_id => current_user.id).count
=form_tag project_issues_path(@project), :id => 'search_issue', :class => 'ajax_search_form', :method => :get do =form_tag project_issues_path(@project), :id => 'search_issue', :class => 'ajax_search_form', :method => :get do
.bordered.bpadding20 .bordered.bpadding20

View File

@ -1,4 +1,4 @@
- path = polymorphic_path [@project, issue.pull_request ? issue.pull_request : issue] - path = polymorphic_path [@project || issue.project, issue.pull_request ? issue.pull_request : issue]
%tr#row1{:name => "row", :class => issue.labels.map(&:name).compact} %tr#row1{:name => "row", :class => issue.labels.map(&:name).compact}
%td.td0 %td.td0
@ -6,7 +6,9 @@
%td.td1=issue.serial_id %td.td1=issue.serial_id
%td %td
%a{:href => path} %a{:href => path}
%div.issue_title=issue.title %div.issue_title
-prefix = @project ? '' : "<span style=\"color: #999;\">#{issue.project.name}</span>: "
="#{prefix} #{issue.title}".html_safe
.smalltext .smalltext
=issue.send(@sort == :created ? :created_at : :updated_at).to_s(:long) =issue.send(@sort == :created ? :created_at : :updated_at).to_s(:long)
=t("layout.by") if issue.user =t("layout.by") if issue.user

View File

@ -35,6 +35,10 @@ en:
readme: Readme readme: Readme
settings: Settings settings: Settings
pull_requests: Pull Requests (%{count}) pull_requests: Pull Requests (%{count})
activity_menu:
activity_feed: Activity Feed
tracker: Tracker
pull_requests: Pull Requests
feed_menu: feed_menu:
all: All all: All
code: Code code: Code

View File

@ -35,6 +35,10 @@ ru:
readme: Readme readme: Readme
settings: Настройки settings: Настройки
pull_requests: Пул реквесты (%{count}) pull_requests: Пул реквесты (%{count})
activity_menu:
activity_feed: Лента активности
tracker: Трекер
pull_requests: Пул реквесты
feed_menu: feed_menu:
all: Все all: Все
code: Код code: Код

View File

@ -20,7 +20,8 @@ en:
assign_someone: Assign someone to this issue assign_someone: Assign someone to this issue
list: List list: List
all: All issues all: All issues
to_me: Assigned to me assigned: Assigned to me
created: Created by you
edit: Edit edit: Edit
search: Find issue... search: Find issue...
comments_header: Comments comments_header: Comments

View File

@ -20,7 +20,8 @@ ru:
assign_someone: Назначить кого-либо на задачу assign_someone: Назначить кого-либо на задачу
list: Список list: Список
all: Все задачи all: Все задачи
to_me: Назначенные мне assigned: Назначенные мне
created: Созданные мной
edit: Редактировать edit: Редактировать
search: Найти задачу... search: Найти задачу...
comments_header: Комментарии comments_header: Комментарии

View File

@ -60,4 +60,6 @@ en:
search: Find pull request... search: Find pull request...
all: All requests all: All requests
to_me: Assigned to me to_me: Assigned to me
assigned: Assigned to me
created: Created by you
view_full_changes: View full changes view_full_changes: View full changes

View File

@ -61,4 +61,6 @@ ru:
search: Найти пул реквест... search: Найти пул реквест...
all: Все пул реквесты all: Все пул реквесты
to_me: Назначенные мне to_me: Назначенные мне
assigned: Назначенные мне
created: Созданные мной
view_full_changes: Посмотреть все изменения view_full_changes: Посмотреть все изменения

View File

@ -33,3 +33,8 @@ en:
product_build_lists: product_build_lists:
index: index:
title: 'Products Monitoring' title: 'Products Monitoring'
pages:
issues:
title: 'Your Issues'
pull_requests:
title: 'Your Pull Requests'

View File

@ -33,3 +33,8 @@ ru:
product_build_lists: product_build_lists:
index: index:
title: 'Мониторинг продуктов' title: 'Мониторинг продуктов'
pages:
issues:
title: 'Ваши задачи'
pull_requests:
title: 'Ваши пул реквесты'

View File

@ -94,16 +94,19 @@ Rosa::Application.routes.draw do
get '/forbidden' => 'pages#forbidden', :as => 'forbidden' get '/forbidden' => 'pages#forbidden', :as => 'forbidden'
get '/terms-of-service' => 'pages#tos', :as => 'tos' get '/terms-of-service' => 'pages#tos', :as => 'tos'
get '/tour/:id' => 'pages#tour_inside', :as => 'tour_inside', :id => /projects|sources|builds/ get '/tour/:id' => 'pages#tour_inside', :as => 'tour_inside', :id => /projects|sources|builds/
match '/invite.html' => redirect('/register_requests/new') #match '/invite.html' => redirect('/register_requests/new')
get '/activity_feeds.:format' => 'home#activity', :as => 'atom_activity_feeds', :format => /atom/
get '/issues' => 'home#issues'
get '/pull_requests' => 'home#pull_requests'
get '/activity_feeds.:format' => 'activity_feeds#index', :as => 'atom_activity_feeds', :format => /atom/
if APP_CONFIG['anonymous_access'] if APP_CONFIG['anonymous_access']
authenticated do authenticated do
root :to => 'activity_feeds#index' root :to => 'home#activity'
end end
root :to => 'pages#root' root :to => 'home#root'
else else
root :to => 'activity_feeds#index' root :to => 'home#activity'
end end
namespace :admin do namespace :admin do