[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.0alpha1-247-g34aae6b5e8

? sunnavy sunnavy at bestpractical.com
Wed May 6 10:31:43 EDT 2020


The branch, 5.0-trunk has been updated
       via  34aae6b5e89d8153fc17380ef09c2db553e34cfe (commit)
       via  8eda0dc817a9faec7d24aabbac9c104507a64af7 (commit)
       via  aefd36bfb87dafe5f3e81c809477a088ef9c6b77 (commit)
       via  d65fb8477f4baf95bb899b9bc326e7147faf1df7 (commit)
       via  b8611593caca3a535f213ab824b7006e520e0a3c (commit)
       via  6da5aeb299e1f643970d1bd84ae85f348aebebb1 (commit)
       via  bfff6e6c3bc4c97aa86dc16b567f4fd13161967a (commit)
       via  decfb5af82afbf2b15b42e08b7fcf23a6518a8cf (commit)
       via  f046ab5d512eafcc8a2b49c3a9b985f7a725719e (commit)
       via  64138321a38fa36a36e6c4137c0c5fd88316a009 (commit)
       via  16957ce4c8be4371fdb4008156a21d7fd9935836 (commit)
       via  82136e8b8f86cbef91ca8df88b7bdb7260c2e5ba (commit)
      from  5badda662ddc2bc958153491daa6cb4bb43e3458 (commit)

Summary of changes:
 docs/UPGRADING-5.0                            |  11 ++
 etc/initialdata                               |  21 ++++
 etc/upgrade/4.5.5/content                     |  38 +++++++
 lib/RT/Interface/Web.pm                       |  32 ++++++
 lib/RT/Interface/Web/MenuBuilder.pm           | 154 ++++++++++++++------------
 share/html/Admin/Global/DashboardsInMenu.html |  51 +++++++--
 share/html/Admin/Users/DashboardsInMenu.html  |  97 ++++++++++++----
 share/html/Prefs/DashboardsInMenu.html        |  79 ++++++++++---
 share/html/Reports/index.html                 |   2 +-
 t/web/dashboards-basics.t                     |   2 +-
 t/web/dashboards-groups.t                     |   6 +-
 t/web/dashboards-in-menu.t                    |   2 +-
 t/web/dashboards-permissions.t                |   2 +-
 t/web/dashboards-subscription.t               |   2 +-
 14 files changed, 379 insertions(+), 120 deletions(-)
 create mode 100644 etc/upgrade/4.5.5/content

- Log -----------------------------------------------------------------
commit bfff6e6c3bc4c97aa86dc16b567f4fd13161967a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon May 4 16:15:44 2020 -0400

    Add and remove reports from the Reports menu
    
    Add report processing to the "Update This Menu" functionality
    for the Reports (formerly Home/Dashboards) menu.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 987b4c890b..8bef4fd086 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -4742,6 +4742,38 @@ sub UpdateDashboard {
     }
 }
 
+=head2 ListOfReports
+
+Returns the list of reports registered with RT.
+
+=cut
+
+sub ListOfReports {
+
+    # TODO: Make this a dynamic list generated by loading files in the Reports
+    # directory
+
+    my $list_of_reports = [
+        {
+            id          => 'resolvedbyowner',
+            title       => 'Resolved by owner', # loc
+            path        => '/Reports/ResolvedByOwner.html',
+        },
+        {
+            id          => 'resolvedindaterange',
+            title       => 'Resolved in date range', # loc
+            path        => '/Reports/ResolvedByDates.html',
+        },
+        {
+            id          => 'createdindaterange',
+            title       => 'Created in a date range', # loc
+            path        => '/Reports/CreatedByDates.html',
+        },
+    ];
+
+    return $list_of_reports;
+}
+
 package RT::Interface::Web;
 RT::Base->_ImportOverlays();
 
diff --git a/share/html/Prefs/DashboardsInMenu.html b/share/html/Prefs/DashboardsInMenu.html
index db456df2b9..a725a82d3b 100644
--- a/share/html/Prefs/DashboardsInMenu.html
+++ b/share/html/Prefs/DashboardsInMenu.html
@@ -50,36 +50,58 @@
 &>
 <& /Elements/ListActions, actions => \@results &>
 
-<br />
-
-% for my $pane ( @panes ) {
 <&|/Widgets/TitleBox,
     title => loc('Dashboards in menu'),
     bodyclass => ""
 &>
-<& /Widgets/SelectionBox:show, self => $pane &>
+<& /Widgets/SelectionBox:show, self => $dashboard_pane &>
 </&>
-% }
 
 <&|/Widgets/TitleBox, title => loc("Reset dashboards in menu") &>
-<form method="post" action="DashboardsInMenu.html">
-<input type="hidden" name="Reset" value="1" />
-<input type="submit" class="button form-control btn btn-primary"" value="<% loc('Reset to default') %>">
-</form>
+<div class="mt-3 mb-1 ml-3">
+  <form method="post" action="DashboardsInMenu.html">
+    <input type="submit" name="ResetDashboards" class="button form-control btn btn-primary" value="<% loc('Reset dashboards to default') %>">
+  </form>
+</div>
 </&>
 
+<&|/Widgets/TitleBox,
+    title => loc('Reports in menu'),
+    bodyclass => ""
+&>
+<& /Widgets/SelectionBox:show, self => $report_pane &>
+</&>
+
+<&|/Widgets/TitleBox, title => loc("Reset reports in menu") &>
+<div class="mt-3 mb-1 ml-3">
+  <form method="post" action="DashboardsInMenu.html">
+    <input type="submit" name="ResetReports" class="button form-control btn btn-primary" value="<% loc('Reset reports to default') %>">
+  </form>
+</div>
+</&>
 
 <%INIT>
 my @results;
-my $title = loc("Customize").' '.loc("dashboards in menu");
+my $title = loc("Customize").' '.loc("reports menu");
 my $user = $session{'CurrentUser'}->UserObj;
 
