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