Commit 04d44522 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'disabled-issues-mr-features' into 'master'

Disable "New Issue" and "New Merge Request" buttons when features are disabled in project settings

Closes #1676

See merge request !691
parents 608bd4bb a7d8a7bd
......@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 7.12.0 (unreleased)
- Add web hook support for note events (Stan Hu)
- Disable "New Issue" and "New Merge Request" buttons when features are disabled in project settings (Stan Hu)
- Allow to configure location of the `.gitlab_shell_secret` file. (Jakub Jirutka)
- Disabled expansion of top/bottom blobs for new file diffs
- Update Asciidoctor gem to version 1.5.2. (Jakub Jirutka)
......
......@@ -101,6 +101,22 @@ class Ability
rules -= project_archived_rules
end
unless project.issues_enabled
rules -= named_abilities('issue')
end
unless project.merge_requests_enabled
rules -= named_abilities('merge_request')
end
unless project.snippets_enabled
rules -= named_abilities('snippet')
end
unless project.wiki_enabled
rules -= named_abilities('wiki')
end
rules
end
end
......@@ -272,5 +288,16 @@ class Ability
abilities
end
end
private
def named_abilities(name)
[
:"read_#{name}",
:"write_#{name}",
:"modify_#{name}",
:"admin_#{name}"
]
end
end
end
- if current_user
.dropdown.pull-right
%a.dropdown-toggle.btn.btn-sm{href: '#', "data-toggle" => "dropdown"}
%i.fa.fa-bars
%ul.dropdown-menu
- if @project.issues_enabled && can?(current_user, :write_issue, @project)
%li
= link_to url_for_new_issue(@project, only_path: true), title: "New Issue" do
%i.fa.fa-fw.fa-exclamation-circle
New issue
- if @project.merge_requests_enabled && can?(current_user, :write_merge_request, @project)
%li
= link_to new_namespace_project_merge_request_path(@project.namespace, @project), title: "New Merge Request" do
%i.fa.fa-fw.fa-tasks
New merge request
- if @project.snippets_enabled && can?(current_user, :write_snippet, @project)
%li
= link_to new_namespace_project_snippet_path(@project.namespace, @project), title: "New Snippet" do
%i.fa.fa-fw.fa-file-text-o
New snippet
- if can?(current_user, :admin_project_member, @project)
%li
= link_to namespace_project_project_members_path(@project.namespace, @project), title: "New project member" do
%i.fa.fa-fw.fa-users
New project member
- if can? current_user, :push_code, @project
%li.divider
%li
= link_to new_namespace_project_branch_path(@project.namespace, @project) do
%i.fa.fa-fw.fa-code-fork
New branch
%li
= link_to new_namespace_project_tag_path(@project.namespace, @project) do
%i.fa.fa-fw.fa-tag
New tag
......@@ -61,7 +61,7 @@
Participants
%span.badge= @users.count
- if @project.issues_enabled
- if can?(current_user, :write_issue, @project)
.pull-right
= link_to new_namespace_project_issue_path(@project.namespace, @project, issue: { milestone_id: @milestone.id }), class: "btn btn-grouped", title: "New Issue" do
%i.fa.fa-plus
......
......@@ -62,3 +62,9 @@ Feature: Project
And I add project tags
And I save project
Then I should see project tags
Scenario: I should not see "New Issue" or "New Merge Request" buttons
Given I disable issues and merge requests in project
When I visit project "Shop" page
Then I should not see "New Issue" button
And I should not see "New Merge Request" button
......@@ -102,4 +102,12 @@ class Spinach::Features::Project < Spinach::FeatureSteps
step 'I should see project tags' do
expect(find_field('Tags').value).to eq 'tag1, tag2'
end
step 'I should not see "New Issue" button' do
page.should_not have_link 'New Issue'
end
step 'I should not see "New Merge Request" button' do
page.should_not have_link 'New Merge Request'
end
end
......@@ -14,6 +14,12 @@ module SharedProject
@project.team << [@user, :master]
end
step 'I disable issues and merge requests in project' do
@project.issues_enabled = false
@project.merge_requests_enabled = false
@project.save
end
# Add another user to project "Shop"
step 'I add a user to project "Shop"' do
@project = Project.find_by(name: "Shop")
......
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