-if ($ARGS{Reset}) {
+if ( $ARGS{ResetDashboards} ) {
+    # Empty DashboardsInMenu pref means to use system default.
     my ($ok, $msg) = $user->SetPreferences('DashboardsInMenu', {});
     push @results, $ok ? loc('Preferences saved.') : $msg;
     delete $session{'dashboards_in_menu'};
 }
 
+if ( $ARGS{ResetReports} ) {
+    if ( $user->Preferences('ReportsInMenu') ) {
+        # Empty ReportsInMenu pref means empty, not to use default,
+        # thus we need to delete preference instead.
+        my ( $ok, $msg ) = $user->DeletePreferences('ReportsInMenu');
+        push @results, $ok ? loc('Preferences saved.') : $msg;
+        delete $session{'reports_in_menu'};
+    }
+}
+
 my ($default_dashboards) =
 RT::System->new($session{'CurrentUser'})->Attributes->Named('DashboardsInMenu');
 
@@ -91,7 +113,7 @@ my $current_dashboards = $dashboard_pref->{dashboards} || [];
 
 my @dashboards = map { [$_->id, $_->Name] } $m->comp("/Dashboards/Elements/ListOfDashboards", IncludeSuperuserGroups => 0 );
 
-my @panes = $m->comp(
+my ($dashboard_pane) = $m->comp(
     '/Admin/Elements/ConfigureDashboardsInMenu',
     Action => 'DashboardsInMenu.html',
     panes => ['dashboards_in_menu'],
@@ -106,8 +128,37 @@ my @panes = $m->comp(
     }
 );
 
-$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
-    for @panes;
+my ( @reports, %reports );
+for my $report ( @{ ListOfReports() } ) {
+    push @reports, [ $report->{id}, $report->{title} ];
+    $reports{ $report->{id} } = $report;
+}
+
+my ($default_reports) = RT::System->new( $session{'CurrentUser'} )->Attributes->Named('ReportsInMenu');
+my $report_pref
+    = $session{CurrentUser}->UserObj->Preferences( 'ReportsInMenu', $default_reports ? $default_reports->Content : () );
+my $current_reports = [ map { $_->{id} } @{ $report_pref || [] } ];
+
+my ($report_pane) = $m->comp(
+    '/Admin/Elements/ConfigureDashboardsInMenu',
+    Action           => 'DashboardsInMenu.html',
+    panes            => ['reports_in_menu'],
+    items            => \@reports,
+    current_portlets => $current_reports,
+    OnSave           => sub {
+        my ($conf) = @_;
+        my $user_reports = [];
+        foreach my $id ( @{ $conf->{dashboards} } ) {
+            push @$user_reports, $reports{$id} if $reports{$id};
+        }
+        my ( $ok, $msg ) = $user->SetPreferences( 'ReportsInMenu', $user_reports );
+        push @results, $msg unless $ok;
+
+        delete $session{'reports_in_menu'};
+    }
+);
+
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ ) for ( $dashboard_pane, $report_pane );
 
 </%INIT>
 

commit 6da5aeb299e1f643970d1bd84ae85f348aebebb1
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon May 4 17:08:19 2020 -0400

    Add reports to global reports menu editor

diff --git a/share/html/Admin/Global/DashboardsInMenu.html b/share/html/Admin/Global/DashboardsInMenu.html
index 21b12077ac..c211f0201a 100644
--- a/share/html/Admin/Global/DashboardsInMenu.html
+++ b/share/html/Admin/Global/DashboardsInMenu.html
@@ -45,16 +45,15 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<& /Admin/Elements/Header, Title => loc("Dashboards in menu") &>
+<& /Admin/Elements/Header, Title => loc("Reports menu") &>
 <& /Elements/Tabs &>
 
 <& /Elements/ListActions, actions => \@actions &>
-<br />
-% for my $pane (@panes) {
 <&|/Widgets/TitleBox, title => loc('Dashboards in menu'), bodyclass => "" &>
-<& /Widgets/SelectionBox:show, self => $pane &></&>
-<br />
-% }
+<& /Widgets/SelectionBox:show, self => $dashboard_pane &></&>
+
+<&|/Widgets/TitleBox, title => loc('Reports in menu'), bodyclass => "" &>
+<& /Widgets/SelectionBox:show, self => $report_pane &></&>
 <%init>
 my @actions;
 my $sys = RT::System->new( $session{'CurrentUser'} );
@@ -76,7 +75,7 @@ while ( my $dashboard = $dashboards->Next ) {
     push @dashboards, [$dashboard->id, $dashboard->Name];
 }
 
-my @panes = $m->comp(
+my ($dashboard_pane) = $m->comp(
     '/Admin/Elements/ConfigureDashboardsInMenu',
     Action => 'DashboardsInMenu.html',
     panes => ['dashboards_in_menu'],
@@ -105,8 +104,42 @@ my @panes = $m->comp(
     }
 );
 
-$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
-    for @panes;
+my ($reports_attr) = RT::System->new( RT->SystemUser )->Attributes->Named('ReportsInMenu');
+
+my ( @reports, %reports );
+for my $report ( @{ ListOfReports() } ) {
+    push @reports, [ $report->{id}, $report->{title} ];
+    $reports{ $report->{id} } = $report;
+}
+
+my ($report_pane) = $m->comp(
+    '/Admin/Elements/ConfigureDashboardsInMenu',
+    Action           => 'DashboardsInMenu.html',
+    panes            => ['reports_in_menu'],
+    ReadOnly         => !$has_right,
+    items            => \@reports,
+    current_portlets => [ map { $_->{id} } @{ $reports_attr->Content || [] } ],
+    OnSave           => sub {
+        my ($conf) = @_;
+        my ( $status, $msg );
+
+        if ( !$has_right ) {
+            push @actions, loc('Permission Denied');
+        }
+        else {
+            my $system_reports = [];
+            foreach my $id ( @{ $conf->{dashboards} } ) {
+                push @$system_reports, $reports{$id} if $reports{$id};
+            }
+
+            ( $status, $msg ) = $reports_attr->SetContent($system_reports);
+            push @actions, $msg unless $status;
+        }
+        push @actions, $status ? loc('Global reports in menu saved.') : $msg;
+    }
+);
+
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ ) for ( $dashboard_pane, $report_pane );
 
 
 </%init>

commit b8611593caca3a535f213ab824b7006e520e0a3c
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon May 4 17:32:39 2020 -0400

    Add reports to user admin menu edit

diff --git a/share/html/Admin/Users/DashboardsInMenu.html b/share/html/Admin/Users/DashboardsInMenu.html
index 35efa9c9c9..9efb079dd1 100644
--- a/share/html/Admin/Users/DashboardsInMenu.html
+++ b/share/html/Admin/Users/DashboardsInMenu.html
@@ -50,33 +50,57 @@
 
 <& /Elements/ListActions, actions => \@actions &>
 
-<form method="post" action="DashboardsInMenu.html">
-<input type="hidden" name="id" value="<% $id %>" />
-<input type="hidden" name="Reset" value="1" />
-<div class="form-row">
-  <div class="col-12">
-    <input type="submit" class="form-control btn btn-primary button" value="<%loc('Reset to default')%>">
-  </div>
+<&|/Widgets/TitleBox,
+    title => loc('Dashboards in menu'),
+    bodyclass => ""
+&>
+<& /Widgets/SelectionBox:show, self => $dashboard_pane &>
+</&>
+
+<&|/Widgets/TitleBox, title => loc("Reset dashboards in menu") &>
+<div class="mt-3 mb-1 ml-3">
+  <form method="post" action="DashboardsInMenu.html">
+    <input type="hidden" name="id" value="<% $id %>" />
+    <input type="submit" name="ResetDashboards" class="button form-control btn btn-primary" value="<% loc('Reset dashboards to default') %>">
+  </form>
 </div>
-</form>
+</&>
 
-<br />
+<&|/Widgets/TitleBox,
+    title => loc('Reports in menu'),
+    bodyclass => ""
+&>
+<& /Widgets/SelectionBox:show, self => $report_pane &>
+</&>
 
-% for my $pane (@panes) {
-<&|/Widgets/TitleBox, title => loc('Dashboards in menu'), bodyclass => "" &>
-<& /Widgets/SelectionBox:show, self => $pane &></&>
-<br />
-% }
+<&|/Widgets/TitleBox, title => loc("Reset reports in menu") &>
+<div class="mt-3 mb-1 ml-3">
+  <form method="post" action="DashboardsInMenu.html">
+    <input type="hidden" name="id" value="<% $id %>" />
+    <input type="submit" name="ResetReports" class="button form-control btn btn-primary" value="<% loc('Reset reports to default') %>">
+  </form>
+</div>
+</&>
 
 <%init>
 my @actions;
 my $UserObj = RT::User->new($session{'CurrentUser'});
 $UserObj->Load($id) || Abort("Couldn't load user '" . ($id || '') . "'");
-my $title = loc("Dashboards in menu for the user [_1]", $UserObj->Name);
+my $title = loc("Reports menu for the user [_1]", $UserObj->Name);
 
-if ($ARGS{Reset}) {
-    my ($ok, $msg) = $UserObj->SetPreferences('DashboardsInMenu', {});
-    push @actions, $ok ? loc('Preferences saved for user [_1].', $UserObj->Name) : $msg;
+if ( $ARGS{ResetDashboards} ) {
+    # Empty DashboardsInMenu pref means to use system default.
+    my ( $ok, $msg ) = $UserObj->SetPreferences( 'DashboardsInMenu', {} );
+    push @actions, $ok ? loc( 'Preferences saved for user [_1].', $UserObj->Name ) : $msg;
+}
+
+if ( $ARGS{ResetReports} ) {
+    if ( $UserObj->Preferences('ReportsInMenu') ) {
+        # Empty ReportsInMenu pref means empty, not to use default,
+        # thus we need to delete preference instead.
+        my ( $ok, $msg ) = $UserObj->DeletePreferences('ReportsInMenu');
+        push @actions, $ok ? loc( 'Preferences saved for user [_1].', $UserObj->Name ) : $msg;
+    }
 }
 
 my ($default_dashboards) =
@@ -97,7 +121,7 @@ my $current_portlets =
   ? $current_pref->{dashboards}
   : [];
 
-my @panes = $m->comp(
+my ($dashboard_pane) = $m->comp(
     '/Admin/Elements/ConfigureDashboardsInMenu',
     Action           => "DashboardsInMenu.html?id=$id",
     panes            => ['dashboards_in_menu'],
@@ -112,9 +136,40 @@ my @panes = $m->comp(
     }
 );
 
+my ( @reports, %reports );
+for my $report ( @{ ListOfReports() } ) {
+    push @reports, [ $report->{id}, $report->{title} ];
+    $reports{ $report->{id} } = $report;
+}
+
+my ($default_reports) = RT::System->new( $session{'CurrentUser'} )->Attributes->Named('ReportsInMenu');
+my $report_pref = $UserObj->Preferences( 'ReportsInMenu', $default_reports ? $default_reports->Content : () );
+my $current_reports = [ map { $_->{id} } @{ $report_pref || [] } ];
+
+my ($report_pane) = $m->comp(
+    '/Admin/Elements/ConfigureDashboardsInMenu',
+    Action           => "DashboardsInMenu.html?id=$id",
+    panes            => ['reports_in_menu'],
+    items            => \@reports,
+    current_portlets => $current_reports,
+    OnSave           => sub {
+        my ($conf) = @_;
+        my $user_reports = [];
+        foreach my $id ( @{ $conf->{dashboards} } ) {
+            push @$user_reports, $reports{$id} if $reports{$id};
+        }
+
+        my ( $ok, $msg ) = $UserObj->SetPreferences( 'ReportsInMenu', $user_reports );
+        if ($ok) {
+            push @actions, loc('Preferences saved for dashboards in menu.');
+        }
+        else {
+            push @actions, $msg;
+        }
+    }
+);
 
-$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
-    for @panes;
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ ) for ( $dashboard_pane, $report_pane );
 
 </%init>
 <%ARGS>

commit d65fb8477f4baf95bb899b9bc326e7147faf1df7
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon May 4 17:15:07 2020 -0400

    Update label to reflect new Reports menu location

diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index a758739674..e7afd9c2f8 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -299,7 +299,7 @@ sub BuildMainNav {
         $settings->child( search_options => title => loc('Search options'), path => '/Prefs/SearchOptions.html' );
         $settings->child( myrt           => title => loc('RT at a glance'), path => '/Prefs/MyRT.html' );
         $settings->child( dashboards_in_menu =>
-            title => loc('Dashboards in menu'),
+            title => loc('Modify Reports menu'),
             path  => '/Prefs/DashboardsInMenu.html',
         );
         $settings->child( queue_list    => title => loc('Queue list'),   path => '/Prefs/QueueList.html' );
@@ -1147,7 +1147,7 @@ sub _BuildAdminMenu {
         path        => '/Admin/Global/MyRT.html',
     );
     $admin_global->child( 'dashboards-in-menu' =>
-        title       => loc('Dashboards in menu'),
+        title       => loc('Modify Reports menu'),
         description => loc('Customize dashboards in menu'),
         path        => '/Admin/Global/DashboardsInMenu.html',
     );
@@ -1270,7 +1270,7 @@ sub _BuildAdminMenu {
                 $page->child( history     => title => loc('History'),        path => "/Admin/Users/History.html?id=" . $id );
                 $page->child( 'my-rt'     => title => loc('RT at a glance'), path => "/Admin/Users/MyRT.html?id=" . $id );
                 $page->child( 'dashboards-in-menu' =>
-                    title => loc('Dashboards in menu'),
+                    title => loc('Modify Reports menu'),
                     path  => '/Admin/Users/DashboardsInMenu.html?id=' . $id,
                 );
                 if ( RT->Config->Get('Crypt')->{'Enable'} ) {

commit aefd36bfb87dafe5f3e81c809477a088ef9c6b77
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 6 04:56:56 2020 +0800

    Update dashboard pref tests as we updated reset input name

diff --git a/t/web/dashboards-in-menu.t b/t/web/dashboards-in-menu.t
index 3915bb2367..ea7d3b1dba 100644
--- a/t/web/dashboards-in-menu.t
+++ b/t/web/dashboards-in-menu.t
@@ -84,7 +84,7 @@ $m->click_button(name => 'Delete');
 
 diag "Reset dashboard menu";
 $m->get_ok( $baseurl."/Prefs/DashboardsInMenu.html");
-$m->form_with_fields('Reset');
+$m->form_with_fields('ResetDashboards');
 $m->click;
 $m->content_contains( 'Preferences saved', 'prefs saved' );
 ok( $m->find_link( text => 'system foo' ), 'got system foo link' );

commit 8eda0dc817a9faec7d24aabbac9c104507a64af7
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Wed May 6 09:28:57 2020 -0400

    Note reports change in upgrading doc

diff --git a/docs/UPGRADING-5.0 b/docs/UPGRADING-5.0
index 54c15e23ed..ebe2958dd5 100644
--- a/docs/UPGRADING-5.0
+++ b/docs/UPGRADING-5.0
@@ -111,6 +111,17 @@ need the extension installed. The C<%PriorityAsString>> configuration is
 simplified and consolidated, so check the documentation for details on
 updating your previous configuration.
 
+=item *
+
+Dashboards previously in the Home menu have been moved to the Reports menu.
+The reports previously in the Reports menu are still there, but you can now
+edit the Reports menu like the previous Home menu, so you can remove the
+default reports if you like.
+
+All other dashboard menu functionality should be the same including editing
+your own menu, the global settings, and setting a user's menu from the user
+admin page for that user.
+
 =back
 
 =cut

commit 34aae6b5e89d8153fc17380ef09c2db553e34cfe
Merge: 5badda662d 8eda0dc817
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 6 22:22:18 2020 +0800

    Merge branch '5.0/dashboards-to-report-menu-2' into 5.0-trunk


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


More information about the rt-commit mailing list