Commit 88f43c7d authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'issue-type-selector-technical-dept' into 'master'

Reduce type selector technical dept

See merge request gitlab-org/gitlab!41752
parents 47cea0c2 40320141
...@@ -189,6 +189,10 @@ module Issuable ...@@ -189,6 +189,10 @@ module Issuable
is_a?(Issue) && super is_a?(Issue) && super
end end
def supports_issue_type?
is_a?(Issue)
end
def severity def severity
return IssuableSeverity::DEFAULT unless incident? return IssuableSeverity::DEFAULT unless incident?
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
= 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
= 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
......
...@@ -32,8 +32,7 @@ ...@@ -32,8 +32,7 @@
- if has_due_date - if has_due_date
.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"
.col-8 .col-8
......
- return unless issuable.supports_issue_type?
.form-group.row.gl-mb-0 .form-group.row.gl-mb-0
= form.label :type, 'Type', class: 'col-form-label col-sm-2' = form.label :type, 'Type', class: 'col-form-label col-sm-2'
.col-sm-10 .col-sm-10
...@@ -5,7 +7,7 @@ ...@@ -5,7 +7,7 @@
.dropdown.js-issuable-type-filter-dropdown-wrap .dropdown.js-issuable-type-filter-dropdown-wrap
%button.dropdown-menu-toggle{ type: 'button', 'data-toggle' => 'dropdown' } %button.dropdown-menu-toggle{ type: 'button', 'data-toggle' => 'dropdown' }
%span.dropdown-toggle-text.is-default %span.dropdown-toggle-text.is-default
= type.capitalize || _("Select type") = issuable.issue_type.capitalize || _("Select type")
= icon('chevron-down') = icon('chevron-down')
.dropdown-menu.dropdown-menu-selectable.dropdown-select .dropdown-menu.dropdown-menu-selectable.dropdown-select
.dropdown-title .dropdown-title
...@@ -15,12 +17,12 @@ ...@@ -15,12 +17,12 @@
.dropdown-content .dropdown-content
%ul %ul
%li.js-filter-issuable-type %li.js-filter-issuable-type
= link_to new_project_issue_path(@project), class: ("is-active" if type === 'issue') do = link_to new_project_issue_path(@project), class: ("is-active" if issuable.issue?) do
= _("Issue") = _("Issue")
%li.js-filter-issuable-type %li.js-filter-issuable-type
= link_to new_project_issue_path(@project, { issuable_template: 'incident', issue: { issue_type: 'incident' } }), class: ("is-active" if type === 'incident') do = link_to new_project_issue_path(@project, { issuable_template: 'incident', issue: { issue_type: 'incident' } }), class: ("is-active" if issuable.incident?) do
= _("Incident") = _("Incident")
- if type === 'incident' - if issuable.incident?
%p.form-text.text-muted %p.form-text.text-muted
- incident_docs_url = help_page_path('operations/incident_management/incidents.md', anchor: 'create-and-manage-incidents-in-gitlab') - incident_docs_url = help_page_path('operations/incident_management/incidents.md', anchor: 'create-and-manage-incidents-in-gitlab')
- incident_docs_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: incident_docs_url } - incident_docs_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: incident_docs_url }
......
...@@ -855,6 +855,23 @@ RSpec.describe Issuable do ...@@ -855,6 +855,23 @@ RSpec.describe Issuable do
end end
end end
describe '#supports_issue_type?' do
using RSpec::Parameterized::TableSyntax
where(:issuable_type, :supports_issue_type) do
:issue | true
:merge_request | false
end
with_them do
let(:issuable) { build_stubbed(issuable_type) }
subject { issuable.supports_issue_type? }
it { is_expected.to eq(supports_issue_type) }
end
end
describe '#severity' do describe '#severity' do
subject { issuable.severity } subject { issuable.severity }
......
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