[Rt-commit] rt branch, 4.2/delay-transaction-loading, updated. rt-4.0.4-235-ge342c4c

Thomas Sibley trs at bestpractical.com
Wed Jan 2 16:30:44 EST 2013


The branch, 4.2/delay-transaction-loading has been updated
       via  e342c4c72f6cbc15d77c16f119ef13ff2425299a (commit)
      from  5275b8dc87558bf95c0ef499c78e54e58225205e (commit)

Summary of changes:
 docs/UPGRADING-4.2             |  5 +++++
 etc/RT_Config.pm.in            | 38 +++++++++++++++++++++++--------------
 etc/upgrade/4.1.6/content      | 43 ++++++++++++++++++++++++++++++++++++++++++
 lib/RT/Config.pm               | 21 +++++++++------------
 lib/RT/Test.pm                 |  1 +
 share/html/Ticket/Display.html |  7 +++----
 6 files changed, 85 insertions(+), 30 deletions(-)
 create mode 100644 etc/upgrade/4.1.6/content

- Log -----------------------------------------------------------------
commit e342c4c72f6cbc15d77c16f119ef13ff2425299a
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Jan 2 12:28:59 2013 -0800

    Combine the two "TransactionLoading" configs, Defer and Delay, into one
    
    The new config option is called ShowHistory and may be one of three
    values: delay, click (previously defer), and always.  The default is
    "delay" since it provides superior page load times.
    
    A single option simplifies user preferences and makes it clear that this
    is a "pick one" choice.  You can't have both delayed loading and click
    to load.
    
    An upgrade script takes care of porting DeferTransactionLoading
    preferences forward.  For preferences which are explicitly false, we
    remove the entry and set ShowHistory to "delay".  "always" may
    technically be the most correct interpretation, but "delay" is the most
    useful and still shows history without any interaction.

diff --git a/docs/UPGRADING-4.2 b/docs/UPGRADING-4.2
index 66af083..19d967d 100644
--- a/docs/UPGRADING-4.2
+++ b/docs/UPGRADING-4.2
@@ -4,3 +4,8 @@ UPGRADING FROM RT 4.0.0 and greater
   describes what the log level controls.  Setting $LogToScreen will still work,
   but an informational notice will be issued on server start telling you about
   the rename.  To avoid this you should set $LogToSTDERR instead.
+
+* The $DeferTransactionLoading was combined into the new option $ShowHistory.
+  If you had enabled $DeferTransactionLoading, you may want to set $ShowHistory
+  to "click".  However, $ShowHistory provides a new mode, "defer", which is the
+  default and may be a more appealing alternative to "click".
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 4e68025..935bca4 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1481,29 +1481,39 @@ option can be overridden by users in their preferences.
 
 Set($OldestTransactionsFirst, 1);
 
-=item C<$DelayTransactionLoading>
+=item C<$ShowHistory>
 
-When set, delays loading ticket history until after the rest of the
-ticket display loads.  This should end up serving pages to users
-quicker, since generating all the HTML for transaction history can be
-slow for long tickets.
+This option controls how history is shown on the ticket display page.  It
+accepts one of three possible modes and is overrideable on a per-user
+preference level.  If you regularly deal with long tickets and don't care much
+about the history, you may wish to change this option to C<click>.
 
-Unlike C<$DeferTransactionLoading> below, it doesn't require any extra
-click to view the ticket history.
+=over
 
-=cut
+=item C<delay> (the default)
+
+When set to C<delay>, history is loaded via javascript after the rest of the
+page has been loaded.  This speeds up apparent page load times and generally
+provides a smoother experience.  You may notice slight delays before the ticket
+history appears on very long tickets.
+
+=item C<click>
 
-# Set($DelayTransactionLoading, 1);
+When set to C<click>, history is loaded on demand when a placeholder link is
+clicked.  This speeds up ticket display page loads and history is never loaded
+if not requested.
 
-=item C<$DeferTransactionLoading>
+=item C<always>
 
-When set, defers loading ticket history until the user clicks a link.
-This should end up serving pages to users quicker, since generating
-all the HTML for transaction history can be slow for long tickets.
+When set to C<always>, history is loaded before showing the page.  This ensures
+history is always available immediately, but at the expense of longer page load
+times.  This behaviour was the default in RT 4.0.
+
+=back
 
 =cut
 
-# Set($DeferTransactionLoading, 1);
+Set($ShowHistory, 'delay');
 
 =item C<$ShowBccHeader>
 
