Commit 1b6a3dfe authored by randx's avatar randx
Browse files

Move all stuff to groups controller

parent 9faddc129dc4
......@@ -13,6 +13,8 @@
font-size:16px;
text-shadow: 0 1px 1px #fff;
padding: 2px 10px;
line-height:32px;
font-size:14px;
}
ul {
li {
......
......@@ -3,21 +3,14 @@ class DashboardController < ApplicationController
def index
@groups = Group.where(id: current_user.projects.pluck(:group_id))
@projects = current_user.projects_with_events
if params[:group].present?
@group = Group.find_by_code(params[:group])
@projects = @projects.where(group_id: @group.id)
end
@projects = @projects.page(params[:page]).per(40)
@events = Event.recent_for_user(current_user).limit(20).offset(params[:offset] || 0)
@last_push = current_user.recent_push
respond_to do |format|
format.html { render 'index', layout: determine_layout }
format.html
format.js
format.atom { render layout: false }
end
......@@ -41,10 +34,4 @@ def issues
format.atom { render layout: false }
end
end
protected
def determine_layout
@group ? 'group' : 'application'
end
end
class GroupsController < ApplicationController
respond_to :html
layout 'group'
before_filter :group
before_filter :projects
def show
@events = Event.where(project_id: project_ids).
order('id DESC').
limit(20).offset(params[:offset] || 0)
@last_push = current_user.recent_push
respond_to do |format|
format.html
format.js
format.atom { render layout: false }
end
end
# Get authored or assigned open merge requests
def merge_requests
@merge_requests = current_user.cared_merge_requests.order("created_at DESC").page(params[:page]).per(20)
end
# Get only assigned issues
def issues
@user = current_user
@issues = current_user.assigned_issues.opened.order("created_at DESC").page(params[:page]).per(20)
@issues = @issues.includes(:author, :project)
respond_to do |format|
format.html
format.atom { render layout: false }
end
end
def search
query = params[:search]
@merge_requests = []
@issues = []
if query.present?
@projects = @projects.search(query).limit(10)
@merge_requests = MergeRequest.where(project_id: project_ids).search(query).limit(10)
@issues = Issue.where(project_id: project_ids).search(query).limit(10)
end
end
def people
@users = group.projects.map(&:users).flatten.uniq
end
protected
def group
@group ||= Group.find_by_code(params[:id])
end
def projects
@projects ||= current_user.projects_with_events.where(group_id: @group.id)
end
def project_ids
projects.map(&:id)
end
end
......@@ -6,7 +6,7 @@
%ul.unstyled
- groups.each do |group|
%li.wll
= link_to dashboard_path(group: group), class: dom_class(group) do
= link_to group_path(id: group.code), class: dom_class(group) do
%strong.group_name= truncate(group.name, length: 25)
%span.arrow
&rarr;
......
......@@ -9,7 +9,7 @@
.loading.hide
.side
= render "events/event_last_push", event: @last_push
- unless @group
- if @groups.present?
= render "groups", groups: @groups
= render "projects", projects: @projects
%div
......
.projects_box
%h5
Projects
%small
(#{projects.count})
- if current_user.can_create_project?
%span.right
= link_to new_project_path, class: "btn very_small info" do
%i.icon-plus
New Project
%ul.unstyled
- projects.each do |project|
%li.wll
= link_to project_path(project), class: dom_class(project) do
%strong.project_name= truncate(project.name, length: 25)
%span.arrow
&rarr;
%span.last_activity
%strong Last activity:
%span= project_last_activity(project)
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
xml.title "#{@user.name} issues"
xml.link :href => dashboard_issues_url(:atom, :private_token => @user.private_token), :rel => "self", :type => "application/atom+xml"
xml.link :href => dashboard_issues_url(:private_token => @user.private_token), :rel => "alternate", :type => "text/html"
xml.id dashboard_issues_url(:private_token => @user.private_token)
xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any?
@issues.each do |issue|
xml.entry do
xml.id project_issue_url(issue.project, issue)
xml.link :href => project_issue_url(issue.project, issue)
xml.title truncate(issue.title, :length => 80)
xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(issue.author_email)
xml.author do |author|
xml.name issue.author_name
xml.email issue.author_email
end
xml.summary issue.title
end
end
end
%h3.page_title
Issues
%small (assigned to you)
%small.right #{@issues.total_count} issues
%br
.clearfix
- if @issues.any?
- @issues.group_by(&:project).each do |group|
%div.ui-box
- @project = group[0]
%h5= @project.name
%ul.unstyled.issues_table
- group[1].each do |issue|
= render(partial: 'issues/show', locals: {issue: issue})
%hr
= paginate @issues, theme: "gitlab"
- else
%h3.nothing_here_message Nothing to show here
%h3.page_title
Merge Requests
%small (authored by or assigned to you)
%small.right #{@merge_requests.total_count} merge requests
%br
- if @merge_requests.any?
- @merge_requests.group_by(&:project).each do |group|
%ul.unstyled.ui-box
- @project = group[0]
%h5= @project.name
- group[1].each do |merge_request|
= render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request})
%hr
= paginate @merge_requests, theme: "gitlab"
- else
%h3.nothing_here_message Nothing to show here
.ui-box
%h5
People
%small
(#{@users.count})
%ul.unstyled
- @users.each do |user|
%li.wll
= image_tag gravatar_icon(user.email, 16), class: "avatar s16"
%strong= user.name
%span.cgray= user.email
= form_tag search_group_path(@group), method: :get, class: 'form-inline' do |f|
.padded
= label_tag :search do
%strong Looking for
.input
= search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search"
= submit_tag 'Search', class: "btn primary wide"
- if params[:search].present?
%br
%h3
Search results
%small (#{@projects.count + @merge_requests.count + @issues.count})
%hr
.search_results
.row
.span6
%table
%thead
%tr
%th Projects
%tbody
- @projects.each do |project|
%tr
%td
= link_to project do
%strong.term= project.name
%small.cgray
last activity at
= project.last_activity_date.stamp("Aug 25, 2011")
- if @projects.blank?
%tr
%td
%h4.nothing_here_message No Projects
%br
%table
%thead
%tr
%th Merge Requests
%tbody
- @merge_requests.each do |merge_request|
%tr
%td
= link_to [merge_request.project, merge_request] do
%span.badge.badge-info ##{merge_request.id}
&ndash;
%strong.term= truncate merge_request.title, length: 50
%strong.right
%span.label= merge_request.project.name
- if @merge_requests.blank?
%tr
%td
%h4.nothing_here_message No Merge Requests
.span6
%table
%thead
%tr
%th Issues
%tbody
- @issues.each do |issue|
%tr
%td
= link_to [issue.project, issue] do
%span.badge.badge-info ##{issue.id}
&ndash;
%strong.term= truncate issue.title, length: 40
%strong.right
%span.label= issue.project.name
- if @issues.blank?
%tr
%td
%h4.nothing_here_message No Issues
:javascript
$(function() {
$(".search_results .term").highlight("#{params[:search]}");
})
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
xml.title "Dashboard feed#{" - #{current_user.name}" if current_user.name.present?}"
xml.link :href => projects_url(:atom), :rel => "self", :type => "application/atom+xml"
xml.link :href => projects_url, :rel => "alternate", :type => "text/html"
xml.id projects_url
xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any?
@events.each do |event|
if event.allowed?
event = EventDecorator.decorate(event)
xml.entry do
event_link = event.feed_url
event_title = event.feed_title
xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}"
xml.link :href => event_link
xml.title truncate(event_title, :length => 80)
xml.updated event.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(event.author_email)
xml.author do |author|
xml.name event.author_name
xml.email event.author_email
end
xml.summary event_title
end
end
end
end
- if @projects.any?
.projects
.activities.span8
= render 'shared/no_ssh'
- if @events.any?
.content_list= render @events
- else
%h4.nothing_here_message Projects activity will be displayed here
.loading.hide
.side
= render "events/event_last_push", event: @last_push
= render "projects", projects: @projects
%div
%span.rss-icon
= link_to dashboard_path(:atom, { private_token: current_user.private_token }) do
= image_tag "rss_ui.png", title: "feed"
%strong News Feed
%hr
.gitlab-promo
= link_to "Homepage", "http://gitlabhq.com"
= link_to "Blog", "http://blog.gitlabhq.com"
= link_to "@gitlabhq", "https://twitter.com/gitlabhq"
- else
%h3.nothing_here_message There are no projects you have access to.
%br
%h4.nothing_here_message
- if current_user.can_create_project?
You can create up to
= current_user.projects_limit
projects. Click on button below to add a new one
.link_holder
= link_to new_project_path, class: "btn primary" do
New Project »
- else
If you will be added to project - it will be displayed here
:javascript
$(function(){ Pager.init(20); });
:plain
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
......@@ -3,22 +3,22 @@
= render "layouts/head"
%body{class: "#{app_theme} application"}
= render "layouts/flash"
= render "layouts/head_panel", title: "#{@group.name}:Dashboard"
= render "layouts/head_panel", title: "#{@group.name}"
.container
%ul.main_menu
= nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do
= link_to "Home", root_path, title: "Home"
= nav_link(path: 'dashboard#issues') do
= link_to dashboard_issues_path(group: @group) do
= nav_link(path: 'groups#show', html_options: {class: 'home'}) do
= link_to "Home", group_path(@group), title: "Home"
= nav_link(path: 'groups#issues') do
= link_to issues_group_path(@group) do
Issues
%span.count= current_user.assigned_issues.opened.count
= nav_link(path: 'dashboard#merge_requests') do
= link_to dashboard_merge_requests_path(group: @group) do
= nav_link(path: 'groups#merge_requests') do
= link_to merge_requests_group_path(@group) do
Merge Requests
%span.count= current_user.cared_merge_requests.count
= nav_link(path: 'search#show') do
= link_to "People", "#"
= nav_link(path: 'help#index') do
= link_to "Help", help_path
= nav_link(path: 'groups#search') do
= link_to "Search", search_group_path(@group)
= nav_link(path: 'groups#people') do
= link_to "People", people_group_path(@group)
.content= yield
......@@ -86,6 +86,19 @@
get "dashboard/issues" => "dashboard#issues"
get "dashboard/merge_requests" => "dashboard#merge_requests"
#
# Groups Area
#
resources :groups, constraints: { id: /[^\/]+/ }, only: [:show] do
member do
get :issues
get :merge_requests
get :search
get :people
end
end
resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks }
......
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