Commit dab2be7c authored by James Johnson's avatar James Johnson Committed by Bob Van Landuyt

Adds confidential flag to new issue URL

parent f6ca508c
...@@ -85,11 +85,13 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -85,11 +85,13 @@ class Projects::IssuesController < Projects::ApplicationController
) )
build_params = issue_params.merge( build_params = issue_params.merge(
merge_request_to_resolve_discussions_of: params[:merge_request_to_resolve_discussions_of], merge_request_to_resolve_discussions_of: params[:merge_request_to_resolve_discussions_of],
discussion_to_resolve: params[:discussion_to_resolve] discussion_to_resolve: params[:discussion_to_resolve],
confidential: !!Gitlab::Utils.to_boolean(params[:issue][:confidential])
) )
service = Issues::BuildService.new(project, current_user, build_params) service = Issues::BuildService.new(project, current_user, build_params)
@issue = @noteable = service.execute @issue = @noteable = service.execute
@merge_request_to_resolve_discussions_of = service.merge_request_to_resolve_discussions_of @merge_request_to_resolve_discussions_of = service.merge_request_to_resolve_discussions_of
@discussion_to_resolve = service.discussions_to_resolve.first if params[:discussion_to_resolve] @discussion_to_resolve = service.discussions_to_resolve.first if params[:discussion_to_resolve]
......
...@@ -65,15 +65,19 @@ module Issues ...@@ -65,15 +65,19 @@ module Issues
private private
def whitelisted_issue_params def whitelisted_issue_params
base_params = [:title, :description, :confidential]
admin_params = [:milestone_id]
if can?(current_user, :admin_issue, project) if can?(current_user, :admin_issue, project)
params.slice(:title, :description, :milestone_id) params.slice(*(base_params + admin_params))
else else
params.slice(:title, :description) params.slice(*base_params)
end end
end end
def build_issue_params def build_issue_params
issue_params_with_info_from_discussions.merge(whitelisted_issue_params) { author: current_user }.merge(issue_params_with_info_from_discussions)
.merge(whitelisted_issue_params)
end end
end end
end end
......
---
title: Adds URL parameter for confidential new issue creation
merge_request: 30250
author:
type: added
...@@ -92,9 +92,17 @@ field values using query string parameters in a URL. This is useful for embeddin ...@@ -92,9 +92,17 @@ field values using query string parameters in a URL. This is useful for embeddin
a URL in an external HTML page, and also certain scenarios where you want the user to a URL in an external HTML page, and also certain scenarios where you want the user to
create an issue with certain fields prefilled. create an issue with certain fields prefilled.
The title, description, and description template fields can be prefilled using The title, description, description template, and confidential fields can be prefilled
this method. You cannot pre-fill both the description and description template fields using this method. You cannot pre-fill both the description and description template
in the same URL (since a description template also populates the description field). fields in the same URL (since a description template also populates the description
field).
| Field | URL Parameter Name | Notes |
|----------------------|-----------------------|-------------------------------------------------------|
| title | `issue[title]` | |
| description | `issue[description]` | |
| description template | `issuable_template` | |
| confidential | `issue[confidential]` | Parameter value must be `true` to set to confidential |
Follow these examples to form your new issue URL with prefilled fields. Follow these examples to form your new issue URL with prefilled fields.
...@@ -102,6 +110,8 @@ Follow these examples to form your new issue URL with prefilled fields. ...@@ -102,6 +110,8 @@ Follow these examples to form your new issue URL with prefilled fields.
and a pre-filled description, the URL would be `https://gitlab.com/gitlab-org/gitlab-foss/issues/new?issue[title]=Validate%20new%20concept&issue[description]=Research%20idea` and a pre-filled description, the URL would be `https://gitlab.com/gitlab-org/gitlab-foss/issues/new?issue[title]=Validate%20new%20concept&issue[description]=Research%20idea`
- For a new issue in the GitLab Community Edition project with a pre-filled title - For a new issue in the GitLab Community Edition project with a pre-filled title
and a pre-filled description template, the URL would be `https://gitlab.com/gitlab-org/gitlab-foss/issues/new?issue[title]=Validate%20new%20concept&issuable_template=Research%20proposal` and a pre-filled description template, the URL would be `https://gitlab.com/gitlab-org/gitlab-foss/issues/new?issue[title]=Validate%20new%20concept&issuable_template=Research%20proposal`
- For a new issue in the GitLab Community Edition project with a pre-filled title,
a pre-filled description, and the confidential flag set, the URL would be `https://gitlab.com/gitlab-org/gitlab-foss/issues/new?issue[title]=Validate%20new%20concept&issue[description]=Research%20idea&issue[confidential]=true`
## Moving Issues ## Moving Issues
......
...@@ -187,6 +187,33 @@ describe Projects::IssuesController do ...@@ -187,6 +187,33 @@ describe Projects::IssuesController do
expect(assigns(:issue)).to be_a_new(Issue) expect(assigns(:issue)).to be_a_new(Issue)
end end
where(:conf_value, :conf_result) do
[
[true, true],
['true', true],
['TRUE', true],
[false, false],
['false', false],
['FALSE', false]
]
end
with_them do
it 'sets the confidential flag to the expected value' do
get :new, params: {
namespace_id: project.namespace,
project_id: project,
issue: {
confidential: conf_value
}
}
assigned_issue = assigns(:issue)
expect(assigned_issue).to be_a_new(Issue)
expect(assigned_issue.confidential).to eq conf_result
end
end
it 'fills in an issue for a merge request' do it 'fills in an issue for a merge request' do
project_with_repository = create(:project, :repository) project_with_repository = create(:project, :repository)
project_with_repository.add_developer(user) project_with_repository.add_developer(user)
......
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