[Rt-commit] rt branch, 5.0/dashboards-to-report-menu, created. rt-5.0.0alpha1-92-ge711077ee4

Michel Rodriguez michel at bestpractical.com
Thu Apr 16 08:44:06 EDT 2020


The branch, 5.0/dashboards-to-report-menu has been created
        at  e711077ee4e1addc9d146fa508da6233d087b9aa (commit)

- Log -----------------------------------------------------------------
commit 26bc02f337aba8f3e40ab275bd7d5e48e0a20392
Author: michel <michel at bestpractical.com>
Date:   Wed Apr 15 15:16:57 2020 +0200

    Moved initial dashboards to the Reports menu.

diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index a45a5dea68..af6e809c3a 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -92,6 +92,49 @@ sub BuildMainNav {
     }
 
     my $home = $top->child( home => title => loc('Homepage'), path => '/' );
+
+    my $search = $top->child( search => title => loc('Search'), path => '/Search/Simple.html' );
+
+    my $tickets = $search->child( tickets => title => loc('Tickets'), path => '/Search/Build.html' );
+    $tickets->child( simple => title => loc('Simple Search'), path => "/Search/Simple.html" );
+    $tickets->child( new    => title => loc('New Search'),    path => "/Search/Build.html?NewQuery=1" );
+
+    my $recents = $tickets->child( recent => title => loc('Recently Viewed'));
+    for my $ticket ( $current_user->RecentlyViewedTickets ) {
+        my $title = $ticket->{subject} || loc( "(No subject)" );
+        if ( length $title > 50 ) {
+            $title = substr($title, 0, 47);
+            $title =~ s/\s+$//;
+            $title .= "...";
+        }
+        $title = "#$ticket->{id}: " . $title;
+        $recents->child( "$ticket->{id}" => title => $title, path => "/Ticket/Display.html?id=" . $ticket->{id} );
+    }
+
+    $search->child( articles => title => loc('Articles'),   path => "/Articles/Article/Search.html" )
+        if $current_user->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
+
+    $search->child( users => title => loc('Users'),   path => "/User/Search.html" );
+
+    $search->child( groups      =>
+                    title       => loc('Groups'),
+                    path        => "/Group/Search.html",
+                    description => 'Group search'
+    );
+
+    $search->child( assets => title => loc("Assets"), path => "/Asset/Search/" )
+        if $current_user->HasRight( Right => 'ShowAssetsMenu', Object => RT->System );
+
+    my $txns = $search->child( transactions => title => loc('Transactions'), path => '/Search/Build.html?Class=RT::Transactions&ObjectType=RT::Ticket' );
+    my $txns_tickets = $txns->child( tickets => title => loc('Tickets'), path => "/Search/Build.html?Class=RT::Transactions&ObjectType=RT::Ticket" );
+    $txns_tickets->child( new => title => loc('New Search'), path => "/Search/Build.html?Class=RT::Transactions&ObjectType=RT::Ticket&NewQuery=1" );
+
+    my $reports = $top->child( reports =>
+        title       => loc('Reports'),
+        description => loc('Reports summarizing ticket resolution and status'),
+        path        => loc('/Reports'),
+    );
+
     unless ($HTML::Mason::Commands::session{'dashboards_in_menu'}) {
         my $dashboards_in_menu = $current_user->UserObj->Preferences(
             'DashboardsInMenu',
@@ -128,63 +171,15 @@ sub BuildMainNav {
         }
     }
 
-    my $dashes = $top->child('home');
     if (@dashboards) {
         for my $dash (@dashboards) {
-            $home->child( 'dashboard-' . $dash->id,
+            $reports->child( 'dashboard-' . $dash->id,
                 title => $dash->Name,
                 path  => '/Dashboards/' . $dash->id . '/' . $dash->Name
             );
         }
     }
-    $dashes->child( edit => title => loc('Update This Menu'), path => 'Prefs/DashboardsInMenu.html' );
-    $dashes->child( more => title => loc('All Dashboards'),   path => 'Dashboards/index.html' );
-    my $dashboard = RT::Dashboard->new( $current_user );
-    if ( $dashboard->CurrentUserCanCreateAny ) {
-        $dashes->child('dashboard_create' => title => loc('New Dashboard'), path => "/Dashboards/Modify.html?Create=1" );
-    }
-
-    my $search = $top->child( search => title => loc('Search'), path => '/Search/Simple.html' );
-
-    my $tickets = $search->child( tickets => title => loc('Tickets'), path => '/Search/Build.html' );
-    $tickets->child( simple => title => loc('Simple Search'), path => "/Search/Simple.html" );
-    $tickets->child( new    => title => loc('New Search'),    path => "/Search/Build.html?NewQuery=1" );
-
-    my $recents = $tickets->child( recent => title => loc('Recently Viewed'));
-    for my $ticket ( $current_user->RecentlyViewedTickets ) {
-        my $title = $ticket->{subject} || loc( "(No subject)" );
-        if ( length $title > 50 ) {
-            $title = substr($title, 0, 47);
-            $title =~ s/\s+$//;
-            $title .= "...";
-        }
-        $title = "#$ticket->{id}: " . $title;
-        $recents->child( "$ticket->{id}" => title => $title, path => "/Ticket/Display.html?id=" . $ticket->{id} );
-    }
-
-    $search->child( articles => title => loc('Articles'),   path => "/Articles/Article/Search.html" )
-        if $current_user->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
-
-    $search->child( users => title => loc('Users'),   path => "/User/Search.html" );
 
-    $search->child( groups      =>
-                    title       => loc('Groups'),
-                    path        => "/Group/Search.html",
-                    description => 'Group search'
-    );
-
-    $search->child( assets => title => loc("Assets"), path => "/Asset/Search/" )
-        if $current_user->HasRight( Right => 'ShowAssetsMenu', Object => RT->System );
-
-    my $txns = $search->child( transactions => title => loc('Transactions'), path => '/Search/Build.html?Class=RT::Transactions&ObjectType=RT::Ticket' );
-    my $txns_tickets = $txns->child( tickets => title => loc('Tickets'), path => "/Search/Build.html?Class=RT::Transactions&ObjectType=RT::Ticket" );
-    $txns_tickets->child( new => title => loc('New Search'), path => "/Search/Build.html?Class=RT::Transactions&ObjectType=RT::Ticket&NewQuery=1" );
-
-    my $reports = $top->child( reports =>
-        title       => loc('Reports'),
-        description => loc('Reports summarizing ticket resolution and status'),
-        path        => loc('/Reports'),
-    );
     $reports->child( resolvedbyowner =>
         title       => loc('Resolved by owner'),
         path        => '/Reports/ResolvedByOwner.html',
@@ -201,6 +196,14 @@ sub BuildMainNav {
         description => loc('Examine tickets created in a queue between two dates'),
     );
 
+    $reports->child( edit => title => loc('Update This Menu'), path => '/Prefs/DashboardsInMenu.html' );
+    $reports->child( more => title => loc('All Dashboards'),   path => '/Dashboards/index.html' );
+    my $dashboard = RT::Dashboard->new( $current_user );
+    if ( $dashboard->CurrentUserCanCreateAny ) {
+        $reports->child('dashboard_create' => title => loc('New Dashboard'), path => "/Dashboards/Modify.html?Create=1" );
+    }
+
+
     if ($current_user->HasRight( Right => 'ShowArticlesMenu', Object => RT->System )) {
         my $articles = $top->child( articles => title => loc('Articles'), path => "/Articles/index.html");
         $articles->child( articles => title => loc('Overview'), path => "/Articles/index.html" );

commit e711077ee4e1addc9d146fa508da6233d087b9aa
Author: michel <michel at bestpractical.com>
Date:   Thu Apr 16 13:21:19 2020 +0200

    Get the list of reports in the reports in the Reports menu from pref/attribute.
    
    The initial list is created from initial_data, in the ReportsInMenu attribute.
    It can be modified in the Pref-ReportsInMenu user preference,
    similar to dashboards.

diff --git a/etc/initialdata b/etc/initialdata
index 74951a5b85..527cc638fe 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -923,6 +923,30 @@ Hour:         { $SubscriptionObj->SubValue('Hour') }
               ],
         },
     },
+# initial reports
+    { Name => 'ReportsInMenu',
+      Description => 'Content of the Reports menu', #loc
+      Content     => [
+          {
+              id          => 'resolvedbyowner',
+              title       => 'Resolved by owner', # loc
+              path        => '/Reports/ResolvedByOwner.html',
+              description => 'Examine tickets resolved in a queue, grouped by owner', #loc
+          },
+          {
+              id          => 'resolvedindaterange',
+              title       => 'Resolved in date range', # loc
+              path        => '/Reports/ResolvedByDates.html',
+              description => 'Examine tickets resolved in a queue between two dates', # loc
+          },
+          {
+              id          => 'createdindaterange',
+              title       => 'Created in a date range', # loc
+              path        => '/Reports/CreatedByDates.html',
+              description => 'Examine tickets created in a queue between two dates', # loc
+          },
+      ],
+    },
 );
 
 @Classes = (
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index af6e809c3a..9e05f00f18 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -171,6 +171,7 @@ sub BuildMainNav {
         }
     }
 
