[Rt-commit] rt branch 5.0/homepage-dashboard-for-rtir created. rt-5.0.2beta1-6-gf31ead064b
BPS Git Server
git at git.bestpractical.com
Tue Aug 24 22:44:12 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 f31ead064be443c000c52a95ffccf1986ed4cec1 (commit)
- Log -----------------------------------------------------------------
commit f31ead064be443c000c52a95ffccf1986ed4cec1
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 61bbadd4d7..2b92c11ab2 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;
@@ -910,7 +910,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($$_);
@@ -1001,7 +1001,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);
@@ -1092,7 +1092,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 5a58b25a7da77822b1cfe05160125c0e527e0db2
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 859ceacd40..bcc8ecfc70 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -5222,6 +5222,7 @@ sub GetDashboards {
my %args = (
Objects => undef,
CurrentUser => $session{CurrentUser},
+ DefaultAttribute => 'DefaultDashboard',
@_,
);
@@ -5229,7 +5230,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 9bf1bf2ec53401c42d5ca672a19406a03c68fc59
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 95fce1f91682933e4143b2f92b898d488efc7c55
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