Commit 333080e3 authored by Sean Arnold's avatar Sean Arnold

Set issue_type to incident for new incidents

- Set incident type via helper & view
- Accept issue_type when creating an issue
parent 07c16be9
...@@ -88,6 +88,7 @@ export default { ...@@ -88,6 +88,7 @@ export default {
'projectPath', 'projectPath',
'newIssuePath', 'newIssuePath',
'incidentTemplateName', 'incidentTemplateName',
'incidentType',
'issuePath', 'issuePath',
'publishedAvailable', 'publishedAvailable',
], ],
...@@ -179,7 +180,10 @@ export default { ...@@ -179,7 +180,10 @@ export default {
}; };
}, },
newIncidentPath() { newIncidentPath() {
return mergeUrlParams({ issuable_template: this.incidentTemplateName }, this.newIssuePath); return mergeUrlParams({
issuable_template: this.incidentTemplateName,
issue_type: this.incidentType
}, this.newIssuePath);
}, },
availableFields() { availableFields() {
return this.publishedAvailable return this.publishedAvailable
......
...@@ -12,6 +12,7 @@ export default () => { ...@@ -12,6 +12,7 @@ export default () => {
projectPath, projectPath,
newIssuePath, newIssuePath,
incidentTemplateName, incidentTemplateName,
incidentType,
issuePath, issuePath,
publishedAvailable, publishedAvailable,
} = domEl.dataset; } = domEl.dataset;
...@@ -25,6 +26,7 @@ export default () => { ...@@ -25,6 +26,7 @@ export default () => {
provide: { provide: {
projectPath, projectPath,
incidentTemplateName, incidentTemplateName,
incidentType,
newIssuePath, newIssuePath,
issuePath, issuePath,
publishedAvailable, publishedAvailable,
......
...@@ -93,7 +93,8 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -93,7 +93,8 @@ 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]) confidential: !!Gitlab::Utils.to_boolean(params[:issue][:confidential]),
issue_type: params[:issue_type]
) )
service = Issues::BuildService.new(project, current_user, build_params) service = Issues::BuildService.new(project, current_user, build_params)
...@@ -112,7 +113,8 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -112,7 +113,8 @@ class Projects::IssuesController < Projects::ApplicationController
def create def create
create_params = issue_params.merge(spammable_params).merge( create_params = issue_params.merge(spammable_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],
issue_type: params[:issue][:issue_type]
) )
service = Issues::CreateService.new(project, current_user, create_params) service = Issues::CreateService.new(project, current_user, create_params)
......
...@@ -6,6 +6,7 @@ module Projects::IncidentsHelper ...@@ -6,6 +6,7 @@ module Projects::IncidentsHelper
'project-path' => project.full_path, 'project-path' => project.full_path,
'new-issue-path' => new_project_issue_path(project), 'new-issue-path' => new_project_issue_path(project),
'incident-template-name' => 'incident', 'incident-template-name' => 'incident',
'incident-type' => 'incident',
'issue-path' => project_issues_path(project) 'issue-path' => project_issues_path(project)
} }
end end
......
...@@ -75,9 +75,16 @@ module Issues ...@@ -75,9 +75,16 @@ module Issues
end end
end end
def optional_issue_params
optional_params = [:issue_type]
params.slice(*optional_params).reject { |_, v| v.nil? }
end
def build_issue_params def build_issue_params
{ author: current_user }.merge(issue_params_with_info_from_discussions) { author: current_user }.merge(issue_params_with_info_from_discussions)
.merge(whitelisted_issue_params) .merge(whitelisted_issue_params)
.merge(optional_issue_params)
end end
end end
end end
......
...@@ -83,4 +83,7 @@ ...@@ -83,4 +83,7 @@
= render_if_exists 'shared/issuable/remove_approver' = render_if_exists 'shared/issuable/remove_approver'
- if issuable.is_a?(Issue)
= form.hidden_field :issue_type
= form.hidden_field :lock_version = form.hidden_field :lock_version
...@@ -16,6 +16,7 @@ RSpec.describe Projects::IncidentsHelper do ...@@ -16,6 +16,7 @@ RSpec.describe Projects::IncidentsHelper do
'project-path' => project_path, 'project-path' => project_path,
'new-issue-path' => new_issue_path, 'new-issue-path' => new_issue_path,
'incident-template-name' => 'incident', 'incident-template-name' => 'incident',
'issue-type' => 'incident',
'issue-path' => issue_path 'issue-path' => issue_path
} }
end end
......
...@@ -26,6 +26,7 @@ describe('Incidents List', () => { ...@@ -26,6 +26,7 @@ describe('Incidents List', () => {
let wrapper; let wrapper;
const newIssuePath = 'namespace/project/-/issues/new'; const newIssuePath = 'namespace/project/-/issues/new';
const incidentTemplateName = 'incident'; const incidentTemplateName = 'incident';
const incidentType = 'incident';
const incidentsCount = { const incidentsCount = {
opened: 14, opened: 14,
closed: 1, closed: 1,
...@@ -66,6 +67,7 @@ describe('Incidents List', () => { ...@@ -66,6 +67,7 @@ describe('Incidents List', () => {
projectPath: '/project/path', projectPath: '/project/path',
newIssuePath, newIssuePath,
incidentTemplateName, incidentTemplateName,
incidentType,
issuePath: '/project/isssues', issuePath: '/project/isssues',
publishedAvailable: true, publishedAvailable: true,
}, },
......
...@@ -18,6 +18,7 @@ RSpec.describe Projects::IncidentsHelper do ...@@ -18,6 +18,7 @@ RSpec.describe Projects::IncidentsHelper do
'project-path' => project_path, 'project-path' => project_path,
'new-issue-path' => new_issue_path, 'new-issue-path' => new_issue_path,
'incident-template-name' => 'incident', 'incident-template-name' => 'incident',
'incident-type' => 'incident',
'issue-path' => issue_path 'issue-path' => issue_path
) )
end end
......
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