diff --git a/etc/upgrade/4.1.6/content b/etc/upgrade/4.1.6/content
new file mode 100644
index 0000000..d27014c
--- /dev/null
+++ b/etc/upgrade/4.1.6/content
@@ -0,0 +1,43 @@
+use strict;
+use warnings;
+
+our @Initial = (sub {
+    my $users = RT::Users->new(RT->SystemUser);
+    $users->FindAllRows;
+
+    my $attributes = $users->Join(
+        ALIAS1  => "main",
+        FIELD1  => "id",
+        TABLE2  => RT::Attributes->Table,
+        FIELD2  => "ObjectId",
+    );
+    $users->Limit(
+        ALIAS   => $attributes,
+        FIELD   => "ObjectType",
+        VALUE   => "RT::User",
+    );
+    $users->Limit(
+        ALIAS   => $attributes,
+        FIELD   => "Name",
+        VALUE   => RT::User::_PrefName( RT->System ),
+    );
+
+    # Iterate all users (including disabled), with config preferences set.
+    # Avoids running a query for every user in the system by only selecting
+    # those known to have preferences.
+    while (my $user = $users->Next) {
+        RT->Logger->debug(sprintf "User #%d has config preferences", $user->id);
+
+        my $config = $user->Preferences( RT->System )
+            or next;
+        next unless exists $config->{DeferTransactionLoading};
+
+        $config->{ShowHistory} = delete $config->{DeferTransactionLoading}
+            ? "click" : "delay";
+
+        $user->SetPreferences( RT->System, $config );
+        RT->Logger->debug(sprintf "Updated config Preferences for user %s (#%d)", $user->Name, $user->id);
+    }
+});
+
+1;
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 973d6ec..be916eb 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -357,22 +357,19 @@ our %META = (
             Description => 'Show oldest history first',    #loc
         },
     },
-    DeferTransactionLoading => {
+    ShowHistory => {
         Section         => 'Ticket display',
         Overridable     => 1,
         SortOrder       => 3,
-        Widget          => '/Widgets/Form/Boolean',
-        WidgetArguments => {
-            Description => 'Hide ticket history by default',    #loc
-        },
-    },
-    DelayTransactionLoading => {
-        Section         => 'Ticket display',
-        Overridable     => 1,
-        SortOrder       => 3.1,
-        Widget          => '/Widgets/Form/Boolean',
+        Widget          => '/Widgets/Form/Select',
         WidgetArguments => {
-            Description => 'Delay load ticket history by default',    #loc
+            Description => 'Show history',                #loc
+            Values      => [qw(delay click always)],
+            ValuesLabel => {
+                delay   => "after the rest of the page loads",  #loc
+                click   => "after clicking a link",             #loc
+                always  => "immediately",                       #loc
+            },
         },
     },
     ShowUnreadMessageNotifications => { 
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 19dfb0d..af1efe4 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -273,6 +273,7 @@ Set( \$WebPort,   $port);
 Set( \$WebPath,   "");
 Set( \@LexiconLanguages, qw(en zh_TW zh_CN fr ja));
 Set( \$RTAddressRegexp , qr/^bad_re_that_doesnt_match\$/i);
+Set( \$ShowHistory, "always");
 };
     if ( $ENV{'RT_TEST_DB_SID'} ) { # oracle case
         print $config "Set( \$DatabaseName , '$ENV{'RT_TEST_DB_SID'}' );\n";
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index b81bb6f..c251730 100755
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -65,14 +65,13 @@
 
 % $m->callback( Ticket => $TicketObj, %ARGS, CallbackName => 'BeforeShowHistory' );
 
-% if (not $ForceShowHistory
-%     and RT->Config->Get( 'DelayTransactionLoading', $session{'CurrentUser'} )) {
+% my $ShowHistory = RT->Config->Get("ShowHistory", $session{'CurrentUser'});
+% if (not $ForceShowHistory and $ShowHistory eq "delay") {
     <& /Ticket/Elements/DelayShowHistory,
         Ticket => $TicketObj,
         ShowHeaders => $ARGS{'ShowHeaders'},
     &>
-% } elsif (not $ForceShowHistory
-%          and RT->Config->Get( 'DeferTransactionLoading', $session{'CurrentUser'} )) {
+% } elsif (not $ForceShowHistory and $ShowHistory eq "click") {
     <& /Ticket/Elements/ClickToShowHistory,
         Ticket => $TicketObj,
         ShowHeaders => $ARGS{'ShowHeaders'},

-----------------------------------------------------------------------


More information about the Rt-commit mailing list