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

BPS Git Server git at git.bestpractical.com
Tue Oct 5 12:52:28 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  db08490fd90a150bb87d2661523c1572a91a1e76 (commit)

- Log -----------------------------------------------------------------
commit db08490fd90a150bb87d2661523c1572a91a1e76
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 ca494f76191c3bfed47a4e03a771053269a680da
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 b5b34be33b932098f913176c8ac6e7e755dd45fc
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>

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list