diff options
author | sunnavy <sunnavy@bestpractical.com> | 2022-10-18 22:37:50 +0300 |
---|---|---|
committer | sunnavy <sunnavy@bestpractical.com> | 2022-11-09 00:37:16 +0300 |
commit | 423e4c0698d29fd59d402b2dd453bb0d0f2eeb4f (patch) | |
tree | 53a4bb1d97d946d718188b40207c7efd647524d7 | |
parent | 80c4303d6294f3eaca07d4e6187c957e7bd78819 (diff) |
Import dashboards/savedsearches/subscriptions/prefs and related history5.0/importer-dashboards
There is no reason to skip them.
-rw-r--r-- | lib/RT/Attribute.pm | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/lib/RT/Attribute.pm b/lib/RT/Attribute.pm index 4552dbd52c..cec98c1c5f 100644 --- a/lib/RT/Attribute.pm +++ b/lib/RT/Attribute.pm @@ -863,11 +863,49 @@ sub PreInflate { if ($data->{Object} and ref $data->{Object}) { my $on_uid = ${ $data->{Object} }; + my $force; + # skip attributes of objects we're not inflating - # exception: we don't inflate RT->System, but we want RT->System's searches - unless ($on_uid eq RT->System->UID && $data->{Name} =~ /Search/) { - return if $importer->ShouldSkipTransaction($on_uid); + if ( $on_uid eq RT->System->UID ) { + + # We always want RT->System's searches and dashboards + $force = 1 if $data->{Name} =~ /^Search|^(?:SavedSearch|Dashboard|ContentHistory)$/; + + # Do not import DefaultDashboard if it already exists + if ( $data->{Name} eq 'DefaultDashboard' ) { + if ( my $exists = RT->System->FirstAttribute('DefaultDashboard') ) { + $importer->Resolve( $uid => ref($exists) => $exists->Id ); + return; + } + else { + $force = 1; + } + } } + elsif ( $on_uid =~ /^RT::(?:User|Group)-/ ) { + if ( $importer->ShouldSkipTransaction($on_uid) ) { + if ( $data->{Name} =~ /^Pref-/ ) { + + # Do not import pref settings if they exist + my $obj = $importer->LookupObj($on_uid); + if ( $obj && $obj->Id ) { + if ( my $exists = RT->System->FirstAttribute( $data->{Name} ) ) { + $importer->Resolve( $uid => ref($exists) => $exists->Id ); + } + else { + $force = 1; + } + } + } + elsif ( $data->{Name} =~ /SavedSearch|Dashboard|Subscription|ContentHistory/ ) { + + # We always want saved searches and dashboards + $force = 1; + } + } + } + + return if !$force && $importer->ShouldSkipTransaction($on_uid); } return $class->SUPER::PreInflate( $importer, $uid, $data ); |