]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1524174 - Redirect to show_bug.cgi after creating bug or updating a bug
authorIsrael Madueme <purelogiq@gmail.com>
Wed, 3 Jul 2019 19:38:27 +0000 (15:38 -0400)
committerdklawren <dklawren@users.noreply.github.com>
Wed, 3 Jul 2019 19:38:27 +0000 (15:38 -0400)
extensions/BugModal/template/en/default/bug/show-modal.html.tmpl
post_bug.cgi
process_bug.cgi
qa/t/lib/QA/Util.pm
qa/t/test_bug_edit.t
qa/t/test_qa_contact.t
show_bug.cgi
template/en/default/bug/choose.html.tmpl
template/en/default/bug/process/bugmail.html.tmpl
template/en/default/bug/show.html.tmpl

index f49b874352a3d5e122cc38d037a7de50e304bad2..3d67379f0a9ee32dcd7fb69dad0529edc04a20ed 100644 (file)
   [% 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 %]
index b4bce25bfae668b2031de00b12e7de2212077471..455c016a87e4cb747f93dc00fca4741490688eb2 100755 (executable)
@@ -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;
index 738ea8c194c777d46ae01201c1d4b89defd3df9e..b2763b5dc386153bea9f9dc4670e1e8134d96de5 100755 (executable)
@@ -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;
index 1e73fca0dbda1fbffc9ae51ed6a012ff64fe45a9..84cc2980d2321bb5efadce94b628b2148d490239 100644 (file)
@@ -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");
 }
index 9ccbfdf27318be675f27b1f8fbf8792a2cabb43a..da16d8d562536e7051065478b0dac94db27e63cc 100644 (file)
@@ -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");
index 850c895a2cc5613985551edf0675cf61651baf5d..92bcb02575ef57ac538dd38a01abe1e198e38ee7 100644 (file)
@@ -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);
index fe5e3c462e983590daf7d1ef6f38c7d77ee7c1cf..2322197bffe287b36d5b4030bf8c7f2a47ed0c47 100755 (executable)
@@ -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;
 }
index c4c407abd19e08a10982ffae5a9d5c3b7257ea79..3134001bdb25102a65cea64fd5b71473032c3253 100644 (file)
 
 [% 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 %]
 
 <form method="get" action="[% basepath FILTER none %]show_bug.cgi" data-no-csrf>
   <p>
index 824f640e527c093864095a78e26e55e5ad3d2d95..5f32bae10fdca237c2ad7ca4925052eaaa6b28df 100644 (file)
 
 [%# 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 %]
-
-<script [% script_nonce FILTER none %]>
-  function toggleBugmailRecipients(bug_id, show) {
-    if (show) {
-      $("#bugmail_summary_" + bug_id).show();
-      $("#bugmail_summary_" + bug_id + "_short").hide();
-    } else {
-      $("#bugmail_summary_" + bug_id).hide();
-      $("#bugmail_summary_" + bug_id + "_short").show();
-    }
-    $.cookie('show_bugmail_recipients', (show ? 1 : 0), {
-        expires: new Date("January 12, 2025")
-    });
-  }
-  $(function() {
-    $(".toggleBugmailRecipients").on("click", function (event) {
-      event.preventDefault();
-      toggleBugmailRecipients($(event.target).data('mailing-bugid'),
-                              $(event.target).data('mailing-show'));
-     });
-   });
-</script>
-
-<dl id="bugmail_summary_[% mailing_bugid FILTER none %]"
-    [% IF !show_recipients %]style="display:none;"[% END %]>
-  <dt>Email sent to:</dt>
-  <dd>
-  [% IF user.can_see_bug(mailing_bugid) %]
-    [% IF sent_bugmail.sent.size > 0 %]
-      [%+ FOREACH name = sent_bugmail.sent %]
-        <code>[% name FILTER html %]</code>[% ", " UNLESS loop.last() %]
-      [% END %]
-    [% ELSE %]
-      no one
-    [% END %]
-    (<a href="#" class="toggleBugmailRecipients" data-mailing-bugid="[% mailing_bugid FILTER html %]"
-        data-mailing-show="false">hide</a>)
-  [% ELSE %]
-    (list of e-mails not available)
-  [% END %]
-  </dd>
-</dl>
-
-<div id="bugmail_summary_[% mailing_bugid FILTER none %]_short"
-     [% IF show_recipients %]style="display:none;"[% END %]>
+<div id="bugmail_summary_[% mailing_bugid FILTER none %]_short">
   [% IF recipient_count > 0 %]
     Email sent to [% recipient_count FILTER html %] recipient[% 's' UNLESS recipient_count == 1 %].
-    (<a href="#" class="toggleBugmailRecipients" data-mailing-bugid="[% mailing_bugid FILTER html %]"
-                                                 data-mailing-show="true">show</a>)
   [% ELSE %]
     No emails were sent.
   [% END %]
 </div>
-
index f6cb5c4c4bb2aa4dd56aba34ce318728575347f7..1ae9d55f3735771f5ee2abe9e534c140001e41c5 100644 (file)
 [% 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 %]