Merge branch 'feature/groups' of dev.gitlabhq.com:gitlabhq
This commit is contained in:
commit
9e80d2d4f7
|
@ -13,6 +13,8 @@
|
|||
font-size:16px;
|
||||
text-shadow: 0 1px 1px #fff;
|
||||
padding: 2px 10px;
|
||||
line-height:32px;
|
||||
font-size:14px;
|
||||
}
|
||||
ul {
|
||||
li {
|
||||
|
|
75
app/controllers/admin/groups_controller.rb
Normal file
75
app/controllers/admin/groups_controller.rb
Normal file
|
@ -0,0 +1,75 @@
|
|||
class Admin::GroupsController < AdminController
|
||||
before_filter :group, only: [:edit, :show, :update, :destroy, :project_update]
|
||||
|
||||
def index
|
||||
@groups = Group.scoped
|
||||
@groups = @groups.search(params[:name]) if params[:name].present?
|
||||
@groups = @groups.page(params[:page]).per(20)
|
||||
end
|
||||
|
||||
def show
|
||||
@projects = Project.scoped
|
||||
@projects = @projects.not_in_group(@group) if @group.projects.present?
|
||||
@projects = @projects.all
|
||||
end
|
||||
|
||||
def new
|
||||
@group = Group.new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@group = Group.new(params[:group])
|
||||
@group.owner = current_user
|
||||
|
||||
if @group.save
|
||||
redirect_to [:admin, @group], notice: 'Group was successfully created.'
|
||||
else
|
||||
render action: "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
group_params = params[:group].dup
|
||||
owner_id =group_params.delete(:owner_id)
|
||||
|
||||
if owner_id
|
||||
@group.owner = User.find(owner_id)
|
||||
end
|
||||
|
||||
if @group.update_attributes(group_params)
|
||||
redirect_to [:admin, @group], notice: 'Group was successfully updated.'
|
||||
else
|
||||
render action: "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def project_update
|
||||
project_ids = params[:project_ids]
|
||||
Project.where(id: project_ids).update_all(group_id: @group.id)
|
||||
|
||||
redirect_to :back, notice: 'Group was successfully updated.'
|
||||
end
|
||||
|
||||
def remove_project
|
||||
@project = Project.find(params[:project_id])
|
||||
@project.group_id = nil
|
||||
@project.save
|
||||
|
||||
redirect_to :back, notice: 'Group was successfully updated.'
|
||||
end
|
||||
|
||||
def destroy
|
||||
@group.destroy
|
||||
|
||||
redirect_to groups_url, notice: 'Group was successfully deleted.'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def group
|
||||
@group = Group.find_by_code(params[:id])
|
||||
end
|
||||
end
|
|
@ -2,7 +2,10 @@ class DashboardController < ApplicationController
|
|||
respond_to :html
|
||||
|
||||
def index
|
||||
@projects = current_user.projects_with_events.page(params[:page]).per(40)
|
||||
@groups = Group.where(id: current_user.projects.pluck(:group_id))
|
||||
@projects = current_user.projects_with_events
|
||||
@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
|
||||
|
||||
|
|
69
app/controllers/groups_controller.rb
Normal file
69
app/controllers/groups_controller.rb
Normal file
|
@ -0,0 +1,69 @@
|
|||
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.users
|
||||
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
|
36
app/models/group.rb
Normal file
36
app/models/group.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: groups
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) not null
|
||||
# code :string(255) not null
|
||||
# owner_id :integer not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class Group < ActiveRecord::Base
|
||||
attr_accessible :code, :name, :owner_id
|
||||
|
||||
has_many :projects
|
||||
belongs_to :owner, class_name: "User"
|
||||
|
||||
validates :name, presence: true, uniqueness: true
|
||||
validates :code, presence: true, uniqueness: true
|
||||
validates :owner_id, presence: true
|
||||
|
||||
delegate :name, to: :owner, allow_nil: true, prefix: true
|
||||
|
||||
def self.search query
|
||||
where("name like :query OR code like :query", query: "%#{query}%")
|
||||
end
|
||||
|
||||
def to_param
|
||||
code
|
||||
end
|
||||
|
||||
def users
|
||||
User.joins(:users_projects).where('users_projects.project_id' => project_ids).uniq
|
||||
end
|
||||
end
|
|
@ -11,6 +11,7 @@ class Project < ActiveRecord::Base
|
|||
attr_accessor :error_code
|
||||
|
||||
# Relations
|
||||
belongs_to :group
|
||||
belongs_to :owner, class_name: "User"
|
||||
has_many :users, through: :users_projects
|
||||
has_many :events, dependent: :destroy
|
||||
|
@ -25,16 +26,19 @@ class Project < ActiveRecord::Base
|
|||
has_many :wikis, dependent: :destroy
|
||||
has_many :protected_branches, dependent: :destroy
|
||||
|
||||
delegate :name, to: :owner, allow_nil: true, prefix: true
|
||||
|
||||
# Scopes
|
||||
scope :public_only, where(private_flag: false)
|
||||
scope :without_user, lambda { |user| where("id not in (:ids)", ids: user.projects.map(&:id) ) }
|
||||
scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) }
|
||||
scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
|
||||
|
||||
def self.active
|
||||
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
|
||||
end
|
||||
|
||||
def self.search query
|
||||
where("name like :query or code like :query or path like :query", query: "%#{query}%")
|
||||
where("name like :query OR code like :query OR path like :query", query: "%#{query}%")
|
||||
end
|
||||
|
||||
def self.create_by_user(params, user)
|
||||
|
@ -173,4 +177,6 @@ end
|
|||
# wall_enabled :boolean default(TRUE), not null
|
||||
# merge_requests_enabled :boolean default(TRUE), not null
|
||||
# wiki_enabled :boolean default(TRUE), not null
|
||||
# group_id :integer
|
||||
#
|
||||
|
||||
|
|
19
app/views/admin/groups/_form.html.haml
Normal file
19
app/views/admin/groups/_form.html.haml
Normal file
|
@ -0,0 +1,19 @@
|
|||
= form_for [:admin, @group] do |f|
|
||||
- if @group.errors.any?
|
||||
.alert-message.block-message.error
|
||||
%span= @group.errors.full_messages.first
|
||||
.clearfix.group_name_holder
|
||||
= f.label :name do
|
||||
Group name is
|
||||
.input
|
||||
= f.text_field :name, placeholder: "Example Group", class: "xxlarge"
|
||||
.clearfix
|
||||
= f.label :code do
|
||||
URL
|
||||
.input
|
||||
.input-prepend
|
||||
%span.add-on= web_app_url
|
||||
= f.text_field :code, placeholder: "example"
|
||||
|
||||
.form-actions
|
||||
= f.submit 'Save group', class: "btn save-btn"
|
3
app/views/admin/groups/edit.html.haml
Normal file
3
app/views/admin/groups/edit.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
%h3.page_title Edit Group
|
||||
%br
|
||||
= render 'form'
|
25
app/views/admin/groups/index.html.haml
Normal file
25
app/views/admin/groups/index.html.haml
Normal file
|
@ -0,0 +1,25 @@
|
|||
= render 'admin/shared/projects_head'
|
||||
%h3.page_title
|
||||
Groups
|
||||
= link_to 'New Group', new_admin_group_path, class: "btn small right"
|
||||
%br
|
||||
= form_tag admin_groups_path, method: :get, class: 'form-inline' do
|
||||
= text_field_tag :name, params[:name], class: "xlarge"
|
||||
= submit_tag "Search", class: "btn submit primary"
|
||||
|
||||
%table
|
||||
%thead
|
||||
%th Name
|
||||
%th Code
|
||||
%th Projects
|
||||
%th Edit
|
||||
%th.cred Danger Zone!
|
||||
|
||||
- @groups.each do |group|
|
||||
%tr
|
||||
%td= link_to group.name, [:admin, group]
|
||||
%td= group.code
|
||||
%td= group.projects.count
|
||||
%td= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small"
|
||||
%td.bgred= link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn small danger"
|
||||
= paginate @groups, theme: "admin"
|
3
app/views/admin/groups/new.html.haml
Normal file
3
app/views/admin/groups/new.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
%h3.page_title New Group
|
||||
%br
|
||||
= render 'form'
|
52
app/views/admin/groups/show.html.haml
Normal file
52
app/views/admin/groups/show.html.haml
Normal file
|
@ -0,0 +1,52 @@
|
|||
= render 'admin/shared/projects_head'
|
||||
%h3.page_title
|
||||
Group: #{@group.name}
|
||||
= link_to edit_admin_group_path(@group), class: "btn right" do
|
||||
%i.icon-edit
|
||||
Edit
|
||||
|
||||
%br
|
||||
%table.zebra-striped
|
||||
%thead
|
||||
%tr
|
||||
%th Group
|
||||
%th
|
||||
%tr
|
||||
%td
|
||||
%b
|
||||
Name:
|
||||
%td
|
||||
= @group.name
|
||||
%tr
|
||||
%td
|
||||
%b
|
||||
Code:
|
||||
%td
|
||||
= @group.code
|
||||
%tr
|
||||
%td
|
||||
%b
|
||||
Owner:
|
||||
%td
|
||||
= @group.owner_name
|
||||
.ui-box
|
||||
%h5
|
||||
Projects
|
||||
%small
|
||||
(#{@group.projects.count})
|
||||
%ul.unstyled
|
||||
- @group.projects.each do |project|
|
||||
%li.wll
|
||||
%strong
|
||||
= link_to project.name, [:admin, project]
|
||||
.right
|
||||
= link_to 'Remove from group', remove_project_admin_group_path(@group, project_id: project.id), confirm: 'Are you sure?', method: :delete, class: "btn danger small"
|
||||
.clearfix
|
||||
|
||||
%br
|
||||
%h3 Add new project
|
||||
%br
|
||||
= form_tag project_update_admin_group_path(@group), class: "bulk_import", method: :put do
|
||||
= select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5'
|
||||
.form-actions
|
||||
= submit_tag 'Add', class: "btn primary"
|
|
@ -1,3 +1,4 @@
|
|||
= render 'admin/shared/projects_head'
|
||||
%h3.page_title
|
||||
Projects
|
||||
= link_to 'New Project', new_admin_project_path, class: "btn small right"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
= render 'admin/shared/projects_head'
|
||||
%h3.page_title
|
||||
Project: #{@admin_project.name}
|
||||
= link_to edit_admin_project_path(@admin_project), class: "btn right" do
|
||||
|
|
5
app/views/admin/shared/_projects_head.html.haml
Normal file
5
app/views/admin/shared/_projects_head.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
%ul.nav.nav-tabs
|
||||
= nav_link(controller: :projects) do
|
||||
= link_to 'Projects', admin_projects_path, class: "tab"
|
||||
= nav_link(controller: :groups) do
|
||||
= link_to 'Groups', admin_groups_path, class: "tab"
|
15
app/views/dashboard/_groups.html.haml
Normal file
15
app/views/dashboard/_groups.html.haml
Normal file
|
@ -0,0 +1,15 @@
|
|||
.projects_box
|
||||
%h5
|
||||
Groups
|
||||
%small
|
||||
(#{groups.count})
|
||||
%ul.unstyled
|
||||
- groups.each do |group|
|
||||
%li.wll
|
||||
= link_to group_path(id: group.code), class: dom_class(group) do
|
||||
%strong.group_name= truncate(group.name, length: 25)
|
||||
%span.arrow
|
||||
→
|
||||
%span.last_activity
|
||||
%strong Projects:
|
||||
%span= group.projects.count
|
21
app/views/dashboard/_projects.html.haml
Normal file
21
app/views/dashboard/_projects.html.haml
Normal file
|
@ -0,0 +1,21 @@
|
|||
.projects_box
|
||||
%h5
|
||||
Projects
|
||||
%small
|
||||
(#{projects.total_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
|
||||
→
|
||||
%span.last_activity
|
||||
%strong Last activity:
|
||||
%span= project_last_activity(project)
|
||||
.bottom= paginate projects, theme: "gitlab"
|
|
@ -9,28 +9,9 @@
|
|||
.loading.hide
|
||||
.side
|
||||
= render "events/event_last_push", event: @last_push
|
||||
.projects_box
|
||||
%h5
|
||||
Projects
|
||||
%small
|
||||
(#{@projects.total_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
|
||||
→
|
||||
%span.last_activity
|
||||
%strong Last activity:
|
||||
%span= project_last_activity(project)
|
||||
.bottom= paginate @projects, theme: "gitlab"
|
||||
|
||||
- if @groups.present?
|
||||
= render "groups", groups: @groups
|
||||
= render "projects", projects: @projects
|
||||
%div
|
||||
%span.rss-icon
|
||||
= link_to dashboard_path(:atom, { private_token: current_user.private_token }) do
|
||||
|
|
15
app/views/groups/_projects.html.haml
Normal file
15
app/views/groups/_projects.html.haml
Normal file
|
@ -0,0 +1,15 @@
|
|||
.projects_box
|
||||
%h5
|
||||
Projects
|
||||
%small
|
||||
(#{projects.count})
|
||||
%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
|
||||
→
|
||||
%span.last_activity
|
||||
%strong Last activity:
|
||||
%span= project_last_activity(project)
|
24
app/views/groups/issues.atom.builder
Normal file
24
app/views/groups/issues.atom.builder
Normal file
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
|
19
app/views/groups/issues.html.haml
Normal file
19
app/views/groups/issues.html.haml
Normal file
|
@ -0,0 +1,19 @@
|
|||
%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
|
18
app/views/groups/merge_requests.html.haml
Normal file
18
app/views/groups/merge_requests.html.haml
Normal file
|
@ -0,0 +1,18 @@
|
|||
%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
|
12
app/views/groups/people.html.haml
Normal file
12
app/views/groups/people.html.haml
Normal file
|
@ -0,0 +1,12 @@
|
|||
.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
|
||||
|
75
app/views/groups/search.html.haml
Normal file
75
app/views/groups/search.html.haml
Normal file
|
@ -0,0 +1,75 @@
|
|||
= 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}
|
||||
–
|
||||
%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}
|
||||
–
|
||||
%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]}");
|
||||
})
|
29
app/views/groups/show.atom.builder
Normal file
29
app/views/groups/show.atom.builder
Normal file
|
@ -0,0 +1,29 @@
|
|||
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
|
30
app/views/groups/show.html.haml
Normal file
30
app/views/groups/show.html.haml
Normal file
|
@ -0,0 +1,30 @@
|
|||
.projects
|
||||
.activities.span8
|
||||
= link_to dashboard_path, class: 'btn very_small' do
|
||||
← To dashboard
|
||||
|
||||
%span.cgray Events and projects are filtered in scope of group
|
||||
%hr
|
||||
= 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"
|
||||
|
||||
:javascript
|
||||
$(function(){ Pager.init(20); });
|
2
app/views/groups/show.js.haml
Normal file
2
app/views/groups/show.js.haml
Normal file
|
@ -0,0 +1,2 @@
|
|||
:plain
|
||||
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
|
|
@ -8,7 +8,7 @@
|
|||
%ul.main_menu
|
||||
= nav_link(controller: :dashboard, html_options: {class: 'home'}) do
|
||||
= link_to "Stats", admin_root_path
|
||||
= nav_link(controller: :projects) do
|
||||
= nav_link(controller: [:projects, :groups]) do
|
||||
= link_to "Projects", admin_projects_path
|
||||
= nav_link(controller: :users) do
|
||||
= link_to "Users", admin_users_path
|
||||
|
|
24
app/views/layouts/group.html.haml
Normal file
24
app/views/layouts/group.html.haml
Normal file
|
@ -0,0 +1,24 @@
|
|||
!!! 5
|
||||
%html{ lang: "en"}
|
||||
= render "layouts/head"
|
||||
%body{class: "#{app_theme} application"}
|
||||
= render "layouts/flash"
|
||||
= render "layouts/head_panel", title: "#{@group.name}"
|
||||
.container
|
||||
%ul.main_menu
|
||||
= 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: '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: '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
|
|
@ -7,14 +7,17 @@
|
|||
= link_to "Edit", edit_project_snippet_path(@project, @snippet), class: "btn small right"
|
||||
|
||||
%br
|
||||
.file_holder
|
||||
.file_title
|
||||
%i.icon-file
|
||||
%strong= @snippet.file_name
|
||||
%span.options
|
||||
= link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn very_small", target: "_blank"
|
||||
.file_content.code
|
||||
%div{class: current_user.dark_scheme ? "black" : ""}
|
||||
= raw @snippet.colorize(options: { linenos: 'True'})
|
||||
%div
|
||||
.file_holder
|
||||
.file_title
|
||||
%i.icon-file
|
||||
%strong= @snippet.file_name
|
||||
%span.options
|
||||
= link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn very_small", target: "_blank"
|
||||
.file_content.code
|
||||
%div{class: current_user.dark_scheme ? "black" : ""}
|
||||
= raw @snippet.colorize(options: { linenos: 'True'})
|
||||
|
||||
= render "notes/notes_with_form", tid: @snippet.id, tt: "snippet"
|
||||
|
||||
%div
|
||||
= render "notes/notes_with_form", tid: @snippet.id, tt: "snippet"
|
||||
|
|
|
@ -43,6 +43,12 @@ Gitlab::Application.routes.draw do
|
|||
put :unblock
|
||||
end
|
||||
end
|
||||
resources :groups, constraints: { id: /[^\/]+/ } do
|
||||
member do
|
||||
put :project_update
|
||||
delete :remove_project
|
||||
end
|
||||
end
|
||||
resources :projects, constraints: { id: /[^\/]+/ } do
|
||||
member do
|
||||
get :team
|
||||
|
@ -81,6 +87,19 @@ Gitlab::Application.routes.draw do
|
|||
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 }
|
||||
|
|
11
db/migrate/20121002150926_create_groups.rb
Normal file
11
db/migrate/20121002150926_create_groups.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class CreateGroups < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :groups do |t|
|
||||
t.string :name, null: false
|
||||
t.string :code, null: false
|
||||
t.integer :owner_id, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
5
db/migrate/20121002151033_add_group_id_to_project.rb
Normal file
5
db/migrate/20121002151033_add_group_id_to_project.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddGroupIdToProject < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :projects, :group_id, :integer
|
||||
end
|
||||
end
|
11
db/schema.rb
11
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120905043334) do
|
||||
ActiveRecord::Schema.define(:version => 20121002151033) do
|
||||
|
||||
create_table "events", :force => true do |t|
|
||||
t.string "target_type"
|
||||
|
@ -25,6 +25,14 @@ ActiveRecord::Schema.define(:version => 20120905043334) do
|
|||
t.integer "author_id"
|
||||
end
|
||||
|
||||
create_table "groups", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
t.string "code", :null => false
|
||||
t.integer "owner_id", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "issues", :force => true do |t|
|
||||
t.string "title"
|
||||
t.integer "assignee_id"
|
||||
|
@ -108,6 +116,7 @@ ActiveRecord::Schema.define(:version => 20120905043334) do
|
|||
t.boolean "wall_enabled", :default => true, :null => false
|
||||
t.boolean "merge_requests_enabled", :default => true, :null => false
|
||||
t.boolean "wiki_enabled", :default => true, :null => false
|
||||
t.integer "group_id"
|
||||
end
|
||||
|
||||
create_table "protected_branches", :force => true do |t|
|
||||
|
|
|
@ -10,6 +10,11 @@ Feature: Dashboard
|
|||
Then I should see "Shop" project link
|
||||
Then I should see project "Shop" activity feed
|
||||
|
||||
Scenario: I should see groups list
|
||||
Given I have group with projects
|
||||
And I visit dashboard page
|
||||
Then I should see groups list
|
||||
|
||||
Scenario: I should see last push widget
|
||||
Then I should see last push widget
|
||||
And I click "Create Merge Request" link
|
||||
|
|
9
features/group/group.feature
Normal file
9
features/group/group.feature
Normal file
|
@ -0,0 +1,9 @@
|
|||
Feature: Groups
|
||||
Background:
|
||||
Given I sign in as a user
|
||||
And I have group with projects
|
||||
|
||||
Scenario: I should see group dashboard list
|
||||
When I visit group page
|
||||
Then I should see projects list
|
||||
And I should see projects activity feed
|
32
features/steps/group/group.rb
Normal file
32
features/steps/group/group.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
class Groups < Spinach::FeatureSteps
|
||||
include SharedAuthentication
|
||||
include SharedPaths
|
||||
|
||||
When 'I visit group page' do
|
||||
visit group_path(current_group)
|
||||
end
|
||||
|
||||
Then 'I should see projects list' do
|
||||
current_user.projects.each do |project|
|
||||
page.should have_link project.name
|
||||
end
|
||||
end
|
||||
|
||||
And 'I have group with projects' do
|
||||
@group = Factory :group
|
||||
@project = Factory :project, group: @group
|
||||
@event = Factory :closed_issue_event, project: @project
|
||||
|
||||
@project.add_access current_user, :admin
|
||||
end
|
||||
|
||||
And 'I should see projects activity feed' do
|
||||
page.should have_content 'closed issue'
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def current_group
|
||||
@group ||= Group.first
|
||||
end
|
||||
end
|
|
@ -47,6 +47,12 @@ FactoryGirl.define do
|
|||
owner
|
||||
end
|
||||
|
||||
factory :group do
|
||||
sequence(:name) { |n| "group#{n}" }
|
||||
code { name.downcase.gsub(/\s/, '_') }
|
||||
owner
|
||||
end
|
||||
|
||||
factory :users_project do
|
||||
user
|
||||
project
|
||||
|
|
24
spec/models/group_spec.rb
Normal file
24
spec/models/group_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: groups
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) not null
|
||||
# code :string(255) not null
|
||||
# owner_id :integer not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Group do
|
||||
let!(:group) { create(:group) }
|
||||
|
||||
it { should have_many :projects }
|
||||
it { should validate_presence_of :name }
|
||||
it { should validate_uniqueness_of(:name) }
|
||||
it { should validate_presence_of :code }
|
||||
it { should validate_uniqueness_of(:code) }
|
||||
it { should validate_presence_of :owner_id }
|
||||
end
|
|
@ -1,7 +1,29 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: projects
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255)
|
||||
# path :string(255)
|
||||
# description :text
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# private_flag :boolean default(TRUE), not null
|
||||
# code :string(255)
|
||||
# owner_id :integer
|
||||
# default_branch :string(255)
|
||||
# issues_enabled :boolean default(TRUE), not null
|
||||
# wall_enabled :boolean default(TRUE), not null
|
||||
# merge_requests_enabled :boolean default(TRUE), not null
|
||||
# wiki_enabled :boolean default(TRUE), not null
|
||||
# group_id :integer
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Project do
|
||||
describe "Associations" do
|
||||
it { should belong_to(:group) }
|
||||
it { should belong_to(:owner).class_name('User') }
|
||||
it { should have_many(:users) }
|
||||
it { should have_many(:events).dependent(:destroy) }
|
||||
|
|
Loading…
Reference in a new issue