[Rt-commit] rt branch 5.0/initialdata-rtir-default-dashboard-content created. rt-5.0.2-113-g906a073010
BPS Git Server
git at git.bestpractical.com
Tue Mar 22 21:41:35 UTC 2022
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/initialdata-rtir-default-dashboard-content has been created
at 906a073010901b9fd500b818ae2da2ae2847739e (commit)
- Log -----------------------------------------------------------------
commit 906a073010901b9fd500b818ae2da2ae2847739e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Mar 23 05:21:04 2022 +0800
Support to canonicalize content for customized DefaultDashboard attributes
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").
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} ) ) {
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list