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
is_a?(Issue) && super
end
def supports_issue_type?
is_a?(Issue)
end
def severity
return IssuableSeverity::DEFAULT unless incident?
......
......@@ -22,8 +22,7 @@
= 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/issuable/form/type_selector', issuable: issuable, form: form
= render 'shared/form_elements/description', model: issuable, form: form, project: project
......
......@@ -32,8 +32,7 @@
- if has_due_date
.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.label :due_date, "Due date", class: "col-form-label col-md-2 col-lg-4"
.col-8
......
- return unless issuable.supports_issue_type?
.form-group.row.gl-mb-0
= form.label :type, 'Type', class: 'col-form-label col-sm-2'
.col-sm-10
......@@ -5,7 +7,7 @@
.dropdown.js-issuable-type-filter-dropdown-wrap
%button.dropdown-menu-toggle{ type: 'button', 'data-toggle' => 'dropdown' }
%span.dropdown-toggle-text.is-default
= type.capitalize || _("Select type")
= issuable.issue_type.capitalize || _("Select type")
= icon('chevron-down')
.dropdown-menu.dropdown-menu-selectable.dropdown-select
.dropdown-title
......@@ -15,12 +17,12 @@
.dropdown-content
%ul
%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")
%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")
- if type === 'incident'
- if issuable.incident?
%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_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: incident_docs_url }
......
......@@ -855,6 +855,23 @@ RSpec.describe Issuable do
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
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