Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bestpractical/rt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsunnavy <sunnavy@bestpractical.com>2022-03-23 00:21:04 +0300
committersunnavy <sunnavy@bestpractical.com>2022-03-23 00:41:11 +0300
commit906a073010901b9fd500b818ae2da2ae2847739e (patch)
treed5a3008f13a9f9f16ba0daf044525a9b488e86de
parent1d7aba58e8dd98c56527940999d5ed609ac8f03d (diff)
Support to canonicalize content for customized DefaultDashboard attributes5.0/initialdata-rtir-default-dashboard-content
Customized DefaultDashboard attributes were added in b5daf2d499(mainly for RTIR), but it missed some bits in RT::Handle. This commit makes sure that exported customized DefaultDashboard attributes in JSON like: { "Content" : { "Description" : "RTIR Homepage", "ObjectId" : "RT System", "ObjectType" : "RT::System" }, "ContentType" : "", "Description" : "RTIR Default Dashboard", "Name" : "RTIRDefaultDashboard", "Object" : "RT::System" } can be imported correctly(i.e. "Content" is converted to the id of dashboard "RTIR HomePage").
-rw-r--r--lib/RT/Handle.pm16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 3f741fa7ff..604a0cf613 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1808,7 +1808,19 @@ sub InsertData {
'Pref-DashboardsInMenu' => 2,
'Subscription' => 2,
);
- for my $item ( sort { ( $order{ $a->{Name} } || 0 ) <=> ( $order{ $b->{Name} } || 0 ) } @Attributes ) {
+
+ my $order = sub {
+ my $name = shift;
+ return $order{$name} if exists $order{$name};
+
+ # Handle customized default dashboards like RTIRDefaultDashboard later than Dashboards.
+ if ( $name =~ /DefaultDashboard$/ ) {
+ return 2;
+ }
+ return 0;
+ };
+
+ for my $item ( sort { $order->( $a->{Name} ) <=> $order->( $b->{Name} ) } @Attributes ) {
if ( $item->{_Original} ) {
$self->_UpdateOrDeleteObject( 'RT::Attribute', $item );
next;
@@ -2838,7 +2850,7 @@ sub _CanonilizeAttributeContent {
}
$item->{Content}{dashboards} = \@dashboards;
}
- elsif ( $item->{Name} =~ /^(?:Pref-)?DefaultDashboard$/ ) {
+ elsif ( $item->{Name} =~ /DefaultDashboard$/ ) {
my $entry = $item->{Content};
if ( $entry->{ObjectType} && $entry->{ObjectId} && $entry->{Description} ) {
if ( my $object = $self->_LoadObject( $entry->{ObjectType}, $entry->{ObjectId} ) ) {