+
     if (@dashboards) {
         for my $dash (@dashboards) {
             $reports->child( 'dashboard-' . $dash->id,
@@ -180,21 +181,36 @@ sub BuildMainNav {
         }
     }
 
-    $reports->child( resolvedbyowner =>
-        title       => loc('Resolved by owner'),
-        path        => '/Reports/ResolvedByOwner.html',
-        description => loc('Examine tickets resolved in a queue, grouped by owner'),
-    );
-    $reports->child( resolvedindaterange =>
-        title       => loc('Resolved in date range'),
-        path        => '/Reports/ResolvedByDates.html',
-        description => loc('Examine tickets resolved in a queue between two dates'),
-    );
-    $reports->child( createdindaterange =>
-        title       => loc('Created in a date range'),
-        path        => '/Reports/CreatedByDates.html',
-        description => loc('Examine tickets created in a queue between two dates'),
-    );
+    # get the list of reports in the Reports menu
+    unless ($HTML::Mason::Commands::session{'reports_in_menu'} && @{$HTML::Mason::Commands::session{'reports_in_menu'}}) {
+        my $reports_in_menu = $current_user->UserObj->Preferences(
+            'ReportsInMenu',
+            {},
+        );
+
+        unless ($reports_in_menu->{reports}) {
+            my ($default_reports) =
+                RT::System->new( $current_user )
+                    ->Attributes
+                    ->Named('ReportsInMenu');
+            if ($default_reports) {
+                $reports_in_menu = $default_reports->Content;
+            }
+            else {
+                $reports_in_menu = $default_reports->Content;
+            }
+        }
+
+        $HTML::Mason::Commands::session{'reports_in_menu'} = $reports_in_menu || [];
+    }
+
+    for my $report ( @{$HTML::Mason::Commands::session{'reports_in_menu'}} ) {
+        $reports->child(  $report->{id} =>
+            title       => $report->{title}, # loc
+            path        => $report->{path},
+            description => $report->{description}, # loc
+        );
+    }
 
     $reports->child( edit => title => loc('Update This Menu'), path => '/Prefs/DashboardsInMenu.html' );
     $reports->child( more => title => loc('All Dashboards'),   path => '/Dashboards/index.html' );

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


More information about the rt-commit mailing list