[Rt-commit] rtir branch 5.0/homepage-dashboard updated. 5.0.1-17-g404c278a

BPS Git Server git at git.bestpractical.com
Tue Sep 28 20:16:35 UTC 2021


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 "rtir".

The branch, 5.0/homepage-dashboard has been updated
       via  404c278a59b3e1128ecefec98396d9c54d3fb00c (commit)
       via  3a30d5554eb694c73029da905e473e712d0a6fdb (commit)
       via  e7e0cf22bfe82a4767e8cf8afd5127c39abd89dc (commit)
      from  39090f1768c31881455f469bcb998cabdf796313 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 404c278a59b3e1128ecefec98396d9c54d3fb00c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Sep 29 03:19:09 2021 +0800

    Bump required RT version to 5.0.2 for homepage dashboard

diff --git a/META.yml b/META.yml
index d2649e08..c09388fd 100644
--- a/META.yml
+++ b/META.yml
@@ -35,5 +35,5 @@ resources:
   license: http://opensource.org/licenses/gpl-license.php
 version: 5.0.1
 x_module_install_rtx_version: '0.42'
-x_requires_rt: 5.0.0
+x_requires_rt: 5.0.2
 x_rt_too_new: 5.2.0
diff --git a/Makefile.PL b/Makefile.PL
index 264fdad3..83d26ec1 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -7,7 +7,7 @@ author('Best Practical Solutions <sales at bestpractical.com>');
 all_from('lib/RT/IR.pm');
 
 # update README and docs/UPGRADING
-requires_rt('5.0.0');
+requires_rt('5.0.2');
 rt_too_new('5.2.0',"\nThis version of RTIR is only compatible with RT 5.0.x and you are using RT %s\n");
 
 # XXX: This should be reported by M::I::RTx
diff --git a/README b/README
index 7643a52b..c3b45683 100644
--- a/README
+++ b/README
@@ -14,7 +14,7 @@ touch with us at <sales at bestpractical.com>.
 REQUIRED PACKAGES:
 ------------------
 
-o   RT version 4.4.1 or later.
+o   RT version 5.0.2 or later.
 o   Net::Whois::RIPE 1.31 is bundled with RTIR for compatibility with the
     API RTIR uses and for a fix to run without warnings under perl 5.18.
 

commit 3a30d5554eb694c73029da905e473e712d0a6fdb
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Sep 29 03:15:47 2021 +0800

    Add RT patch to make RTIR homepage dashboard work
    
    The patch will be included in RT 5.0.3, and we can revert this commit by
    then, the corresponding RT branch is 5.0/homepage-dashboard-for-rtir.

diff --git a/README b/README
index d8a48f48..7643a52b 100644
--- a/README
+++ b/README
@@ -32,6 +32,10 @@ Installation instructions:
 1) Install the current release of the RT 5.0 series following RT's
    regular installation instructions
 
+1.1) Patch RT if RT is 5.0.2:
+
+    patch -d /opt/rt5 -p1 < patches/homepage-dashboard.patch
+
 2) Run "perl Makefile.PL" to generate a makefile for RTIR.
 
 3) Install any extra Perl modules RTIR needs that aren't already
diff --git a/patches/homepage-dashboard.patch b/patches/homepage-dashboard.patch
new file mode 100644
index 00000000..c3f8e437
--- /dev/null
+++ b/patches/homepage-dashboard.patch
@@ -0,0 +1,115 @@
+diff --git a/lib/RT/Attribute.pm b/lib/RT/Attribute.pm
+index 43e75d912..05998911f 100644
+--- a/lib/RT/Attribute.pm
++++ b/lib/RT/Attribute.pm
+@@ -418,7 +418,7 @@ sub Delete {
+     # Get values even if current user doesn't have right to see
+     my $name = $self->__Value('Name');
+     my @links;
+-    if ( $name =~ /^(?:Dashboard|(?:Pref-)?DefaultDashboard)$/ ) {
++    if ( $name eq 'Dashboard' || $name =~ /DefaultDashboard$/ ) {
+         push @links, @{ $self->DependsOn->ItemsArrayRef };
+     }
+ 
+@@ -816,7 +816,7 @@ sub FindDependencies {
+         }
+     }
+     # DefaultDashboard has id of dashboard it uses
+-    elsif ($self->Name =~ /^(?:Pref-)?DefaultDashboard$/) {
++    elsif ($self->Name =~ /DefaultDashboard$/) {
+         my $attr = RT::Attribute->new( $self->CurrentUser );
+         $attr->LoadById($self->Content);
+         $deps->Add( out => $attr ) if $attr->Id;
+@@ -911,7 +911,7 @@ sub PostInflateFixup {
+         }
+         $self->SetContent($content);
+     }
+-    elsif ( $self->Name =~ /^(?:Pref-)?DefaultDashboard$/ ) {
++    elsif ( $self->Name =~ /DefaultDashboard$/ ) {
+         my $content = $self->Content;
+         if ( ref($content) eq 'SCALAR' ) {
+             my $attr = $importer->LookupObj($$_);
+@@ -1002,7 +1002,7 @@ sub Serialize {
+         }
+         $store{Content} = $self->_SerializeContent($content);
+     }
+-    elsif ( $store{Name} =~ /^(?:Pref-)?DefaultDashboard$/ ) {
++    elsif ( $store{Name} =~ /DefaultDashboard$/ ) {
+         my $content = $store{Content};
+         my $attr    = RT::Attribute->new( $self->CurrentUser );
+         $attr->LoadById($content);
+@@ -1093,7 +1093,7 @@ sub _SyncLinks {
+             }
+         }
+     }
+-    elsif ( $name =~ /^(?:Pref-)?DefaultDashboard$/ ) {
++    elsif ( $name =~ /DefaultDashboard$/ ) {
+         my $id    = $self->__Value('Content');
+         my $links = $self->DependsOn;
+         my $found;
+diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
+index 0b4533167..bb4ab2011 100644
+--- a/lib/RT/Dashboard.pm
++++ b/lib/RT/Dashboard.pm
+@@ -335,10 +335,10 @@ sub CurrentUserCanDelete {
+ 
+     # Don't allow to delete system default dashboard
+     if ($can) {
+-        my ($system_default) = RT::System->new( RT->SystemUser )->Attributes->Named('DefaultDashboard');
+-        if ( $system_default && $system_default->Content && $system_default->Content == $self->Id ) {
+-            return 0;
+-        }
++        my $attrs = RT::System->new( RT->SystemUser )->Attributes;
++        $attrs->Limit( FIELD => 'Name', OPERATOR => 'ENDSWITH', VALUE => 'DefaultDashboard' );
++        $attrs->Limit( FIELD => 'Content', VALUE => $self->Id );
++        return 0 if $attrs->First;
+     }
+ 
+     return $can;
+diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
+index ce0931f35..9f4dfb453 100644
+--- a/lib/RT/Interface/Web.pm
++++ b/lib/RT/Interface/Web.pm
+@@ -5232,6 +5232,7 @@ sub GetDashboards {
+     my %args = (
+         Objects     => undef,
+         CurrentUser => $session{CurrentUser},
++        DefaultAttribute => 'DefaultDashboard',
+         @_,
+     );
+ 
+@@ -5239,7 +5240,7 @@ sub GetDashboards {
+ 
+     $args{Objects} ||= [ RT::Dashboard->new( $args{CurrentUser} )->ObjectsForLoading( IncludeSuperuserGroups => 1 ) ];
+ 
+-    my ($system_default) = RT::System->new( $args{'CurrentUser'} )->Attributes->Named('DefaultDashboard');
++    my ($system_default) = RT::System->new( $args{'CurrentUser'} )->Attributes->Named( $args{DefaultAttribute} );
+     my $default_dashboard_id = $system_default ? $system_default->Content : 0;
+ 
+     my $found_system_default;
+diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
+index d163ceb9c..99fb6e2fe 100644
+--- a/lib/RT/Migrate/Serializer/JSON.pm
++++ b/lib/RT/Migrate/Serializer/JSON.pm
+@@ -538,7 +538,7 @@ sub CanonicalizeAttributes {
+                 }
+             }
+         }
+-        elsif ( $record->{Name} =~ /^(?:Pref-)?DefaultDashboard$/ ) {
++        elsif ( $record->{Name} =~ /DefaultDashboard$/ ) {
+             if ( ref $record->{Content} eq 'SCALAR' && ${$record->{Content}} =~ /(\d+)$/ ) {
+                 my $id        = $1;
+                 my $attribute = RT::Attribute->new( RT->SystemUser );
+diff --git a/share/html/Elements/SelectDashboard b/share/html/Elements/SelectDashboard
+index 8e89db63f..0388c30a5 100644
+--- a/share/html/Elements/SelectDashboard
++++ b/share/html/Elements/SelectDashboard
+@@ -72,7 +72,7 @@
+ %     if ( $dashboard->{id} == $Default ) {
+         <&|/l&>Current Homepage</&>
+ %     } else {
+-        <input name="DefaultDashboard-<% $dashboard->{id} %>" class="button btn btn-primary form-control" type="submit" value="<&|/l&>Set as Homepage</&>" />
++        <input name="<% $Name %>-<% $dashboard->{id} %>" class="button btn btn-primary form-control" type="submit" value="<&|/l&>Set as Homepage</&>" />
+ %     }
+       </td>
+     </tr>

commit e7e0cf22bfe82a4767e8cf8afd5127c39abd89dc
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Sep 28 22:33:42 2021 +0800

    Remove the possible "/Elements/" prefix for RTIR components in dashboard
    
    The prefix could be wrongly added by RT's etc/upgrade/5.0.2/content if
    "RT at a glance" contains RTIR components.
    
    We can revert this commit once we bump RT version to 5.0.3, by when the
    issue will be fixed in RT.

diff --git a/etc/upgrade/5.0.2/content b/etc/upgrade/5.0.2/content
index 4dc54058..33a3bde9 100644
--- a/etc/upgrade/5.0.2/content
+++ b/etc/upgrade/5.0.2/content
@@ -143,4 +143,35 @@ our @Final = (
             }
         }
     },
+    sub {
+        # This is caused by a bug in RT's etc/upgrade/5.0.2/content, which
+        # will be fixed in RT 5.0.3, and we can drop this part by then.
+
+        RT->Logger->debug("Fixing RTIR component path in dashboards");
+        my $attrs = RT::Attributes->new( RT->SystemUser );
+        $attrs->Limit( FIELD => 'Name', VALUE => 'Dashboard' );
+        while ( my $attr = $attrs->Next ) {
+            my $content = $attr->Content    or next;
+            my $panes   = $content->{Panes} or next;
+            my $attr_id = $attr->Id;
+            my $updated;
+            for my $pane ( sort keys %$panes ) {
+                my $list = $panes->{$pane} or next;
+                for my $entry ( grep { $_->{portlet_type} eq 'component' } @$list ) {
+                    if (   $entry->{component} =~ m{^/RTIR/Elements/}
+                        && $entry->{path} =~ s{^/Elements/(?=/RTIR/Elements/)}{} )
+                    {
+                        $updated ||= 1;
+                    }
+                }
+            }
+
+            if ($updated) {
+                my ( $ret, $msg ) = $attr->SetContent($content);
+                if ( !$ret ) {
+                    RT->Logger->error("Couldn't update Content of attribute #$attr_id: $msg");
+                }
+            }
+        }
+    },
 );

-----------------------------------------------------------------------

Summary of changes:
 META.yml                         |   2 +-
 Makefile.PL                      |   2 +-
 README                           |   6 +-
 etc/upgrade/5.0.2/content        |  31 +++++++++++
 patches/homepage-dashboard.patch | 115 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 153 insertions(+), 3 deletions(-)
 create mode 100644 patches/homepage-dashboard.patch


hooks/post-receive
-- 
rtir


More information about the rt-commit mailing list