diff --git a/CHANGELOG b/CHANGELOG index b3ead8d73d9bbbc897083fee22bfd10f93e95e96..63fb78c8b02255cb1837f81950b922cc37204a70 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ v 8.10.0 (unreleased) - Fix commit builds API, return all builds for all pipelines for given commit. !4849 - Replace Haml with Hamlit to make view rendering faster. !3666 - Refresh the branch cache after `git gc` runs + - Allow to disable request access button on projects/groups - Refactor repository paths handling to allow multiple git mount points - Optimize system note visibility checking by memoizing the visible reference count !5070 - Add Application Setting to configure default Repository Path for new projects diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 94b5aaa71d076b6f440357a96ec7290c987976d2..f3a88a8e6c8cd47e8b1143c2fbf14140b9996764 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -60,6 +60,6 @@ class Admin::GroupsController < Admin::ApplicationController end def group_params - params.require(:group).permit(:name, :description, :path, :avatar, :visibility_level) + params.require(:group).permit(:name, :description, :path, :avatar, :visibility_level, :request_access_enabled) end end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index a04bf7df722ae30525f7f34505fadd94674b8555..6780a6d4d8731b23cdae74365aea3493a245a866 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -121,7 +121,7 @@ class GroupsController < Groups::ApplicationController end def group_params - params.require(:group).permit(:name, :description, :path, :avatar, :public, :visibility_level, :share_with_group_lock) + params.require(:group).permit(:name, :description, :path, :avatar, :public, :visibility_level, :share_with_group_lock, :request_access_enabled) end def load_events diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 4e5bcff9cf843eaf67752959a628997d28241ebe..ec7a2e63b9a8288670bb31c17834ed02b05516e8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -296,7 +296,7 @@ class ProjectsController < Projects::ApplicationController :issues_tracker_id, :default_branch, :wiki_enabled, :visibility_level, :import_url, :last_activity_at, :namespace_id, :avatar, :builds_enabled, :build_allow_git_fetch, :build_timeout_in_minutes, :build_coverage_regex, - :public_builds, :only_allow_merge_if_build_succeeds + :public_builds, :only_allow_merge_if_build_succeeds, :request_access_enabled ) end diff --git a/app/models/ability.rb b/app/models/ability.rb index 6fd18f2ee24bd0dea3b42d0aff4c9317eeac8534..f33c8d61d3fedb39750ddfc3548379ada813f87e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -172,7 +172,7 @@ class Ability rules << :read_build if project.public_builds? unless owner || project.team.member?(user) || project_group_member?(project, user) - rules << :request_access + rules << :request_access if project.request_access_enabled end end @@ -373,7 +373,7 @@ class Ability end if group.public? || (group.internal? && !user.external?) - rules << :request_access unless group.users.include?(user) + rules << :request_access if group.request_access_enabled && group.users.exclude?(user) end rules.flatten diff --git a/app/views/admin/groups/_form.html.haml b/app/views/admin/groups/_form.html.haml index 0cc405401cf5450f712941b31eed7a21af9420a3..5f7fdfdb011801cf71ded2c5fd22ade8f7c4717b 100644 --- a/app/views/admin/groups/_form.html.haml +++ b/app/views/admin/groups/_form.html.haml @@ -9,6 +9,10 @@ = render 'shared/visibility_level', f: f, visibility_level: @group.visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group + .form-group + .col-sm-offset-2.col-sm-10 + = render 'shared/allow_request_access', form: f + - if @group.new_record? .form-group .col-sm-offset-2.col-sm-10 diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index 92cd4c553d0b4d00072c07866331651381ef1f76..decb89b2fd60936c02cc5ab27eaa97be0ba355bc 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -21,6 +21,10 @@ = render 'shared/visibility_level', f: f, visibility_level: @group.visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group + .form-group + .col-sm-offset-2.col-sm-10 + = render 'shared/allow_request_access', form: f + .form-group %hr = f.label :share_with_group_lock, class: 'control-label' do diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index 57af167180b254673b29ce1c10d55c3c2b3d0e8b..541d81e65e5efe988e52f9f4ed654e8c55668c92 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -32,6 +32,10 @@ %strong = visibility_level_label(@project.visibility_level) .light= visibility_level_description(@project.visibility_level, @project) + + .form-group + = render 'shared/allow_request_access', form: f + .form-group = f.label :tag_list, "Tags", class: 'label-light' = f.text_field :tag_list, value: @project.tag_list.to_s, maxlength: 2000, class: "form-control" diff --git a/app/views/shared/_allow_request_access.html.haml b/app/views/shared/_allow_request_access.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..53a99a736c0ea7d1b97f1f89ecb2e1fe48071953 --- /dev/null +++ b/app/views/shared/_allow_request_access.html.haml @@ -0,0 +1,6 @@ +.checkbox + = form.label :request_access_enabled do + = form.check_box :request_access_enabled + %strong Allow users to request access + %br + %span.descr Allow users to request access if visibility is public or internal. diff --git a/db/migrate/20160715154212_add_request_access_enabled_to_projects.rb b/db/migrate/20160715154212_add_request_access_enabled_to_projects.rb new file mode 100644 index 0000000000000000000000000000000000000000..bf0131c6d76379dcc71131721c7f5a283ccf0f08 --- /dev/null +++ b/db/migrate/20160715154212_add_request_access_enabled_to_projects.rb @@ -0,0 +1,12 @@ +class AddRequestAccessEnabledToProjects < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + def up + add_column_with_default :projects, :request_access_enabled, :boolean, default: true + end + + def down + remove_column :projects, :request_access_enabled + end +end diff --git a/db/migrate/20160715204316_add_request_access_enabled_to_groups.rb b/db/migrate/20160715204316_add_request_access_enabled_to_groups.rb new file mode 100644 index 0000000000000000000000000000000000000000..e7b14cd3ee29b4a33e6a6f9c758d80ad67e876b0 --- /dev/null +++ b/db/migrate/20160715204316_add_request_access_enabled_to_groups.rb @@ -0,0 +1,12 @@ +class AddRequestAccessEnabledToGroups < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + def up + add_column_with_default :namespaces, :request_access_enabled, :boolean, default: true + end + + def down + remove_column :namespaces, :request_access_enabled + end +end diff --git a/db/schema.rb b/db/schema.rb index ebf31ded3696a546edc615e20e9c07d80c8c464b..72780fb8d03b72c88a3ade9ac43f698a07eea81e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -664,16 +664,17 @@ ActiveRecord::Schema.define(version: 20160718153603) do add_index "milestones", ["title"], name: "index_milestones_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} create_table "namespaces", force: :cascade do |t| - t.string "name", null: false - t.string "path", null: false + t.string "name", null: false + t.string "path", null: false t.integer "owner_id" t.datetime "created_at" t.datetime "updated_at" t.string "type" - t.string "description", default: "", null: false + t.string "description", default: "", null: false t.string "avatar" - t.boolean "share_with_group_lock", default: false - t.integer "visibility_level", default: 20, null: false + t.boolean "share_with_group_lock", default: false + t.integer "visibility_level", default: 20, null: false + t.boolean "request_access_enabled", default: true, null: false end add_index "namespaces", ["created_at", "id"], name: "index_namespaces_on_created_at_and_id", using: :btree @@ -843,6 +844,7 @@ ActiveRecord::Schema.define(version: 20160718153603) do t.boolean "has_external_issue_tracker" t.string "repository_storage", default: "default", null: false t.boolean "has_external_wiki" + t.boolean "request_access_enabled", default: true, null: false end add_index "projects", ["builds_enabled", "shared_runners_enabled"], name: "index_projects_on_builds_enabled_and_shared_runners_enabled", using: :btree diff --git a/doc/workflow/add-user/add-user.md b/doc/workflow/add-user/add-user.md index 0537ce0bcd4989ac313098ce14515bb56b505173..e541111d7b33b616be608821e37f4867b7163bc4 100644 --- a/doc/workflow/add-user/add-user.md +++ b/doc/workflow/add-user/add-user.md @@ -90,6 +90,9 @@ GitLab account using the same e-mail address the invitation was sent to. ## Request access to a project +As a project owner you can enable or disable non members to request access to +your project. Go to the project settings and click on **Allow users to request access**. + As a user, you can request to be a member of a project. Go to the project you'd like to be a member of, and click the **Request Access** button on the right side of your screen. diff --git a/doc/workflow/groups.md b/doc/workflow/groups.md index 9b50286b179dd4c4f4d9e31aefea11449b674768..a693cc3d0fda2a5b55e342c550ea9a3a995c2971 100644 --- a/doc/workflow/groups.md +++ b/doc/workflow/groups.md @@ -53,6 +53,9 @@ If necessary, you can increase the access level of an individual user for a spec ## Requesting access to a group +As a group owner you can enable or disable non members to request access to +your group. Go to the group settings and click on **Allow users to request access**. + As a user, you can request to be a member of a group. Go to the group you'd like to be a member of, and click the **Request Access** button on the right side of your screen. diff --git a/spec/features/groups/members/user_requests_access_spec.rb b/spec/features/groups/members/user_requests_access_spec.rb index d1a6a98ab7219687b11406d02e3d624ecfa41505..b3baa2ab57ca29f805bc269ac7bdf8ac56accc82 100644 --- a/spec/features/groups/members/user_requests_access_spec.rb +++ b/spec/features/groups/members/user_requests_access_spec.rb @@ -12,6 +12,13 @@ feature 'Groups > Members > User requests access', feature: true do visit group_path(group) end + scenario 'request access feature is disabled' do + group.update_attributes(request_access_enabled: false) + visit group_path(group) + + expect(page).not_to have_content 'Request Access' + end + scenario 'user can request access to a group' do perform_enqueued_jobs { click_link 'Request Access' } diff --git a/spec/features/projects/members/user_requests_access_spec.rb b/spec/features/projects/members/user_requests_access_spec.rb index f2fe3ef364d0f777cabd24bdd1bef857a79ac762..56ede8eb5be5e304b44193ae1c05bdf0e5791e07 100644 --- a/spec/features/projects/members/user_requests_access_spec.rb +++ b/spec/features/projects/members/user_requests_access_spec.rb @@ -11,6 +11,13 @@ feature 'Projects > Members > User requests access', feature: true do visit namespace_project_path(project.namespace, project) end + scenario 'request access feature is disabled' do + project.update_attributes(request_access_enabled: false) + visit namespace_project_path(project.namespace, project) + + expect(page).not_to have_content 'Request Access' + end + scenario 'user can request access to a project' do perform_enqueued_jobs { click_link 'Request Access' }