From: Kohei Yoshino Date: Thu, 27 Jun 2019 20:08:25 +0000 (-0400) Subject: Bug 1546788 - Deselect bug type by default unless component-specific type is defined X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e20126bc12075b419caa9aefc4fa9af927a2b73c;p=thirdparty%2Fbugzilla.git Bug 1546788 - Deselect bug type by default unless component-specific type is defined --- diff --git a/Bugzilla/Config/BugFields.pm b/Bugzilla/Config/BugFields.pm index dee0717ce..3100412d3 100644 --- a/Bugzilla/Config/BugFields.pm +++ b/Bugzilla/Config/BugFields.pm @@ -44,7 +44,7 @@ sub get_param_list { name => 'default_bug_type', type => 's', choices => \@legal_types, - default => 'defect', + default => $legal_types[-1], checker => \&check_bug_type }, diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 5f581e377..a12cf2e86 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -252,6 +252,7 @@ use constant DEFAULT_FIELDS => ( name => 'bug_type', desc => 'Type', in_new_bugmail => 1, + is_mandatory => 1, type => FIELD_TYPE_SINGLE_SELECT, buglist => 1 }, diff --git a/Bugzilla/Test/Util.pm b/Bugzilla/Test/Util.pm index e826d97e0..4d7d662ff 100644 --- a/Bugzilla/Test/Util.pm +++ b/Bugzilla/Test/Util.pm @@ -103,7 +103,7 @@ sub create_bug { default => sub {$Component} }, bug_type => Str, - {default => 'defect'}, + {default => '--'}, bug_severity => Str, {default => 'normal'}, groups => ArrayRef [Str], diff --git a/conf/checksetup_answers.txt b/conf/checksetup_answers.txt index 19ecce06b..236139fa6 100644 --- a/conf/checksetup_answers.txt +++ b/conf/checksetup_answers.txt @@ -22,7 +22,7 @@ $answer{'usetargetmilestone'} = 1; $answer{'webdotbase'} = '/usr/bin/dot'; $answer{'auth_delegation'} = 1; $answer{'insidergroup'} = 'admin'; -$answer{'default_bug_type'} = 'defect'; +$answer{'default_bug_type'} = '--'; $answer{'defaultpriority'} = '--'; $answer{'defaultseverity'} = 'normal'; $answer{'skin'} = 'Mozilla'; diff --git a/docs/en/rst/api/core/v1/bugzilla.rst b/docs/en/rst/api/core/v1/bugzilla.rst index d0453887d..c934d33ac 100644 --- a/docs/en/rst/api/core/v1/bugzilla.rst +++ b/docs/en/rst/api/core/v1/bugzilla.rst @@ -193,7 +193,7 @@ Example response for authenticated user: "defaultplatform" : "", "defaultpriority" : "--", "defaultseverity" : "normal", - "default_bug_type" : "defect", + "default_bug_type" : "--", "duplicate_or_move_bug_status" : "RESOLVED", "emailregexp" : "^[\\w\\.\\+\\-=']+@[\\w\\.\\-]+\\.[\\w\\-]+$", "emailsuffix" : "", diff --git a/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl index d37d0e933..14f42afc8 100644 --- a/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl @@ -190,11 +190,13 @@ END; [%# single value select %] [% IF use_buttons %] -
+
[% IF values.defined %] [% FOREACH v IN values %] [% NEXT IF NOT v.is_active AND NOT value.contains(v.name).size %] [% NEXT IF NOT bug.check_can_change_field(name, bug.${field_name}, v.name) %] + [% NEXT IF field.is_mandatory && v.name == '--' %]
diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index 04e3f01b4..c8ca6fe59 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -548,9 +548,13 @@ $(function() { if (!$select) return; // It can be radio-button-like UI const use_buttons = $select.matches('.buttons.toggle'); + const is_required = $select.matches('[aria-required="true"]'); const selected = use_buttons ? $select.querySelector('input').value : $select.value; $select.innerHTML = ''; value.forEach(({ name }) => { + if (is_required && name === '--') { + return; + } if (use_buttons) { $select.insertAdjacentHTML('beforeend', `
diff --git a/js/field.js b/js/field.js index 497d0da42..da1c44b9a 100644 --- a/js/field.js +++ b/js/field.js @@ -35,6 +35,7 @@ function validateEnterBug(theform) { var short_desc = theform.short_desc; var version = theform.version; var bug_status = theform.bug_status; + var bug_type = theform.bug_type; var description = theform.comment; var attach_data = theform.data; var attach_desc = theform.description; @@ -76,6 +77,10 @@ function validateEnterBug(theform) { _errorFor(component); focus_me = component; } + if (!bug_type.value) { + _errorFor(document.querySelector('#bug_type')); + focus_me = bug_type[0]; + } if (focus_me) { focus_me.focus(); diff --git a/qa/t/lib/QA/Util.pm b/qa/t/lib/QA/Util.pm index 28ff07e57..1e73fca0d 100644 --- a/qa/t/lib/QA/Util.pm +++ b/qa/t/lib/QA/Util.pm @@ -260,6 +260,12 @@ sub file_bug_in_product { } $sel->title_is("Enter Bug: $product", "Display form to enter bug data"); sleep(1); # FIXME: Delay for slow page performance + + # Select the defect type by default + # `check_ok()` doesn't work here because the checkbox is invisible + $sel->driver->execute_script(' + document.querySelector(\'input[name="bug_type"][value="defect"]\').checked = true; + '); } sub create_bug { diff --git a/qa/t/test_bug_edit.t b/qa/t/test_bug_edit.t index 765a531bc..9ccbfdf27 100644 --- a/qa/t/test_bug_edit.t +++ b/qa/t/test_bug_edit.t @@ -53,7 +53,6 @@ logout($sel); log_in($sel, $config, 'QA_Selenium_TEST'); file_bug_in_product($sel, 'TestProduct'); -$sel->check_ok('//input[@name="bug_type" and @value="defect"]'); $sel->select_ok("bug_severity", "label=critical"); $sel->type_ok("short_desc", "Test bug editing"); $sel->type_ok("comment", "ploc"); @@ -339,7 +338,6 @@ logout($sel); log_in($sel, $config, 'QA_Selenium_TEST'); file_bug_in_product($sel, 'TestProduct'); -$sel->check_ok('//input[@name="bug_type" and @value="defect"]'); $sel->select_ok("bug_severity", "label=blocker"); $sel->type_ok("short_desc", "New bug from me"); diff --git a/qa/t/webservice_bug_fields.t b/qa/t/webservice_bug_fields.t index 48373a885..ab4a43e1b 100644 --- a/qa/t/webservice_bug_fields.t +++ b/qa/t/webservice_bug_fields.t @@ -83,7 +83,7 @@ use constant ALL_SELECT_FIELDS => use constant PRODUCT_FIELDS => qw(version target_milestone component); use constant ALL_FIELDS => (GLOBAL_GENERAL_FIELDS, ALL_SELECT_FIELDS, PRODUCT_FIELDS); -use constant MANDATORY_FIELDS => qw(short_desc product version component); +use constant MANDATORY_FIELDS => qw(short_desc product version component bug_type); use constant PUBLIC_PRODUCT => 'Another Product'; use constant PRIVATE_PRODUCT => 'QA-Selenium-TEST'; diff --git a/scripts/c9-install b/scripts/c9-install index 89cec5716..aabe45782 100755 --- a/scripts/c9-install +++ b/scripts/c9-install @@ -55,7 +55,7 @@ $answer{'usetargetmilestone'} = 1; $answer{'webdotbase'} = '/usr/bin/dot'; $answer{'auth_delegation'} = 1; $answer{'insidergroup'} = 'admin'; -$answer{'default_bug_type'} = 'defect'; +$answer{'default_bug_type'} = '--'; $answer{'defaultpriority'} = '--'; $answer{'defaultseverity'} = 'normal'; $answer{'maxattachmentsize'} = 4095; diff --git a/scripts/generate_bmo_data.pl b/scripts/generate_bmo_data.pl index 7b5ff6108..30ae5a49e 100755 --- a/scripts/generate_bmo_data.pl +++ b/scripts/generate_bmo_data.pl @@ -483,7 +483,7 @@ my %set_params = ( confirmuniqueusermatch => 0, maxusermatches => '100', debug_group => 'editbugs', - default_bug_type => 'defect', + default_bug_type => '--', defaultpriority => '--', # FIXME: add priority defaultquery => 'resolution=---&emailassigned_to1=1&emailassigned_to2=1' . '&emailreporter2=1&emailqa_contact2=1&emailtype1=exact' diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl index d9cc8e7c2..e47542ada 100644 --- a/template/en/default/bug/field.html.tmpl +++ b/template/en/default/bug/field.html.tmpl @@ -103,7 +103,8 @@ constants.FIELD_TYPE_MULTI_SELECT ] %] [% IF use_buttons %] -
+
[% ELSE %] { # Please keep these in alphabetical order. + bug_type_required => + "You must select a Type for this $terms.bug", component_required => "You must select a Component for this $terms.bug", description_required => diff --git a/vagrant_support/checksetup_answers.j2 b/vagrant_support/checksetup_answers.j2 index a79df9b62..75505e751 100644 --- a/vagrant_support/checksetup_answers.j2 +++ b/vagrant_support/checksetup_answers.j2 @@ -33,7 +33,7 @@ $answer{'usetargetmilestone'} = 1; $answer{'webdotbase'} = '/usr/bin/dot'; $answer{'auth_delegation'} = 1; $answer{'insidergroup'} = 'admin'; -$answer{'default_bug_type'} = 'defect'; +$answer{'default_bug_type'} = '--'; $answer{'defaultpriority'} = '--'; $answer{'defaultseverity'} = 'normal'; $answer{'skin'} = 'Mozilla';