[Rt-commit] rt branch, 4.2/fixup-version-history, created. rt-4.1.17-3-g706ca4f

Jim Brandt jbrandt at bestpractical.com
Wed Jul 24 13:56:12 EDT 2013


The branch, 4.2/fixup-version-history has been created
        at  706ca4fd765494ad21f7d0a7fc5c2958a7d0bd3a (commit)

- Log -----------------------------------------------------------------
commit 884b1538125b17fb8a42380f8d42b29b4a1c2260
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Jul 5 10:58:45 2013 -0400

    Hide upgrade history from global attributes on config page
    
    Skipped the entry in code since applying a Limit removed the
    upgrade history when calling the attribute methods in the
    Upgrade history section later on the page.

diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index 71d1702..0802938 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -216,6 +216,7 @@ for my $type (qw/Tickets Queues Transactions Groups PrivilegedUsers Unprivileged
 % my $attrs = $RT::System->Attributes;
 % my $index_size = 0;
 % while ( my $attr = $attrs->Next ) {
+% next if $attr->Name eq 'UpgradeHistory';
 <tr class="<% $index_size%2 ? 'oddline' : 'evenline'%>">
 % if ($attr->Name eq 'UserLogo') {
 %   my $content = $attr->Content;

commit 706ca4fd765494ad21f7d0a7fc5c2958a7d0bd3a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Jul 12 16:22:22 2013 -0400

    Updates to initial display of RT upgrade history
    
    The initial upgrade history section on the Configuration page
    wasn't fully polished. Make full upgrades and their child
    upgrade entries clearer and show current version of RT and
    installed extensions for convenience. Also show upgrades that
    didn't appear to finish.

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 05d0364..0c9d937 100644
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -189,6 +189,7 @@ print "Working with:\n"
 
 my $package = $args{'package'} || 'RT';
 my $ext_version = $args{'ext-version'};
+my $upgrade_id = Digest::MD5::md5_hex(time . {} . $$ . rand(1024));
 
 foreach my $action ( @actions ) {
     no strict 'refs';
@@ -305,7 +306,9 @@ sub action_insert {
         action   => 'insert',
         filename => Cwd::abs_path($file),
         content  => $content,
-        stage    => 'after',);
+        stage    => 'after',
+        type     => 'process initialdata',
+        upgrade_id => $upgrade_id );
 
     $upgrade_data{'ext_version'} = $ext_version if $ext_version;
 
@@ -410,6 +413,7 @@ sub action_upgrade {
         from      => $upgrading_from,
         to        => $upgrading_to,
         versions  => [@versions],
+        upgrade_id => $upgrade_id,
     });
 
     my $previous = $upgrading_from;
@@ -425,6 +429,7 @@ sub action_upgrade {
             stage  => 'before',
             from   => $previous,
             to     => $v,
+            upgrade_id => $upgrade_id,
         });
 
         my %tmp = (%args, datadir => "$base_dir/$v", datafile => undef, backcompat => \@back);
@@ -453,6 +458,7 @@ sub action_upgrade {
             stage  => 'after',
             from   => $previous,
             to     => $v,
+            upgrade_id => $upgrade_id,
         });
 
         $previous = $v;
@@ -465,6 +471,7 @@ sub action_upgrade {
         from      => $upgrading_from,
         to        => $upgrading_to,
         versions  => [@versions],
+        upgrade_id => $upgrade_id,
     });
 
     return 1;
diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index 0802938..acc7952 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -268,47 +268,123 @@ if ($item =~ /^\s*(.*?)\s*v(\S+);/) {
 </&>
 
 <&|/Widgets/TitleBox, title => loc("RT upgrade history")&>
+<%perl>
+my $upgrade_history = RT->System->UpgradeHistory;
+my @packages = ('RT', sort grep { $_ ne 'RT' } keys %$upgrade_history);
+
+if ( not scalar @{$upgrade_history->{'RT'}} ){
+    push @{$upgrade_history->{'RT'}},
+        { stage => 'after',
+          action => 'upgrade',
+          type => 'No upgrade history found',
+          timestamp => '',
+          from => 'N/A',
+          to => 'N/A',
+          rt_version => '',
+          upgrade_id => '1',
+        };
+}
 
-% my $upgrade_history = RT->System->UpgradeHistory;
-% my @packages = ('RT', sort grep { $_ ne 'RT' } keys %$upgrade_history);
-% for my $package (@packages) {
-<h4><% $package %></h4>
+for my $package (@packages) {
+    my $version_status = "Current version: ";
+    if ( $package eq 'RT' ){
+        $version_status .= $RT::VERSION;
+    }
+    elsif ( grep {/$package/} @{RT->Config->Get('Plugins')} ) {
+        {
+            no strict 'refs';
+            $version_status .= ${ $package . '::VERSION' };
+        }
+    }
+    else {
+        $version_status = "Not currently loaded";
+    }
+</%perl>
+
+<h4><% $package . ' (' . $version_status . ')' %></h4>
 <table border="0" cellspacing="0" cellpadding="5" width="100%" class="collection">
 <tr class="collection-as-table">
+<th class="collection-as-table"> </th>
 <th class="collection-as-table"><&|/l&>Action</&></th>
+<th class="collection-as-table"><&|/l&>Date</&></th>
 <th class="collection-as-table"><&|/l&>Using RT Version</&></th>
-<th class="collection-as-table"><&|/l&>Time</&></th>
-<th class="collection-as-table"><&|/l&>Extra</&></th>
 
 <%perl>
-    my $i = 0;
-    for my $upgrade (@{ $upgrade_history->{$package} }) {
-        # only list completed upgrades
-        next unless $upgrade->{stage} eq 'after';
+    my %upgrades;
+    foreach my $upgrade ( @{$upgrade_history->{$package}} ){
+        # Batch upgrade history by id.
+        # Entries within batches are already in time order.
+        push @{$upgrades{$upgrade->{upgrade_id}}}, $upgrade;
+    }
+
+    # Sort the batches by time using first (and possibly only) entry
+    # in each batch.
+    foreach my $upgrade_batch ( sort { $a->[0]{timestamp} <=> $b->[0]{timestamp} }
+                                values %upgrades ){
+
+        my $i = 0;
+        my $full_upgrade = grep { $_->{'type'} eq 'full upgrade' } @{ $upgrade_batch };
+        # Move the full upgrade entry to first
+        unshift @{ $upgrade_batch }, pop @{ $upgrade_batch } if $full_upgrade;
+
+        foreach my $upgrade (@{ $upgrade_batch }) {
+
+        if ( $upgrade->{'stage'} eq 'before' ){
+            # Find a matching after for this before
+            next if ( grep { $_->{'action'} eq 'upgrade'
+                             and $_->{'stage'} eq 'after'
+                             and $_->{'from'} eq $upgrade->{'from'}
+                             and $_->{'to'} eq $upgrade->{'to'} } @{ $upgrade_batch } );
+            $upgrade->{'action'} = 'Individual upgrade from ' . $upgrade->{'from'}
+              . ' to ' . $upgrade->{'to'} . ' started but not completed';
+        }
+
+        my $tr_class = 'oddline';
+        if ( $package eq 'RT' ){
+            if ( $upgrade->{'type'} ne 'full upgrade' ) {
+                $tr_class = 'evenline '
+                  . 'upgrade-history-' . $upgrade->{'upgrade_id'};
+            }
+        }
+        else {
+            $tr_class = $i++ %2 ? 'oddline' : 'evenline';
+        }
+        if ( $full_upgrade and $upgrade->{'type'} eq 'full upgrade' ){
+            my $parent_id = $upgrade->{'upgrade_id'};
 </%perl>
-<tr class="<% $i++ %2 ? 'oddline' : 'evenline'%>">
-    <td class="collection-as-table">
-% if ($upgrade->{action} eq 'upgrade') { # type is more specific for upgrades
-    <% $upgrade->{type} %>
-% } else {
-    <% $upgrade->{action} %>
-% }
-    </td>
-    <td class="collection-as-table">
-        <% $upgrade->{rt_version} %>
-    </td>
-    <td class="collection-as-table">
+    <tr class="oddline">
+    <td class="upgrade-history-parent" id="parent-upgrade-history-<% $parent_id %>">
+    <span class="widget"><a href="#" onclick="return toggleClassElement('<% 'upgrade-history-' . $parent_id %>');"></a></span></td>
+%       } else {
+<tr class="<% $tr_class %>">
+<td class="collection-as-table"></td>
+%       }
+%       if ( $upgrade->{'type'} ne 'full upgrade'
+%            and $full_upgrade ){
+<td class="collection-as-table" style="padding-left:15px">
+%       } else {
+<td class="collection-as-table">
+%       }
+%       if ($upgrade->{'action'} eq 'upgrade') { # type is more specific for upgrades
+<% $upgrade->{'type'} eq 'full upgrade' ? "Upgrade" : "Individual upgrade" %>
+<&|/l, $upgrade->{'from'}, $upgrade->{'to'} &>from [_1] to [_2]</&>
+%       } elsif ( $upgrade->{'type'} eq 'process initialdata' ) {
+<% "Insert from " . $upgrade->{'filename'} %>
+%       } else {
+<% ucfirst($upgrade->{action}) %>
+%       }
+</td>
+<td class="collection-as-table">
 %          my $timestamp = RT::Date->new($session{CurrentUser});
 %          $timestamp->Set(Value => $upgrade->{timestamp});
            <% $timestamp->AsString %>
     </td>
     <td class="collection-as-table">
-% if ($upgrade->{action} eq 'upgrade') {
-    <&|/l, $upgrade->{from}, $upgrade->{to} &>from [_1] to [_2]</&>
-% }
+        <% $upgrade->{rt_version} %>
     </td>
 </tr>
 % }
+% }
 </table>
 % }
 </&>
diff --git a/share/static/css/base/collection.css b/share/static/css/base/collection.css
index d690192..f82ec2c 100644
--- a/share/static/css/base/collection.css
+++ b/share/static/css/base/collection.css
@@ -14,3 +14,16 @@ table.collection td:first-child, table.collection th:first-child {
 .collection-as-table .user a:visited {
     color: inherit;
 }
+
+.upgrade-history-parent .widget a {
+  display: inline-block;
+  margin: 0;
+  width: 20px;
+  background-image: url('../../../static/images/css/rollup-arrow.gif');
+  background-repeat: no-repeat;
+  background-position: center 0;
+  position: static;
+  top: 0.5em;
+  left: 1.2em;
+  padding: 7px 0 0 0;
+}
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 8b91092..40c4b37 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -30,6 +30,19 @@ function switchVisibility(id1, id2) {
     return false;
 }
 
+/* Show/hide with class */
+
+function toggleClassElement(className) {
+    jQuery("." + className).toggle();
+    if ( jQuery("." + className).is(":hidden") ){
+        jQuery("#parent-" + className).find("a").css("background-image", "url('../../../static/images/css/rolldown-arrow.gif')");
+    }
+    else{
+        jQuery("#parent-" + className).find("a").css("background-image", "url('../../../static/images/css/rollup-arrow.gif')");
+    }
+    return false;
+}
+
 /* Classes */
 function jQueryWrap( id ) {
     return typeof id == 'object' ? jQuery(id) : jQuery('#'+id);

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


More information about the Rt-commit mailing list