diff --git a/app/views/shared/issuable/_form.html.haml b/app/views/shared/issuable/_form.html.haml index 86cd2923facfecd22067d1718934d3ca5ba47274..e17165e5e15a8013c9ab1aefa1e61ce1b36ba58f 100644 --- a/app/views/shared/issuable/_form.html.haml +++ b/app/views/shared/issuable/_form.html.haml @@ -21,6 +21,10 @@ #js-suggestions{ data: { project_path: @project.full_path } } = 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 - if issuable.respond_to?(:confidential) diff --git a/app/views/shared/issuable/form/_metadata.html.haml b/app/views/shared/issuable/form/_metadata.html.haml index 1389bc2ab4dc89a6f5ea58da75ee812bdd7d1759..82e435fe0d3e390d22113cf66851cd8d3a3e050f 100644 --- a/app/views/shared/issuable/form/_metadata.html.haml +++ b/app/views/shared/issuable/form/_metadata.html.haml @@ -14,11 +14,13 @@ = render_if_exists "shared/issuable/form/epic", issuable: issuable, form: form, project: project - .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"}" - .col-sm-10{ class: ("col-md-8" if has_due_date) } - .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" + - if issuable.supports_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"}" + .col-sm-10{ class: ("col-md-8" if has_due_date) } + .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" + .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.hidden_field :label_ids, multiple: true, value: '' @@ -30,7 +32,8 @@ - if has_due_date || issuable.supports_weight? .col-lg-6 - = render_if_exists "shared/issuable/form/weight", issuable: issuable, form: form + - if @issue[:issue_type] != 'incident' + = render_if_exists "shared/issuable/form/weight", issuable: issuable, form: form .form-group.row = form.label :due_date, "Due date", class: "col-form-label col-md-2 col-lg-4" .col-8 diff --git a/app/views/shared/issuable/form/_type_selector.html.haml b/app/views/shared/issuable/form/_type_selector.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..1c3a720ebccce66ece3ef91ca4a4e1b2fb7715fb --- /dev/null +++ b/app/views/shared/issuable/form/_type_selector.html.haml @@ -0,0 +1,22 @@ +.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") diff --git a/changelogs/unreleased/230857-incident-type-selector.yml b/changelogs/unreleased/230857-incident-type-selector.yml new file mode 100644 index 0000000000000000000000000000000000000000..6ccbdf4c9fcea7372434135b715a321df3cf93ca --- /dev/null +++ b/changelogs/unreleased/230857-incident-type-selector.yml @@ -0,0 +1,5 @@ +--- +title: Add type selector dropdown to new issue form +merge_request: 40981 +author: +type: changed diff --git a/ee/app/views/shared/issuable/form/_epic.html.haml b/ee/app/views/shared/issuable/form/_epic.html.haml index 117afa5ed8aabbd68582505afdf375439482aa90..1a35c9201016b3ebe54f4c9c963a513921e71ed0 100644 --- a/ee/app/views/shared/issuable/form/_epic.html.haml +++ b/ee/app/views/shared/issuable/form/_epic.html.haml @@ -1,7 +1,7 @@ - project = local_assigns.fetch(:project) - 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-group.row.issue-epic diff --git a/ee/app/views/shared/issuable/form/_weight.html.haml b/ee/app/views/shared/issuable/form/_weight.html.haml index a4016246caf04ee8062762cc027dc8d2595f5bde..0e381a34653900950326d47e0514e1e9cad0beba 100644 --- a/ee/app/views/shared/issuable/form/_weight.html.haml +++ b/ee/app/views/shared/issuable/form/_weight.html.haml @@ -11,4 +11,4 @@ - if issuable.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" diff --git a/locale/gitlab.pot b/locale/gitlab.pot index df6345cba625fd4887bb6a488692bb4e297f22bc..2bae2403562c0f4b45e16f5c6186bb7a59c1805b 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -13052,6 +13052,9 @@ msgstr "" msgid "In the next step, you'll be able to select the projects you want to import." msgstr "" +msgid "Incident" +msgstr "" + msgid "Incident Management Limits" msgstr "" @@ -22212,6 +22215,9 @@ msgstr "" msgid "Select timezone" msgstr "" +msgid "Select type" +msgstr "" + msgid "Select user" msgstr "" diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb index a2c868d02561fa8fbb59b7846c68fe40c8e93a2f..fe7736853737e48a577ee28ce5193e5a279be6e1 100644 --- a/spec/features/issues/user_creates_issue_spec.rb +++ b/spec/features/issues/user_creates_issue_spec.rb @@ -188,6 +188,46 @@ 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 it 'displays list of related issues' do issue = create(:issue, project: project)