Skip to content
Snippets Groups Projects
Commit 5059c660 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge branch 'share-with-different-group' into 'master'

Don't allow project to be shared with the group it is already in.

Fixes #249.

See merge request !352
parents a243b282 ed680349
No related branches found
No related tags found
3 merge requests!8889WIP: Port of 25624-anticipate-obstacles-to-removing-turbolinks to EE.,!7795Asciidoctor plantuml,!7793Add support for PlantUML diagrams in Asciidoc.
Loading
Loading
@@ -5,6 +5,7 @@ v 7.9.0 (unreleased)
- Use one custom header logo for all GitLab themes in appearance settings
- Escape wildcards when searching LDAP by group name.
- Group level Web Hooks
- Don't allow project to be shared with the group it is already in.
 
v 7.8.0
- Improved Jira issue closing integration
Loading
Loading
Loading
Loading
@@ -2,6 +2,7 @@ class @GroupsSelect
constructor: ->
$('.ajax-groups-select').each (i, select) =>
skip_ldap = $(select).hasClass('skip_ldap')
skip_group = $(select).data("skip-group")
 
$(select).select2
placeholder: "Search for a group"
Loading
Loading
@@ -9,7 +10,13 @@ class @GroupsSelect
minimumInputLength: 0
query: (query) ->
Api.groups query.term, skip_ldap, (groups) ->
data = { results: groups }
data = { results: [] }
for group in groups
continue if skip_group && group.path == skip_group
data.results.push(group)
query.callback(data)
 
initSelection: (element, callback) ->
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ module SelectsHelper
css_class << (opts[:class] || '')
value = opts[:selected] || ''
 
hidden_field_tag(id, value, class: css_class)
hidden_field_tag(id, value, class: css_class, data: { skip_group: opts[:skip_group] })
end
 
def admin_email_select_tag(id, opts = {})
Loading
Loading
Loading
Loading
@@ -12,6 +12,7 @@ class ProjectGroupLink < ActiveRecord::Base
validates :group_id, uniqueness: { scope: [:project_id], message: "already shared with this group" }
validates :group_access, presence: true
validates :group_access, inclusion: { in: Gitlab::Access.values }, presence: true
validate :different_group
 
def self.access_options
Gitlab::Access.options
Loading
Loading
@@ -24,4 +25,12 @@ class ProjectGroupLink < ActiveRecord::Base
def human_access
self.class.access_options.key(self.group_access)
end
private
def different_group
if self.group && self.project && self.project.group == self.group
errors.add(:base, "Project cannot be shared with the project it is in.")
end
end
end
Loading
Loading
@@ -29,7 +29,7 @@
.form-group
= label_tag :link_group_id, 'Group', class: 'control-label'
.col-sm-10
= groups_select_tag(:link_group_id)
= groups_select_tag(:link_group_id, skip_group: @project.group.try(:path))
.form-group
= label_tag :link_group_access, 'Max access level', class: 'control-label'
.col-sm-10
Loading
Loading
Loading
Loading
@@ -395,11 +395,11 @@ ActiveRecord::Schema.define(version: 20150312000132) do
t.string "avatar"
t.string "import_status"
t.float "repository_size", default: 0.0
t.text "merge_requests_template"
t.integer "star_count", default: 0, null: false
t.boolean "merge_requests_rebase_enabled", default: false
t.string "import_type"
t.string "import_source"
t.text "merge_requests_template"
t.boolean "merge_requests_rebase_enabled", default: false
t.boolean "merge_requests_rebase_default", default: true
end
 
Loading
Loading
@@ -515,7 +515,6 @@ ActiveRecord::Schema.define(version: 20150312000132) do
t.string "unconfirmed_email"
t.boolean "hide_no_ssh_key", default: false
t.string "website_url", default: "", null: false
t.datetime "admin_email_unsubscribed_at"
t.string "github_access_token"
t.string "gitlab_access_token"
t.string "notification_email"
Loading
Loading
@@ -523,6 +522,7 @@ ActiveRecord::Schema.define(version: 20150312000132) do
t.boolean "password_automatically_set", default: false
t.string "bitbucket_access_token"
t.string "bitbucket_access_token_secret"
t.datetime "admin_email_unsubscribed_at"
end
 
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment