[Rt-commit] rt branch 5.0/homepage-dashboard-for-rtir created. rt-5.0.2-21-g0b40fef02b

BPS Git Server git at git.bestpractical.com
Tue Sep 28 19:41:47 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 "rt".

The branch, 5.0/homepage-dashboard-for-rtir has been created
        at  0b40fef02be8d38a3adbc7aef345f5aee99a2e7b (commit)

- Log -----------------------------------------------------------------
commit 0b40fef02be8d38a3adbc7aef345f5aee99a2e7b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 25 05:12:58 2021 +0800

    Use a loose regex to cover all DefaultDashboard attributes
    
    All DefaultDashboard attributes contain dashboard ids, and we keep track
    of the relationship between them, prevent system default dashboards from
    being deleted, etc.
    
    This commit is enhance the feature to support customized
    DefaultDashboard attributes too like the one in RTIR(attribute name is
    "RTIRDefaultDashboard").

diff --git a/lib/RT/Attribute.pm b/lib/RT/Attribute.pm
index 43e75d9123..05998911f8 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 0b45331674..bb4ab20113 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/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index d163ceb9cf..99fb6e2fe4 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 );

commit de5ff2fa40126af4162d2db589267d9672aec05b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 25 05:10:18 2021 +0800

    Support to specify attribute name of system default dashboard
    
    This is mainly for RTIR, where system default dashboard is saved in
    attribute "RTIRDefaultDashboard".

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index ce0931f35a..9f4dfb453a 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;

commit 86f22343aeab622c9bad3065c5fa68befa2733a5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 25 05:07:30 2021 +0800

    Respect $Name argument in SelectDashboard
    
    Previously we didn't actually make use of $Name argument. With this
    change, we can customize input name via $Name.

diff --git a/share/html/Elements/SelectDashboard b/share/html/Elements/SelectDashboard
index 8e89db63f4..0388c30a59 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 74eafebe38403ce1cfdfa9d25b725ec0eb4a2b0b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 25 05:04:42 2021 +0800

    In case homepage has components living outside of /Elements
    
    This is initially to make RTIR components happy, which live in
    "/RTIR/Elements".

diff --git a/etc/upgrade/5.0.2/content b/etc/upgrade/5.0.2/content
index 9ad5ed4a18..4f2b36a095 100644
--- a/etc/upgrade/5.0.2/content
+++ b/etc/upgrade/5.0.2/content
@@ -169,7 +169,7 @@ our @Final = (
                             $new_entry->{portlet_type} = 'component';
                             $new_entry->{component}    = $entry->{name};
                             $new_entry->{description}  = $entry->{name};
-                            $new_entry->{path}         = "/Elements/$entry->{name}";
+                            $new_entry->{path} = $entry->{name} =~ m{^/} ? $entry->{name} : "/Elements/$entry->{name}";
                         }
                         else {
                             RT->Logger->warning("Unsupported type $entry->{type} in attribute #$attr_id, skipping");

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list