Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a6718222
Commit
a6718222
authored
Jul 15, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/project_group_links' of /home/git/repositories/gitlab/gitlab-ee
parents
f99c1e2b
dfb62c4e
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
221 additions
and
12 deletions
+221
-12
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+2
-0
app/controllers/projects/group_links_controller.rb
app/controllers/projects/group_links_controller.rb
+38
-0
app/models/group.rb
app/models/group.rb
+3
-0
app/models/project.rb
app/models/project.rb
+3
-0
app/models/project_group_link.rb
app/models/project_group_link.rb
+34
-0
app/models/project_team.rb
app/models/project_team.rb
+18
-1
app/models/user.rb
app/models/user.rb
+6
-2
app/views/groups/_projects.html.haml
app/views/groups/_projects.html.haml
+3
-2
app/views/groups/_shared_projects.html.haml
app/views/groups/_shared_projects.html.haml
+21
-0
app/views/groups/show.html.haml
app/views/groups/show.html.haml
+3
-0
app/views/projects/_settings_nav.html.haml
app/views/projects/_settings_nav.html.haml
+4
-0
app/views/projects/group_links/index.html.haml
app/views/projects/group_links/index.html.haml
+39
-0
config/routes.rb
config/routes.rb
+2
-0
db/migrate/20130711063759_create_project_group_links.rb
db/migrate/20130711063759_create_project_group_links.rb
+10
-0
db/schema.rb
db/schema.rb
+8
-1
spec/factories/project_group_links.rb
spec/factories/project_group_links.rb
+6
-0
spec/features/notes_on_merge_requests_spec.rb
spec/features/notes_on_merge_requests_spec.rb
+0
-6
spec/models/project_group_link_spec.rb
spec/models/project_group_link_spec.rb
+21
-0
No files found.
app/controllers/groups_controller.rb
View file @
a6718222
...
...
@@ -34,6 +34,8 @@ class GroupsController < ApplicationController
@events
=
Event
.
in_projects
(
project_ids
).
limit
(
20
).
offset
(
params
[
:offset
]
||
0
)
@last_push
=
current_user
.
recent_push
@shared_projects
=
@group
.
shared_projects
respond_to
do
|
format
|
format
.
html
format
.
js
...
...
app/controllers/projects/group_links_controller.rb
0 → 100644
View file @
a6718222
#-------------------------------------------------------------------
#
# The GitLab Enterprise Edition (EE) license
#
# Copyright (c) 2013 GitLab.com
#
# All Rights Reserved. No part of this software may be reproduced without
# prior permission of GitLab.com. By using this software you agree to be
# bound by the GitLab Enterprise Support Subscription Terms.
#
#-------------------------------------------------------------------
class
Projects::GroupLinksController
<
Projects
::
ApplicationController
layout
'project_settings'
before_filter
:authorize_admin_project!
def
index
@group_links
=
project
.
project_group_links
.
all
@available_groups
=
Group
.
scoped
@available_groups
-=
project
.
invited_groups
@available_groups
-=
[
project
.
group
]
end
def
create
link
=
project
.
project_group_links
.
new
link
.
group_id
=
params
[
:group_id
]
link
.
save
redirect_to
project_group_links_path
(
project
)
end
def
destroy
project
.
project_group_links
.
find
(
params
[
:id
]).
destroy
redirect_to
project_group_links_path
(
project
)
end
end
app/models/group.rb
View file @
a6718222
...
...
@@ -16,6 +16,9 @@ class Group < Namespace
has_many
:users_groups
,
dependent: :destroy
has_many
:users
,
through: :users_groups
has_many
:project_group_links
,
dependent: :destroy
has_many
:shared_projects
,
through: :project_group_links
,
source:
'project'
after_create
:add_owner
def
human_name
...
...
app/models/project.rb
View file @
a6718222
...
...
@@ -67,6 +67,9 @@ class Project < ActiveRecord::Base
has_many
:deploy_keys_projects
,
dependent: :destroy
has_many
:deploy_keys
,
through: :deploy_keys_projects
has_many
:project_group_links
,
dependent: :destroy
has_many
:invited_groups
,
through: :project_group_links
,
source:
'group'
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:members
,
to: :team
,
prefix:
true
...
...
app/models/project_group_link.rb
0 → 100644
View file @
a6718222
#-------------------------------------------------------------------
#
# The GitLab Enterprise Edition (EE) license
#
# Copyright (c) 2013 GitLab.com
#
# All Rights Reserved. No part of this software may be reproduced without
# prior permission of GitLab.com. By using this software you agree to be
# bound by the GitLab Enterprise Support Subscription Terms.
#
#-------------------------------------------------------------------
class
ProjectGroupLink
<
ActiveRecord
::
Base
GUEST
=
10
REPORTER
=
20
DEVELOPER
=
30
MASTER
=
40
belongs_to
:project
belongs_to
:group
validates
:project_id
,
presence:
true
validates
:group_id
,
presence:
true
validates
:group_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already shared with this group"
}
def
self
.
access_options
{
"Guest"
=>
GUEST
,
"Reporter"
=>
REPORTER
,
"Developer"
=>
DEVELOPER
,
"Master"
=>
MASTER
}
end
end
app/models/project_team.rb
View file @
a6718222
...
...
@@ -111,13 +111,30 @@ class ProjectTeam
def
fetch_members
(
level
=
nil
)
project_members
=
project
.
users_projects
group_members
=
group
?
group
.
users_groups
:
[]
invited_members
=
[]
if
project
.
invited_groups
.
any?
project
.
invited_groups
.
each
do
|
invited_group
|
im
=
invited_group
.
users_groups
if
level
if
level
==
:masters
im
=
im
.
owners
+
im
.
masters
else
im
=
im
.
send
(
level
)
end
end
invited_members
<<
im
end
invited_members
=
invited_members
.
flatten
.
compact
end
if
level
project_members
=
project_members
.
send
(
level
)
group_members
=
group_members
.
send
(
level
)
if
group
end
(
project_members
+
group_members
).
map
(
&
:user
).
uniq
(
project_members
+
group_members
+
invited_members
).
map
(
&
:user
).
uniq
end
def
group
...
...
app/models/user.rb
View file @
a6718222
...
...
@@ -242,8 +242,12 @@ class User < ActiveRecord::Base
# Projects user has access to
def
authorized_projects
@authorized_projects
||=
begin
project_ids
=
(
owned_projects
.
pluck
(
:id
)
+
groups_projects
.
pluck
(
:id
)
+
projects
.
pluck
(
:id
)).
uniq
Project
.
where
(
id:
project_ids
).
joins
(
:namespace
).
order
(
'namespaces.name ASC'
)
project_ids
=
owned_projects
.
pluck
(
:id
)
project_ids
+=
groups_projects
.
pluck
(
:id
)
project_ids
+=
projects
.
pluck
(
:id
)
project_ids
+=
groups
.
joins
(
:shared_projects
).
pluck
(
:project_id
)
Project
.
where
(
id:
project_ids
.
uniq
).
joins
(
:namespace
).
order
(
'namespaces.name ASC'
)
end
end
...
...
app/views/groups/_projects.html.haml
View file @
a6718222
.ui-box
%h5
.title
%strong
=
@group
.
name
Projects (
#{
projects
.
count
}
)
-
if
can?
current_user
,
:manage_group
,
@group
%span
.pull-right
=
link_to
new_project_path
(
namespace_id:
@group
.
id
),
class:
"btn
"
do
=
link_to
new_project_path
(
namespace_id:
@group
.
id
),
class:
"btn
btn-small"
,
title:
'New Project'
do
%i
.icon-plus
New Project
%span
.only-wide
New Project
%ul
.well-list
-
if
projects
.
blank?
%p
.nothing_here_message
This groups has no projects yet
...
...
app/views/groups/_shared_projects.html.haml
0 → 100644
View file @
a6718222
-
if
projects
.
present?
.ui-box
%h5
.title
Projects shared with
%strong
#{
@group
.
name
}
(
#{
projects
.
count
}
)
%ul
.well-list
-
projects
.
each
do
|
project
|
%li
.project-row
=
link_to
project_path
(
project
),
class:
dom_class
(
project
)
do
%span
.namespace-name
-
if
project
.
namespace
=
project
.
namespace
.
human_name
\/
%span
.project-name
=
truncate
(
project
.
name
,
length:
25
)
%span
.arrow
%i
.icon-angle-right
%span
.last-activity
%span
Last activity:
%span
.date
=
project_last_activity
(
project
)
app/views/groups/show.html.haml
View file @
a6718222
...
...
@@ -16,6 +16,9 @@
.description-block
=
@group
.
description
=
render
"projects"
,
projects:
@projects
%br
=
render
"shared_projects"
,
projects:
@shared_projects
.prepend-top-20
=
link_to
group_path
(
@group
,
{
format: :atom
,
private_token:
current_user
.
private_token
}),
title:
"Feed"
do
%strong
...
...
app/views/projects/_settings_nav.html.haml
View file @
a6718222
...
...
@@ -7,6 +7,10 @@
=
link_to
project_team_index_path
(
@project
),
class:
"team-tab tab"
do
%i
.icon-group
Members
=
nav_link
(
controller: :group_links
)
do
=
link_to
project_group_links_path
(
@project
)
do
%span
Groups
=
nav_link
(
controller: :deploy_keys
)
do
=
link_to
project_deploy_keys_path
(
@project
)
do
%span
...
...
app/views/projects/group_links/index.html.haml
0 → 100644
View file @
a6718222
%h3
.page_title
Share project with groups
%br
%p
Project can be stored in one group at once
%br
However you can share project with other groups here.
.row
.span5.enabled-groups
%h5
Already shared with:
%ul
.bordered-list
-
@group_links
.
each
do
|
group_link
|
-
group
=
group_link
.
group
%li
%h5
.pull-left
=
link_to
project_group_link_path
(
@project
,
group_link
),
method: :delete
,
class:
'btn btn-small append-right-10'
do
%i
.icon-remove
=
link_to
group
do
%i
.icon-folder-open
=
group
.
name
%small
.light
up to Masters
.span5.available-groups
%h5
Can be shared with:
%ul
.bordered-list
-
@available_groups
.
each
do
|
group
|
%li
%h5
.pull-right
=
form_tag
project_group_links_path
(
@project
),
method: :post
do
=
select_tag
:group_access
,
options_for_select
(
ProjectGroupLink
.
access_options
,
ProjectGroupLink
::
MASTER
),
class:
"span2"
=
hidden_field_tag
:group_id
,
group
.
id
=
submit_tag
"Share"
,
class:
"btn"
%i
.icon-folder-close
=
group
.
name
config/routes.rb
View file @
a6718222
...
...
@@ -284,6 +284,8 @@ Gitlab::Application.routes.draw do
end
end
resources
:group_links
,
only:
[
:index
,
:create
,
:destroy
]
resources
:notes
,
only:
[
:index
,
:create
,
:destroy
,
:update
]
do
member
do
delete
:delete_attachment
...
...
db/migrate/20130711063759_create_project_group_links.rb
0 → 100644
View file @
a6718222
class
CreateProjectGroupLinks
<
ActiveRecord
::
Migration
def
change
create_table
:project_group_links
do
|
t
|
t
.
integer
:project_id
,
null:
false
t
.
integer
:group_id
,
null:
false
t
.
timestamps
end
end
end
db/schema.rb
View file @
a6718222
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
20130
624162710
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
20130
711063759
)
do
create_table
"deploy_keys_projects"
,
:force
=>
true
do
|
t
|
t
.
integer
"deploy_key_id"
,
:null
=>
false
...
...
@@ -157,6 +157,13 @@ ActiveRecord::Schema.define(:version => 20130624162710) do
add_index
"notes"
,
[
"project_id"
,
"noteable_type"
],
:name
=>
"index_notes_on_project_id_and_noteable_type"
add_index
"notes"
,
[
"project_id"
],
:name
=>
"index_notes_on_project_id"
create_table
"project_group_links"
,
:force
=>
true
do
|
t
|
t
.
integer
"project_id"
,
:null
=>
false
t
.
integer
"group_id"
,
:null
=>
false
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
end
create_table
"projects"
,
:force
=>
true
do
|
t
|
t
.
string
"name"
t
.
string
"path"
...
...
spec/factories/project_group_links.rb
0 → 100644
View file @
a6718222
FactoryGirl
.
define
do
factory
:project_group_link
do
project
group
end
end
spec/features/notes_on_merge_requests_spec.rb
View file @
a6718222
...
...
@@ -66,12 +66,6 @@ describe "On a merge request", js: true do
within
(
".js-main-target-form"
)
{
should
have_css
(
".js-note-preview"
,
visible:
false
)
}
within
(
".js-main-target-form"
)
{
should
have_css
(
".js-note-text"
,
visible:
true
)
}
end
it
"should be removable"
do
find
(
'.note'
).
hover
find
(
".js-note-delete"
).
click
should_not
have_css
(
".note"
)
end
end
describe
"when editing a note"
,
js:
true
do
...
...
spec/models/project_group_link_spec.rb
0 → 100644
View file @
a6718222
require
'spec_helper'
describe
ProjectGroupLink
do
describe
"Associations"
do
it
{
should
belong_to
(
:group
)
}
it
{
should
belong_to
(
:project
)
}
end
describe
"Mass assignment"
do
it
{
should_not
allow_mass_assignment_of
(
:group_id
)
}
it
{
should_not
allow_mass_assignment_of
(
:project_id
)
}
end
describe
"Validation"
do
let!
(
:project_group_link
)
{
create
(
:project_group_link
)
}
it
{
should
validate_presence_of
(
:project_id
)
}
it
{
should
validate_uniqueness_of
(
:group_id
).
scoped_to
(
:project_id
).
with_message
(
/already shared/
)
}
it
{
should
validate_presence_of
(
:group_id
)
}
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment