Commit cbd24fa0 authored by David O'Regan's avatar David O'Regan Committed by David

Add type selector for issues

We add a type selector to the
new issue creation form for
allowing selection for incidents
parent 1a9d624a
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
#js-suggestions{ data: { project_path: @project.full_path } } #js-suggestions{ data: { project_path: @project.full_path } }
= render 'shared/form_elements/apply_template_warning' = render 'shared/form_elements/apply_template_warning'
- if issuable.is_a?(Issuable) && @issue
= render 'shared/issuable/form/type_selector', issuable: issuable, form: form, type: @issue[:issue_type]
= render 'shared/form_elements/description', model: issuable, form: form, project: project = render 'shared/form_elements/description', model: issuable, form: form, project: project
- if issuable.respond_to?(:confidential) - if issuable.respond_to?(:confidential)
......
...@@ -14,11 +14,13 @@ ...@@ -14,11 +14,13 @@
= render_if_exists "shared/issuable/form/epic", issuable: issuable, form: form, project: project = render_if_exists "shared/issuable/form/epic", issuable: issuable, form: form, project: project
- if issuable.supports_milestone?
.form-group.row.issue-milestone .form-group.row.issue-milestone
= form.label :milestone_id, "Milestone", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}" = form.label :milestone_id, "Milestone", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}"
.col-sm-10{ class: ("col-md-8" if has_due_date) } .col-sm-10{ class: ("col-md-8" if has_due_date) }
.issuable-form-select-holder .issuable-form-select-holder
= render "shared/issuable/milestone_dropdown", selected: issuable.milestone, name: "#{issuable.class.model_name.param_key}[milestone_id]", show_any: false, show_upcoming: false, show_started: false, extra_class: "qa-issuable-milestone-dropdown js-issuable-form-dropdown js-dropdown-keep-input", dropdown_title: "Select milestone" = render "shared/issuable/milestone_dropdown", selected: issuable.milestone, name: "#{issuable.class.model_name.param_key}[milestone_id]", show_any: false, show_upcoming: false, show_started: false, extra_class: "qa-issuable-milestone-dropdown js-issuable-form-dropdown js-dropdown-keep-input", dropdown_title: "Select milestone"
.form-group.row .form-group.row
= form.label :label_ids, "Labels", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}" = form.label :label_ids, "Labels", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}"
= form.hidden_field :label_ids, multiple: true, value: '' = form.hidden_field :label_ids, multiple: true, value: ''
...@@ -30,6 +32,7 @@ ...@@ -30,6 +32,7 @@
- if has_due_date || issuable.supports_weight? - if has_due_date || issuable.supports_weight?
.col-lg-6 .col-lg-6
- if @issue[:issue_type] != 'incident'
= render_if_exists "shared/issuable/form/weight", issuable: issuable, form: form = render_if_exists "shared/issuable/form/weight", issuable: issuable, form: form
.form-group.row .form-group.row
= form.label :due_date, "Due date", class: "col-form-label col-md-2 col-lg-4" = form.label :due_date, "Due date", class: "col-form-label col-md-2 col-lg-4"
......
.form-group.row.gl-mb-0
= form.label :type, 'Type', class: 'col-form-label col-sm-2'
.col-sm-10
.issuable-form-select-holder.selectbox.form-group
.dropdown.js-issuable-type-filter-dropdown-wrap
%button.dropdown-menu-toggle{ type: 'button', 'data-toggle' => 'dropdown' }
%span.dropdown-label
= type.capitalize || _("Select type")
= icon('chevron-down')
.dropdown-menu.dropdown-menu-selectable.dropdown-select
.dropdown-title
= _("Select type")
%button.dropdown-title-button.dropdown-menu-close.gl-mt-3
= icon('times', class: 'dropdown-menu-close-icon', 'aria-hidden' => 'true')
.dropdown-content
%ul
%li.js-filter-issuable-type
= link_to new_project_issue_path(@project), class: ("is-active" if type === 'issue') do
= _("Issue")
%li.js-filter-issuable-type
= link_to new_project_issue_path(@project, { 'issue[issue_type]': 'incident', issuable_template: 'incident' }), class: ("is-active" if type === 'incident') do
= _("Incident")
---
title: Add type selector dropdown to new issue form
merge_request: 40981
author:
type: changed
- project = local_assigns.fetch(:project) - project = local_assigns.fetch(:project)
- issuable = local_assigns.fetch(:issuable) - issuable = local_assigns.fetch(:issuable)
- return unless issuable.can_assign_epic?(current_user) - return unless issuable.can_assign_epic?(current_user) && issuable.supports_epic?
- form = local_assigns.fetch(:form) - form = local_assigns.fetch(:form)
.form-group.row.issue-epic .form-group.row.issue-epic
......
...@@ -11,4 +11,4 @@ ...@@ -11,4 +11,4 @@
- if issuable.weight - if issuable.weight
= form.hidden_field :weight = form.hidden_field :weight
= form.text_field :weight, class: "datepicker form-control", placeholder: "Enter a number", autocomplete: "off", type: "text" = form.text_field :weight, class: "datepicker form-control qa-issuable-weight-input", placeholder: "Enter a number", autocomplete: "off", type: "text"
...@@ -13052,6 +13052,9 @@ msgstr "" ...@@ -13052,6 +13052,9 @@ msgstr ""
msgid "In the next step, you'll be able to select the projects you want to import." msgid "In the next step, you'll be able to select the projects you want to import."
msgstr "" msgstr ""
msgid "Incident"
msgstr ""
msgid "Incident Management Limits" msgid "Incident Management Limits"
msgstr "" msgstr ""
...@@ -22212,6 +22215,9 @@ msgstr "" ...@@ -22212,6 +22215,9 @@ msgstr ""
msgid "Select timezone" msgid "Select timezone"
msgstr "" msgstr ""
msgid "Select type"
msgstr ""
msgid "Select user" msgid "Select user"
msgstr "" msgstr ""
......
...@@ -188,6 +188,46 @@ RSpec.describe "User creates issue" do ...@@ -188,6 +188,46 @@ RSpec.describe "User creates issue" do
end end
end end
context 'form create handles issue creation by default' do
let(:project) { create(:project) }
before do
visit new_project_issue_path(project)
end
it 'pre-fills the issue type dropdown with issue type' do
expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-label')).to have_content('Issue')
end
it 'does not hide the milestone select' do
expect(page).to have_selector('.qa-issuable-milestone-dropdown')
end
end
context 'form create handles incident creation' do
let(:project) { create(:project) }
before do
visit new_project_issue_path(project, { 'issue[issue_type]': 'incident', issuable_template: 'incident' })
end
it 'pre-fills the issue type dropdown with incident type' do
expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-label')).to have_content('Incident')
end
it 'hides the epic select' do
expect(page).not_to have_selector('.epic-dropdown-container')
end
it 'hides the milestone select' do
expect(page).not_to have_selector('.qa-issuable-milestone-dropdown')
end
it 'hides the weight input' do
expect(page).not_to have_selector('.qa-issuable-weight-input')
end
end
context 'suggestions', :js do context 'suggestions', :js do
it 'displays list of related issues' do it 'displays list of related issues' do
issue = create(:issue, project: project) issue = create(:issue, project: project)
......
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