BigW Consortium Gitlab

Commit a7d8a7bd by Stan Hu

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

Closes #1676
parent f042b085
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 7.12.0 (unreleased) v 7.12.0 (unreleased)
- 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) - Allow to configure location of the `.gitlab_shell_secret` file. (Jakub Jirutka)
- Disabled expansion of top/bottom blobs for new file diffs - Disabled expansion of top/bottom blobs for new file diffs
- Update Asciidoctor gem to version 1.5.2. (Jakub Jirutka) - Update Asciidoctor gem to version 1.5.2. (Jakub Jirutka)
......
...@@ -101,6 +101,22 @@ class Ability ...@@ -101,6 +101,22 @@ class Ability
rules -= project_archived_rules rules -= project_archived_rules
end 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 rules
end end
end end
...@@ -272,5 +288,16 @@ class Ability ...@@ -272,5 +288,16 @@ class Ability
abilities abilities
end end
end end
private
def named_abilities(name)
[
:"read_#{name}",
:"write_#{name}",
:"modify_#{name}",
:"admin_#{name}"
]
end
end 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 @@ ...@@ -61,7 +61,7 @@
Participants Participants
%span.badge= @users.count %span.badge= @users.count
- if @project.issues_enabled - if can?(current_user, :write_issue, @project)
.pull-right .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 = 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 %i.fa.fa-plus
......
...@@ -62,3 +62,9 @@ Feature: Project ...@@ -62,3 +62,9 @@ Feature: Project
And I add project tags And I add project tags
And I save project And I save project
Then I should see project tags 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 ...@@ -102,4 +102,12 @@ class Spinach::Features::Project < Spinach::FeatureSteps
step 'I should see project tags' do step 'I should see project tags' do
expect(find_field('Tags').value).to eq 'tag1, tag2' expect(find_field('Tags').value).to eq 'tag1, tag2'
end 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 end
...@@ -14,6 +14,12 @@ module SharedProject ...@@ -14,6 +14,12 @@ module SharedProject
@project.team << [@user, :master] @project.team << [@user, :master]
end 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" # Add another user to project "Shop"
step 'I add a user to project "Shop"' do step 'I add a user to project "Shop"' do
@project = Project.find_by(name: "Shop") @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