[Rt-commit] rt branch 5.0/dynamic-reports created. rt-5.0.4-7-gdde959b87f

BPS Git Server git at git.bestpractical.com
Fri May 12 19:45:02 UTC 2023


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/dynamic-reports has been created
        at  dde959b87ffb201bb616b2e7b997d7806da1f015 (commit)

- Log -----------------------------------------------------------------
commit dde959b87ffb201bb616b2e7b997d7806da1f015
Author: Ruslan Zakirov <ruslan.zakirov at gmail.com>
Date:   Fri May 12 22:43:47 2023 +0300

    RT#256668: a stab at customizable list of Reports

diff --git a/.gitignore b/.gitignore
index 5ad579ba53..c26b4cc109 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,6 +61,7 @@
 /config.pld
 /nytprof.out*
 /.prove
+/.vscode
 *~
 *.swp
 *.swo
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 444eb1c24e..f8a615242f 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -5032,35 +5032,63 @@ Returns the list of reports registered with RT.
 
 =cut
 
+our $reports_registry = {
+    resolvedbyowner => {
+        id          => 'resolvedbyowner',
+        title       => 'Resolved by owner', # loc
+        path        => '/Reports/ResolvedByOwner.html',
+    },
+    resolvedindaterange => {
+        id          => 'resolvedindaterange',
+        title       => 'Resolved in date range', # loc
+        path        => '/Reports/ResolvedByDates.html',
+    },
+    createdindaterange => {
+        id          => 'createdindaterange',
+        title       => 'Created in a date range', # loc
+        path        => '/Reports/CreatedByDates.html',
+    },
+    user_time => {
+        id          => 'user_time',
+        title       => 'User time worked',
+        path        => '/Reports/TimeWorkedReport.html',
+    },
+};
+
 sub ListOfReports {
+    my @res = sort { lc($a->{title}) cmp lc($b->{title}) } values %$reports_registry;
+    return \@res;
+}
 
-    # TODO: Make this a dynamic list generated by loading files in the Reports
-    # directory
+=head2 RegisterReport
 
-    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',
-        },
-        {
-            id          => 'user_time',
-            title       => 'User time worked',
-            path        => '/Reports/TimeWorkedReport.html',
-        },
-    ];
+Registers a report that can be added to the Reports menu.
+
+    use RT::Interface::Web;
+    RT::Interface::Web->RegisterReport(
+        id    => 'my_super_report',
+        title => 'Super report',
+        path  => 'MySuperReport.html',
+    );
 
-    return $list_of_reports;
+All reports are expected to be in the /Reports/ directory.
+
+=cut
+
+sub RegisterReport {
+    my $self = shift;
+    my %args = (
+        id    => undef,
+        title => undef,
+        path  => undef,
+        @_
+    );
+
+    $reports_registry->{id} = {
+        id    => $args{id},
+        title => $args{title},
+        path  => '/Reports/'. $args{path},
+    };
 }
 
 =head2 ProcessCustomDateRanges ARGSRef => ARGSREF, UserPreference => 0|1

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list