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

Jim Brandt jbrandt at bestpractical.com
Fri Jul 19 14:44:52 EDT 2013


The branch, 4.2/fixup-version-history has been created
        at  824c4078f51d495021ac7e2b3b1cc7117b64141b (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 824c4078f51d495021ac7e2b3b1cc7117b64141b
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.

diff --git a/lib/RT/System.pm b/lib/RT/System.pm
index abb0712..4c9bbfc 100644
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -258,6 +258,65 @@ sub UpgradeHistory {
     return $upgrade_history;
 }
 
+=head2 GroupRTUpgradeHistory
+
+Locate full upgrades and sort and group individual upgrades within them.
+
+Only returns 'after' history entries.
+
+=cut
+
+sub GroupRTUpgradeHistory {
+    my $self = shift;
+    my $rt_history_ref = shift;
+    my @ordered_history;
+
+    return \@ordered_history
+      unless $rt_history_ref and scalar @{$rt_history_ref};
+
+    # Walk through the RT history backward and add keys to flag
+    # full upgrade 'parent' entries and 'children' entries
+    my @rt_upgrades = reverse @{$rt_history_ref};
+
+    # C-style loop because we iterate multiple times within
+  HISTORY: foreach ( my $i = 0; $i < @rt_upgrades; $i++ ) {
+        next unless $rt_upgrades[$i]->{'stage'} eq 'after';
+
+        if ( exists $rt_upgrades[$i]->{'type'}
+             and $rt_upgrades[$i]->{'type'} eq 'full upgrade' ) {
+            $rt_upgrades[$i]->{'full-upgrade-parent'} = $i;
+            my $full_upgrade_index = $i;
+
+            # Loop through versions of the full upgrade.
+            foreach my $version ( reverse @{$rt_upgrades[$i]->{'versions'}} ) {
+                $i++;           # Walk through children upgrade entries
+                next unless $rt_upgrades[$i]->{'stage'} eq 'after';
+
+                # Log should have an individual upgrade for each version.
+                # For now, skip any intermediate insert entries
+                until ( exists $rt_upgrades[$i]->{'to'}
+                        and $version eq $rt_upgrades[$i]->{'to'} ) {
+                    $i++;
+                    # Make sure we don't fall off the end of the loop if an
+                    # expected individual upgrade is missing.
+                    last HISTORY if $i > @rt_upgrades;
+                }
+
+                $rt_upgrades[$i]->{'full-upgrade-child'} = $full_upgrade_index;
+                unshift @ordered_history, $rt_upgrades[$i];
+            }
+
+            # Put the full upgrade entry on the front.
+            unshift @ordered_history, $rt_upgrades[$full_upgrade_index];
+        } else {
+            # Individual upgrade entry independent of a full upgrade.
+            # Tack it on the front.
+            unshift @ordered_history, $rt_upgrades[$i];
+        }
+    }
+    return \@ordered_history;
+}
+
 RT::Base->_ImportOverlays();
 
 1;
diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index 0802938..efd5399 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -268,36 +268,84 @@ 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);
+    $upgrade_history->{'RT'} = RT->System->GroupRTUpgradeHistory($upgrade_history->{'RT'});
+
+    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 => '', };
+    }
 
-% 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&>Versions</&></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 $tr_class = 'oddline';
+        if ( $package eq 'RT' ){
+            if ( exists $upgrade->{'full-upgrade-child'} ) {
+                $tr_class = 'evenline '
+                  . 'upgrade-history-' . $upgrade->{'full-upgrade-child'};
+            }
+        }
+        else {
+            $tr_class = $i++ %2 ? 'oddline' : 'evenline';
+        }
+    if ( exists $upgrade->{'full-upgrade-parent'}){
+        my $parent_id = $upgrade->{'full-upgrade-parent'};
 </%perl>
-<tr class="<% $i++ %2 ? 'oddline' : 'evenline'%>">
-    <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 ( exists $upgrade->{'full-upgrade-child'} ){
+<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} %>
+    <% ucfirst($upgrade->{type}) %>
 % } else {
-    <% $upgrade->{action} %>
+    <% ucfirst($upgrade->{action}) %>
 % }
     </td>
     <td class="collection-as-table">
-        <% $upgrade->{rt_version} %>
-    </td>
-    <td class="collection-as-table">
 %          my $timestamp = RT::Date->new($session{CurrentUser});
 %          $timestamp->Set(Value => $upgrade->{timestamp});
            <% $timestamp->AsString %>
@@ -307,6 +355,9 @@ if ($item =~ /^\s*(.*?)\s*v(\S+);/) {
     <&|/l, $upgrade->{from}, $upgrade->{to} &>from [_1] to [_2]</&>
 % }
     </td>
+    <td class="collection-as-table">
+        <% $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