From: Israel Madueme Date: Wed, 3 Jul 2019 19:38:27 +0000 (-0400) Subject: Bug 1524174 - Redirect to show_bug.cgi after creating bug or updating a bug X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93d946b4f386963de7cb5036cbc58008fc39659a;p=thirdparty%2Fbugzilla.git Bug 1524174 - Redirect to show_bug.cgi after creating bug or updating a bug --- diff --git a/extensions/BugModal/template/en/default/bug/show-modal.html.tmpl b/extensions/BugModal/template/en/default/bug/show-modal.html.tmpl index f49b87435..3d67379f0 100644 --- a/extensions/BugModal/template/en/default/bug/show-modal.html.tmpl +++ b/extensions/BugModal/template/en/default/bug/show-modal.html.tmpl @@ -12,5 +12,16 @@ [% PROCESS global/header.html.tmpl %] [% header_done = 1 %] [% END %] + +[%# Displays changes to bugs that happened in the last request #%] +[% sentmail = c.flash("last_sent_changes") %] +[% FOREACH item = sentmail %] + [% INCLUDE bug/process/results.html.tmpl + id = item.id + type = item.type + recipient_count = item.recipient_count + %] +[% END %] + [% INCLUDE bug_modal/edit.html.tmpl %] [% PROCESS global/footer.html.tmpl %] diff --git a/post_bug.cgi b/post_bug.cgi index b4bce25bf..455c016a8 100755 --- a/post_bug.cgi +++ b/post_bug.cgi @@ -275,39 +275,24 @@ ThrowCodeError("bug_error", {bug => $bug}) if $bug->error; my $recipients = {changer => $user}; my $bug_sent = Bugzilla::BugMail::Send($id, $recipients); -$bug_sent->{type} = 'created'; -$bug_sent->{id} = $id; -my @all_mail_results = ($bug_sent); +my @all_mail_results = ({ id => $id, type => 'created', recipient_count => scalar @{$bug_sent->{sent}} }); foreach my $dep ( map { @{$bug->{$_} || []} } qw(dependson blocked regressed_by regresses) ) { my $dep_sent = Bugzilla::BugMail::Send($dep, $recipients); - $dep_sent->{type} = 'dep'; - $dep_sent->{id} = $dep; - push(@all_mail_results, $dep_sent); + push(@all_mail_results, { id => $dep, type => 'dep', recipient_count => scalar @{$dep_sent->{sent}} }); } # Sending emails for any referenced bugs. foreach my $ref_bug_id (uniq @{$bug->{see_also_changes} || []}) { my $ref_sent = Bugzilla::BugMail::Send($ref_bug_id, $recipients); - $ref_sent->{id} = $ref_bug_id; - push(@all_mail_results, $ref_sent); + push(@all_mail_results, { id => $ref_bug_id, recipient_count => scalar @{$ref_sent->{sent}} }); } -$vars->{sentmail} = \@all_mail_results; +$Bugzilla::App::CGI::C->flash(last_sent_changes => \@all_mail_results); -$format = $template->get_format("bug/create/created", - scalar($cgi->param('created-format')), "html"); - -# don't leak the enter_bug format param to show_bug -$cgi->delete('format'); - -if ($user->setting('ui_experiments') eq 'on') { - $C->content_security_policy(SHOW_BUG_MODAL_CSP($bug->id)); -} -print $cgi->header(); -$template->process($format->{'template'}, $vars) - || ThrowTemplateError($template->error()); +my $redirect_url = $Bugzilla::App::CGI::C->url_for('show_bugcgi')->query(id => $id); +$Bugzilla::App::CGI::C->redirect_to($redirect_url); 1; diff --git a/process_bug.cgi b/process_bug.cgi index 738ea8c19..b2763b5dc 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -429,64 +429,54 @@ foreach my $bug (@bug_objects) { # Delete the session token used for the mass-change. delete_token($token) unless $cgi->param('id'); -# BMO: add show_bug_format hook for experimental UI work -my $format_params = { - format => scalar $cgi->param('format'), - ctype => scalar $cgi->param('ctype'), -}; -Bugzilla::Hook::process('show_bug_format', $format_params); -if ($format_params->{format} eq 'modal') { - my $bug_id = $vars->{bug} ? $vars->{bug}->id : undef; - $C->content_security_policy(SHOW_BUG_MODAL_CSP($bug_id)); -} -my $format = $template->get_format( - "bug/show", - $format_params->{format}, - $format_params->{ctype} -); - if (Bugzilla->usage_mode != USAGE_MODE_EMAIL) { - print $cgi->header(); - - foreach my $sent_changes (@all_sent_changes) { - foreach my $sent_change (@$sent_changes) { - my $params = $sent_change->{params}; - my $sent_bugmail = $sent_change->{sent_bugmail}; - $vars->{$_} = $params->{$_} foreach keys %$params; - $vars->{'sent_bugmail'} = $sent_bugmail; - $template->process("bug/process/results.html.tmpl", $vars) - || ThrowTemplateError($template->error()); - $vars->{'header_done'} = 1; - } - } - if ($action eq 'next_bug' or $action eq 'same_bug') { - my $bug = $vars->{'bug'}; - if ($bug and $user->can_see_bug($bug)) { - if ($action eq 'same_bug') { - - # $bug->update() does not update the internal structure of - # the bug sufficiently to display the bug with the new values. - # (That is, if we just passed in the old Bug object, we'd get - # a lot of old values displayed.) - $bug = Bugzilla::Bug->new($bug->id); - $vars->{'bug'} = $bug; + # We strip the sent changes to just the necessary parameters so that they can + # be saved in the session flash. + my @saved_sent_changes; + foreach my $sent_changes (@all_sent_changes) { + foreach my $sent_change (@$sent_changes) { + my $saved_sent_change = { + id => $sent_change->{params}->{id}, + type => $sent_change->{params}->{type}, + recipient_count => scalar @{$sent_change->{sent_bugmail}->{sent}}, + }; + push @saved_sent_changes, $saved_sent_change; } - $vars->{'bugs'} = [$bug]; - if ($action eq 'next_bug') { - $vars->{'nextbug'} = $bug->id; - } - - $template->process($format->{template}, $vars) - || ThrowTemplateError($template->error()); - exit; } + + $Bugzilla::App::CGI::C->flash(last_sent_changes => \@saved_sent_changes); + + # Redirect to show_bug.cgi. + # $bug_id will be the same bug or the next bug due to checks earlier in this file. + # An undefined $bug_id (in the case of $action = 'nothing') will still redirect to + # show_bug.cgi which will prompt for a bug. This allows mass bug updates to still see + # the result of what changed/emails sent. + my $bug_id = $vars->{bug} ? $vars->{bug}->id : undef; + my $redirect_url = $Bugzilla::App::CGI::C->url_for('show_bugcgi')->query(id => $bug_id); + $Bugzilla::App::CGI::C->redirect_to($redirect_url); + exit; } + else { # Handle $action = 'nothing' or mass bug update case. + print $cgi->header(); + + foreach my $sent_changes (@all_sent_changes) { + foreach my $sent_change (@$sent_changes) { + my $params = $sent_change->{params}; + my $recipient_count = scalar @{$sent_change->{sent_bugmail}->{sent}}; + $vars->{$_} = $params->{$_} foreach keys %$params; + $vars->{'recipient_count'} = $recipient_count; + $template->process("bug/process/results.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + $vars->{'header_done'} = 1; + } + } - # End the response page. - $template->process("bug/navigate.html.tmpl", $vars) - || ThrowTemplateError($template->error()); - $template->process("global/footer.html.tmpl", $vars) - || ThrowTemplateError($template->error()); + # End the response page. + $template->process("bug/navigate.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + $template->process("global/footer.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + } } 1; diff --git a/qa/t/lib/QA/Util.pm b/qa/t/lib/QA/Util.pm index 1e73fca0d..84cc2980d 100644 --- a/qa/t/lib/QA/Util.pm +++ b/qa/t/lib/QA/Util.pm @@ -469,11 +469,14 @@ sub check_page_load { } } - if ($expected_uri->query_param('id')) { - if ($expected_uri->query_param('id') eq '__BUG_ID__') { - $uri->query_param('id' => '__BUG_ID__'); - } + if ($expected_uri->query_param('id') and $expected_uri->query_param('id') eq '__BUG_ID__') { + $uri->query_param('id' => '__BUG_ID__'); + } + + if ($expected_uri->query_param('list_id') and $expected_uri->query_param('list_id') eq '__LIST_ID__') { + $uri->query_param('list_id' => '__LIST_ID__'); } + my ($pkg, $file, $line) = caller; is($uri, $expected_uri, "checking location on $file line $line"); } diff --git a/qa/t/test_bug_edit.t b/qa/t/test_bug_edit.t index 9ccbfdf27..da16d8d56 100644 --- a/qa/t/test_bug_edit.t +++ b/qa/t/test_bug_edit.t @@ -311,16 +311,17 @@ $sel->type_ok("email2", $config->{QA_Selenium_TEST_user_login}); screenshot_page($sel, '/app/artifacts/line271.png'); $sel->click_ok("Search"); check_page_load($sel, - q{http://HOSTNAME/buglist.cgi?emailreporter2=1&emailtype2=exact&order=Importance&list_id=15&emailtype1=exact&emailcc2=1&query_format=advanced&emailassigned_to1=1&emailqa_contact2=1&email2=QA-Selenium-TEST%40mozilla.test&email1=admin%40mozilla.test&emailassigned_to2=1&product=TestProduct} + q{http://HOSTNAME/buglist.cgi?emailreporter2=1&emailtype2=exact&order=Importance&list_id=__LIST_ID__&emailtype1=exact&emailcc2=1&query_format=advanced&emailassigned_to1=1&emailqa_contact2=1&email2=QA-Selenium-TEST%40mozilla.test&email1=admin%40mozilla.test&emailassigned_to2=1&product=TestProduct} ); $sel->title_is("Bug List"); screenshot_page($sel, '/app/artifacts/line275.png'); $sel->is_text_present_ok("One bug found."); $sel->type_ok("save_newqueryname", "My bugs from QA_Selenium"); $sel->click_ok("remember"); -check_page_load($sel, - q{http://HOSTNAME/buglist.cgi?newquery=email1%3Dadmin%2540mozilla.test%26email2%3DQA-Selenium-TEST%2540mozilla.test%26emailassigned_to1%3D1%26emailassigned_to2%3D1%26emailcc2%3D1%26emailqa_contact2%3D1%26emailreporter2%3D1%26emailtype1%3Dexact%26emailtype2%3Dexact%26list_id%3D15%26product%3DTestProduct%26query_format%3Dadvanced%26order%3Dpriority%252Cbug_severity&cmdtype=doit&remtype=asnamed&token=1531926552-dc69995d79c786af046436ec6717000b&newqueryname=My%20bugs%20from%20QA_Selenium&list_id=16} -); +# Bad test below, unable to deterministically know the inner list_id encoded in the newquery param. +# check_page_load($sel, +# q{http://HOSTNAME/buglist.cgi?newquery=email1%3Dadmin%2540mozilla.test%26email2%3DQA-Selenium-TEST%2540mozilla.test%26emailassigned_to1%3D1%26emailassigned_to2%3D1%26emailcc2%3D1%26emailqa_contact2%3D1%26emailreporter2%3D1%26emailtype1%3Dexact%26emailtype2%3Dexact%26list_id%3D15%26product%3DTestProduct%26query_format%3Dadvanced%26order%3Dpriority%252Cbug_severity&cmdtype=doit&remtype=asnamed&token=1531926552-dc69995d79c786af046436ec6717000b&newqueryname=My+bugs+from+QA_Selenium&list_id=__LIST_ID__} +# ); $sel->title_is("Search created"); $sel->is_text_present_ok( "OK, you have a new search named My bugs from QA_Selenium."); @@ -328,7 +329,7 @@ $sel->click_ok( '//a[normalize-space(text())="My bugs from QA_Selenium" and not(@role="option")]' ); check_page_load($sel, - q{http://HOSTNAME/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=17} + q{http://HOSTNAME/buglist.cgi?cmdtype=runnamed&namedcmd=My+bugs+from+QA_Selenium&list_id=__LIST_ID__} ); $sel->title_is("Bug List: My bugs from QA_Selenium"); logout($sel); @@ -387,7 +388,7 @@ $sel->click_ok( '//a[normalize-space(text())="My bugs from QA_Selenium" and @role="option"]'); screenshot_page($sel, '/app/artifacts/line344.png'); check_page_load($sel, - q{http://HOSTNAME/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=19} + q{http://HOSTNAME/buglist.cgi?cmdtype=runnamed&namedcmd=My+bugs+from+QA_Selenium&list_id=__LIST_ID__} ); screenshot_page($sel, '/app/artifacts/line346.png'); $sel->title_is("Bug List: My bugs from QA_Selenium"); @@ -396,7 +397,7 @@ $sel->is_text_present_ok("2 bugs found"); screenshot_page($sel, '/app/artifacts/line350.png'); $sel->click_ok('change-several'); check_page_load($sel, - q{http://HOSTNAME/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=20} + q{http://HOSTNAME/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=__LIST_ID__} ); $sel->title_is("Bug List"); $sel->click_ok("check_all"); @@ -523,13 +524,13 @@ $sel->click_ok('quicksearch_top'); $sel->click_ok( '//a[normalize-space(text())="My bugs from QA_Selenium" and @role="option"]'); check_page_load($sel, - q{http://HOSTNAME/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=21} + q{http://HOSTNAME/buglist.cgi?cmdtype=runnamed&namedcmd=My+bugs+from+QA_Selenium&list_id=__LIST_ID__} ); $sel->title_is("Bug List: My bugs from QA_Selenium"); $sel->is_text_present_ok("2 bugs found"); $sel->click_ok('change-several', 'Change Several Bugs at Once'); check_page_load($sel, - q{http://HOSTNAME/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=22} + q{http://HOSTNAME/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=__LIST_ID__} ); $sel->title_is("Bug List"); $sel->click_ok("check_all"); @@ -545,12 +546,12 @@ $sel->click_ok('quicksearch_top'); $sel->click_ok( '//a[normalize-space(text())="My bugs from QA_Selenium" and @role="option"]'); check_page_load($sel, - q{http://HOSTNAME/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=23} + q{http://HOSTNAME/buglist.cgi?cmdtype=runnamed&namedcmd=My+bugs+from+QA_Selenium&list_id=__LIST_ID__} ); $sel->title_is("Bug List: My bugs from QA_Selenium"); $sel->click_ok('forget-search', 'Forget Search'); check_page_load($sel, - q{http://HOSTNAME/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=My%20bugs%20from%20QA_Selenium&token=1531926582-f228fa8ebc2f2b3970f2a791e54534ec&list_id=24} + q{http://HOSTNAME/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=My+bugs+from+QA_Selenium&token=1531926582-f228fa8ebc2f2b3970f2a791e54534ec&list_id=__LIST_ID__} ); $sel->title_is("Search is gone"); $sel->is_text_present_ok("OK, the My bugs from QA_Selenium search is gone"); diff --git a/qa/t/test_qa_contact.t b/qa/t/test_qa_contact.t index 850c895a2..92bcb0257 100644 --- a/qa/t/test_qa_contact.t +++ b/qa/t/test_qa_contact.t @@ -192,9 +192,6 @@ $sel->click_ok('bottom-save-btn'); # The user is no longer the QA contact, and he has no other role # with the bug. He can no longer see it. -$sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->is_text_present_ok("(list of e-mails not available)"); -$sel->click_ok("link=bug $bug1_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Access Denied"); logout($sel); diff --git a/show_bug.cgi b/show_bug.cgi index fe5e3c462..2322197bf 100755 --- a/show_bug.cgi +++ b/show_bug.cgi @@ -51,7 +51,7 @@ my $single = (!$format->{format} || $format->{format} ne 'multiple') # If we don't have an ID, _AND_ we're only doing a single bug, then prompt if (!$cgi->param('id') && $single) { print Bugzilla->cgi->header(); - $template->process("bug/choose.html.tmpl", $vars) + $template->process('bug/choose.html.tmpl', $vars) || ThrowTemplateError($template->error()); exit; } diff --git a/template/en/default/bug/choose.html.tmpl b/template/en/default/bug/choose.html.tmpl index c4c407abd..3134001bd 100644 --- a/template/en/default/bug/choose.html.tmpl +++ b/template/en/default/bug/choose.html.tmpl @@ -20,9 +20,20 @@ [% PROCESS global/variables.none.tmpl %] -[% PROCESS global/header.html.tmpl - title = "Search by $terms.bug number" - %] +[% UNLESS header_done %] + [% PROCESS bug/process/header.html.tmpl title = "Search by $terms.bug number" %] + [% header_done = 1 %] +[% END %] + +[%# Displays changes to bugs that happened in the last request #%] +[% sentmail = c.flash("last_sent_changes") %] +[% FOREACH item = sentmail %] + [% INCLUDE bug/process/results.html.tmpl + id = item.id + type = item.type + recipient_count = item.recipient_count + %] +[% END %]

diff --git a/template/en/default/bug/process/bugmail.html.tmpl b/template/en/default/bug/process/bugmail.html.tmpl index 824f640e5..5f32bae10 100644 --- a/template/en/default/bug/process/bugmail.html.tmpl +++ b/template/en/default/bug/process/bugmail.html.tmpl @@ -21,70 +21,16 @@ [%# INTERFACE: # mailing_bugid: The bug ID that email is being sent for. - # sent_bugmail: The results of Bugzilla::BugMail::Send(). + # recipient_count: The number of people that were emailed. #%] [% USE Bugzilla %] [% PROCESS global/variables.none.tmpl %] -[%# hide the recipient list by default from new users %] -[% show_recipients = - user.settings.post_bug_submit_action.value == 'nothing' - || Bugzilla.cgi.cookie('show_bugmail_recipients') - || !user.can_see_bug(mailing_bugid) -%] -[% recipient_count = sent_bugmail.sent.size %] - - - -

-
Email sent to:
-
- [% IF user.can_see_bug(mailing_bugid) %] - [% IF sent_bugmail.sent.size > 0 %] - [%+ FOREACH name = sent_bugmail.sent %] - [% name FILTER html %][% ", " UNLESS loop.last() %] - [% END %] - [% ELSE %] - no one - [% END %] - (hide) - [% ELSE %] - (list of e-mails not available) - [% END %] -
-
- -
+
[% IF recipient_count > 0 %] Email sent to [% recipient_count FILTER html %] recipient[% 's' UNLESS recipient_count == 1 %]. - (show) [% ELSE %] No emails were sent. [% END %]
- diff --git a/template/en/default/bug/show.html.tmpl b/template/en/default/bug/show.html.tmpl index f6cb5c4c4..1ae9d55f3 100644 --- a/template/en/default/bug/show.html.tmpl +++ b/template/en/default/bug/show.html.tmpl @@ -29,6 +29,17 @@ [% IF !header_done %] [% PROCESS "bug/show-header.html.tmpl" %] [% PROCESS global/header.html.tmpl %] + [% header_done = 1 %] +[% END %] + +[%# Displays changes to bugs that happened in the last request #%] +[% sentmail = c.flash("last_sent_changes") %] +[% FOREACH item = sentmail %] + [% INCLUDE bug/process/results.html.tmpl + id = item.id + type = item.type + recipient_count = item.recipient_count + %] [% END %] [% IF nextbug %]