[Rt-commit] rt branch 5.0/make-config-history-more-readable2 created. rt-5.0.3-422-gb0beb66a81
BPS Git Server
git at git.bestpractical.com
Thu Apr 6 20:45:39 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/make-config-history-more-readable2 has been created
at b0beb66a810c6c6e16ea7a8376a6081b2c74d4c8 (commit)
- Log -----------------------------------------------------------------
commit b0beb66a810c6c6e16ea7a8376a6081b2c74d4c8
Author: Brad Embree <brad at bestpractical.com>
Date: Mon Jan 31 11:17:09 2022 -0800
Adjust tests to account for new brief descriptions of SetConfig transactions
diff --git a/t/web/admin_tools_editconfig.t b/t/web/admin_tools_editconfig.t
index 536ce8cdaf..b18389c0f3 100644
--- a/t/web/admin_tools_editconfig.t
+++ b/t/web/admin_tools_editconfig.t
@@ -137,7 +137,7 @@ sub check_history_page_item {
} else {
$m->text_contains($change->{new_value});
}
- $m->text_contains("$change->{setting} changed", 'fetched tx has changed field');
+ $m->text_like(qr/$change->{setting} (?:added|changed)/, 'fetched tx has changed field');
}
sub compactify {
commit 76f4b7db29fd2b9adaa4ef14bb03522c9a0d1d41
Author: Brad Embree <brad at bestpractical.com>
Date: Mon Jan 31 10:26:23 2022 -0800
Handle SetConfig changes in same way as text cfs
For simple boolean/integer/select/string values, there is no need to
show the diff.
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 3f61ae8807..7db4e0b86b 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1417,6 +1417,9 @@ sub _CanonicalizeRoleName {
my $self = shift;
my ($new_value, $old_value);
+ my $meta = $RT::Config::META{$self->Field} || {};
+ my $show_details = ( $meta->{Widget} // '' ) =~ m{/(?:Boolean|Integer|String|Select)$} ? 0 : 1;
+
# pull in new value from reference if exists
if ( $self->NewReference ) {
my $newobj = RT::Configuration->new($self->CurrentUser);
@@ -1429,10 +1432,19 @@ sub _CanonicalizeRoleName {
my $oldobj = RT::Configuration->new($self->CurrentUser);
$oldobj->Load($self->OldReference);
$old_value = $oldobj->Content;
- return ('[_1] changed from "[_2]" to "[_3]"', $self->Field, $old_value // '', $new_value // ''); #loc()
+ if ( !$show_details ) {
+ return ( '[_1] changed from "[_2]" to "[_3]"', $self->Field, $old_value // '', $new_value // '' ); #loc()
+ }
+ }
+
+ if ( !$show_details ) {
+ return ( '[_1] changed to "[_2]"', $self->Field, $new_value // '' ); #loc()
+ }
+ elsif ( !defined($old_value) || ( $old_value eq '' ) ) {
+ return ( "[_1] added", $self->Field ); #loc()
}
else {
- return ('[_1] changed to "[_2]"', $self->Field, $new_value // ''); #loc()
+ return ( "[_1] changed", $self->Field ); #loc()
}
},
DeleteConfig => sub {
diff --git a/share/html/Admin/Tools/ConfigHistory.html b/share/html/Admin/Tools/ConfigHistory.html
index 739fa0abbb..f4eac50a24 100644
--- a/share/html/Admin/Tools/ConfigHistory.html
+++ b/share/html/Admin/Tools/ConfigHistory.html
@@ -77,3 +77,10 @@ $Transactions->OrderBy(FIELD => 'Created', ORDER => 'DESC');
</div>
</&>
</div>
+<script type="text/javascript">
+jQuery(function() {
+ jQuery('.transaction .toggle-txn-details').click(function () {
+ return toggleTransactionDetails.apply(this);
+ });
+});
+</script>
diff --git a/share/html/Elements/ShowTransaction b/share/html/Elements/ShowTransaction
index f2fcfb417d..fca8d50f09 100644
--- a/share/html/Elements/ShowTransaction
+++ b/share/html/Elements/ShowTransaction
@@ -83,7 +83,7 @@ $m->comp(
) if $ShowBody;
</%PERL>
</div>
-% if ($Transaction->Type eq 'CustomField' && $Transaction->Field ) {
+% if ( ( $Transaction->Type eq 'CustomField' && $Transaction->Field ) or ( $Transaction->Type eq 'SetConfig' ) ) {
% my ($old, $new);
% my $cf = RT::CustomField->new( $session{CurrentUser} );
% $cf->SetContextObject( $Transaction->Object );
@@ -94,6 +94,24 @@ $m->comp(
% $old = $old_ref ? $m->scomp($comp, Object => $old_ref) : loc('(no value)');
% my $new_ref = $Transaction->NewReferenceObject;
% $new = $new_ref ? $m->scomp($comp, Object => $new_ref) : loc('(no value)');
+% }
+% elsif ( $show_config_diff ) {
+% # pull in new value from reference if exists
+% if ( my $newobj = $Transaction->NewReferenceObject ) {
+% $new = $newobj->Content;
+% }
+% else {
+% $new = loc('(no value)');
+% }
+% # pull in old value from reference if exists
+% if ( my $oldobj = $Transaction->OldReferenceObject ) {
+% $old = $oldobj->Content // loc('(no value)');
+% }
+% else {
+% $old = loc('(no value)');
+% }
+% }
+% if ( $old || $new ) {
<div class="details hidden" id="txn-<% $Transaction->Id %>-details">
% if ( $old eq loc('(no value)') ) {
<div class="form-row">
@@ -192,6 +210,8 @@ if ( $ShowBody && !$Attachments ) {
}
my $show_cf_diff = 0; # Show/hide colorized diff panel in transaction display
+my $show_config_diff = 0;
+
my @actions = ();
my $txn_type = $Transaction->Type;
if ( $txn_type =~ /EmailRecord$/ ) {
@@ -229,6 +249,13 @@ elsif ($txn_type eq 'CustomField' && $Transaction->Field) {
push @actions, { class => 'toggle-txn-details', title => loc('Show Details'), path => '#' };
}
}
+elsif ($txn_type eq 'SetConfig' && $Transaction->Field) {
+ my $meta = $RT::Config::META{$Transaction->Field} || {};
+ $show_config_diff = ( $meta->{Widget} // '' ) =~ m{/(?:Boolean|Integer|String|Select)$} ? 0 : 1;
+ if ( $show_config_diff ) {
+ push @actions, { class => 'toggle-txn-details', title => loc('Show Details'), path => '#' };
+ }
+}
# If the transaction has anything attached to it at all
elsif ( %$Attachments && $ShowActions ) {
my %has_right = map {
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list