[Rt-commit] rt branch, 4.6/log-view-db-config-change-history, repushed

Aaron Trevena ast at bestpractical.com
Fri Feb 14 06:08:23 EST 2020


The branch 4.6/log-view-db-config-change-history was deleted and repushed:
       was 46cd2e3a531944f7ab131586dd889c971c51e806
       now 3c79f1346988d7a5be0ce5dac92138469b002302

1: b5ddf186d = 1: b5ddf186d Schema updates for tracking db configuration changes in transactions
2: 230ace51e ! 2: 4f154bd32 Log DB config changes as transactions
    @@ -3,7 +3,6 @@
         Log DB config changes as transactions
         
         Implementation of storing Configuration change history in transactions
    -    Added page to view transaction log or configurations
     
     diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
     --- a/lib/RT/Config.pm
    @@ -141,109 +140,9 @@
              return ($ok, $self->loc('[_1] changed from "[_2]" to "[_3]"', $self->Name, $old_value, $value));
          } else {
     
    -diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
    ---- a/lib/RT/Interface/Web/MenuBuilder.pm
    -+++ b/lib/RT/Interface/Web/MenuBuilder.pm
    -@@
    -         $page->child( edit => raw_html => q[<a id="page-edit" class="menu-item" href="] . RT->Config->Get('WebPath') . qq[/Prefs/MyRT.html"><span class="fas fa-cog" alt="$alt" data-toggle="tooltip" data-placement="top" data-original-title="$alt"></span></a>] );
    -     }
    - 
    --    if ( $request_path =~ m{^/Admin/Tools/(Configuration|EditConfig)} ) {
    --        $page->child( display => title => loc('View'), path => "/Admin/Tools/Configuration.html" );
    --        $page->child( history => title => loc('Edit'), path => "/Admin/Tools/EditConfig.html" );
    -+    if ( $request_path =~ m{^/Admin/Tools/(Configuration|EditConfig|ConfigHistory)} ) {
    -+        $page->child( "display",  title => loc('View'), path => "/Admin/Tools/Configuration.html" );
    -+        $page->child( "modify", title => loc('Edit'), path => "/Admin/Tools/EditConfig.html" );
    -+        $page->child( "history",  title => loc('History'), path => "/Admin/Tools/ConfigHistory.html" );
    -     }
    - 
    -     # due to historical reasons of always having been in /Elements/Tabs
    -
    -diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
    ---- a/lib/RT/Record.pm
    -+++ b/lib/RT/Record.pm
    -@@
    -     return $self->Id unless @classes;
    - 
    -     my $object = $self;
    -+    return $self->Id if (ref($object) eq 'RT::Configuration');
    -     # Save a ->Load call by not calling ->FooObj->Id, just ->Foo
    -     my $final = shift @classes;
    -     foreach my $class (reverse @classes) {
    -
     diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
     --- a/lib/RT/Transaction.pm
     +++ b/lib/RT/Transaction.pm
    -@@
    -         return ( 0, $self->loc( "Transaction->Create couldn't, as you didn't specify an object type and id"));
    -     }
    - 
    --
    --
    -     #lets create our transaction
    -     my %params = (
    -         Type      => $args{'Type'},
    -@@
    -         my $self = shift;
    -         return "Attachment content modified";
    -     },
    -+    SetConfig => sub  {
    -+        my $self = shift;
    -+        my $new_value = $self->NewValue;
    -+        my $old_value = $self->OldValue;
    -+
    -+        # pull in old value from reference if data structure
    -+        if ($old_value =~ m/^(perl|json).value$/) {
    -+            my $oldobj = RT::Configuration->new($self->CurrentUser);
    -+            $oldobj->Load($self->OldReference);
    -+            $old_value = $oldobj->Content;
    -+        }
    -+
    -+        # pull in new value from reference if data structure
    -+        if ($new_value =~ m/^(perl|json).value$/) {
    -+            my $newobj = RT::Configuration->new($self->CurrentUser);
    -+            $newobj->Load($self->NewReference);
    -+            $new_value = $newobj->Content;
    -+        }
    -+
    -+        my $description = sprintf('<b>%s updated %s</b><br/>%s', $self->CreatorObj->Name, $self->Field, "\n");
    -+        $description .= $self->loc('[_1] changed from "[_2]" to "[_3]"', $self->Field, $old_value || '', $new_value || '');
    -+        return $description;
    -+    },
    -+    DeleteConfig => sub  {
    -+        my $self = shift;
    -+        my $description = sprintf('<b>%s deleted %s</b><br/>%s', $self->CreatorObj->Name, $self->Field,"\n");
    -+        my $old_value = $self->OldValue;
    -+        # pull in old value from reference if data structure
    -+        if ($old_value =~ m/^(perl|json).value$/) {
    -+            my $oldobj = RT::Configuration->new($self->CurrentUser);
    -+            $oldobj->Load($self->OldReference);
    -+            $old_value = $oldobj->Content;
    -+        }
    -+
    -+        $description .= $self->loc('[_1] changed from "[_2]" to "[_3]"', $self->Field, $old_value, $self->loc("Deleted"));
    -+        return $description;
    -+    }
    - );
    - 
    - 
    -@@
    - 
    - 
    - sub CustomFieldLookupType {
    --    "RT::Queue-RT::Ticket-RT::Transaction";
    -+    my $self = shift;
    -+
    -+    # skip if it's a table/class with no custom fields
    -+    if (ref($self) && ($self->ObjectType =~ m/RT::(Configuration)/)) {
    -+        return "";
    -+    }
    -+    else {
    -+        return "RT::Queue-RT::Ticket-RT::Transaction";
    -+    }
    - }
    - 
    - 
     @@
              Type =>
                      {read => 1, write => 1, sql_type => 12, length => 20,  is_blob => 0,  is_numeric => 0,  type => 'varchar(20)', default => ''},
    @@ -253,98 +152,6 @@
              OldValue =>
                      {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
              NewValue =>
    -
    -diff --git a/share/html/Admin/Tools/ConfigHistory.html b/share/html/Admin/Tools/ConfigHistory.html
    -new file mode 100644
    ---- /dev/null
    -+++ b/share/html/Admin/Tools/ConfigHistory.html
    -@@
    -+%# BEGIN BPS TAGGED BLOCK {{{
    -+%#
    -+%# COPYRIGHT:
    -+%#
    -+%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
    -+%#                                          <sales at bestpractical.com>
    -+%#
    -+%# (Except where explicitly superseded by other copyright notices)
    -+%#
    -+%#
    -+%# LICENSE:
    -+%#
    -+%# This work is made available to you under the terms of Version 2 of
    -+%# the GNU General Public License. A copy of that license should have
    -+%# been provided with this software, but in any event can be snarfed
    -+%# from www.gnu.org.
    -+%#
    -+%# This work is distributed in the hope that it will be useful, but
    -+%# WITHOUT ANY WARRANTY; without even the implied warranty of
    -+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    -+%# General Public License for more details.
    -+%#
    -+%# You should have received a copy of the GNU General Public License
    -+%# along with this program; if not, write to the Free Software
    -+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    -+%# 02110-1301 or visit their web page on the internet at
    -+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
    -+%#
    -+%#
    -+%# CONTRIBUTION SUBMISSION POLICY:
    -+%#
    -+%# (The following paragraph is not intended to limit the rights granted
    -+%# to you to modify and distribute this software under the terms of
    -+%# the GNU General Public License and is only of importance to you if
    -+%# you choose to contribute your changes and enhancements to the
    -+%# community by submitting them to Best Practical Solutions, LLC.)
    -+%#
    -+%# By intentionally submitting any modifications, corrections or
    -+%# derivatives to this work, or any other work intended for use with
    -+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
    -+%# you are the copyright holder for those contributions and you grant
    -+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
    -+%# royalty-free, perpetual, license to use, copy, create derivative
    -+%# works based on those contributions, and sublicense and distribute
    -+%# those contributions and any derivatives thereof.
    -+%#
    -+%# END BPS TAGGED BLOCK }}}
    -+<%INIT>
    -+my $title = loc('System Configuration');
    -+unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'SuperUser')) {
    -+ Abort(loc('This feature is only available to system administrators'));
    -+}
    -+
    -+# get the transactions?
    -+# start off just getting all of them!
    -+
    -+my $Transactions = RT::Transactions->new($session{CurrentUser});
    -+$Transactions->Limit(FIELD => 'ObjectType', VALUE =>  'RT::Configuration');
    -+$Transactions->OrderBy(FIELD => 'Created', ORDER => 'DESC');
    -+</%INIT>
    -+<& /Admin/Elements/Header, Title => $title &>
    -+<& /Elements/Tabs &>
    -+  <div class="configuration">
    -+    <div class="history configurations" id="configurations">
    -+      <& /Widgets/TitleBoxStart, title => $title, class => 'fullwidth' &>
    -+    </div>
    -+<div class="history-container">
    -+% my $i = 1;
    -+% while (my $tx = $Transactions->Next()) {
    -+<& /Elements/ShowTransaction,
    -+    Transaction => $tx,
    -+    ShowHeaders => 1,
    -+    ShowDisplayModes => 0,
    -+    ShowActions => 1,
    -+    HasTxnCFs => 0,
    -+    RowNum => $i
    -+&>
    -+% $i++;
    -+% }
    -+</div>
    -+  </div>
    -+</div>
    -+<hr class="clear">
    -+</div>
    -+</div>
    -+
     
     diff --git a/share/html/Admin/Tools/EditConfig.html b/share/html/Admin/Tools/EditConfig.html
     --- a/share/html/Admin/Tools/EditConfig.html
-:  ------- > 3: db223c851 Log DB config changes as transactions
3: 46cd2e3a5 ! 4: 3c79f1346 Log DB config changes as transactions
    @@ -1,16 +1,15 @@
     Author: Aaron Trevena <ast at bestpractical.com>
     
    -    Test updates for tracking db configuration changes in transactions
    +    Log DB config changes as transactions
    +    
    +    Added unit tests for storing and viewing Configuration change history in transactions
     
     diff --git a/t/web/admin_tools_editconfig.t b/t/web/admin_tools_editconfig.t
     --- a/t/web/admin_tools_editconfig.t
     +++ b/t/web/admin_tools_editconfig.t
     @@
    - my ( $url, $m ) = RT::Test->started_ok;
      ok( $m->login(), 'logged in' );
      
    -+note('using url ' . $m->rt_base_url());
    -+
      $m->follow_link_ok( { text => 'System Configuration' }, 'followed link to "System Configuration"' );
     +$m->follow_link_ok( { text => 'History' }, 'followed link to History page' );
      $m->follow_link_ok( { text => 'Edit' }, 'followed link to Edit page' );



More information about the rt-commit mailing list