UX: new site setting to define activity metrics displayed on dashboard

UX: new site setting to define activity metrics displayed on dashboard

diff --git a/app/assets/javascripts/admin/controllers/admin-dashboard-next-general.js.es6 b/app/assets/javascripts/admin/controllers/admin-dashboard-next-general.js.es6
index 9690778..3452817 100644
--- a/app/assets/javascripts/admin/controllers/admin-dashboard-next-general.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-dashboard-next-general.js.es6
@@ -19,16 +19,9 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
   logSearchQueriesEnabled: setting("log_search_queries"),
   basePath: Discourse.BaseUri,
 
-  @computed
-  activityMetrics() {
-    return [
-      "page_view_total_reqs",
-      "visits",
-      "time_to_first_response",
-      "likes",
-      "flags",
-      "user_to_user_private_messages_with_replies"
-    ];
+  @computed("siteSettings.dashboard_general_tab_activity_metrics")
+  activityMetrics(metrics) {
+    return (metrics || "").split("|").filter(m => m);
   },
 
   @computed
diff --git a/app/assets/javascripts/admin/templates/components/admin-report.hbs b/app/assets/javascripts/admin/templates/components/admin-report.hbs
index a7e7648..69ec7a3 100644
--- a/app/assets/javascripts/admin/templates/components/admin-report.hbs
+++ b/app/assets/javascripts/admin/templates/components/admin-report.hbs
@@ -112,17 +112,15 @@
     {{#if showFilteringUI}}
       <div class="filters">
         {{#if showModes}}
-          <ul class="modes">
+          <div class="modes">
             {{#each displayedModes as |displayedMode|}}
-              <li class="mode">
-                {{d-button
-                  action="changeMode"
-                  actionParam=displayedMode.mode
-                  class=displayedMode.cssClass
-                  icon=displayedMode.icon}}
-              </li>
+              {{d-button
+                action="changeMode"
+                actionParam=displayedMode.mode
+                class=displayedMode.cssClass
+                icon=displayedMode.icon}}
             {{/each}}
-          </ul>
+          </div>
         {{/if}}
 
         {{#if showDatesOptions}}
diff --git a/app/assets/javascripts/admin/templates/dashboard_next_general.hbs b/app/assets/javascripts/admin/templates/dashboard_next_general.hbs
index 78970f7..a9bfd44 100644
--- a/app/assets/javascripts/admin/templates/dashboard_next_general.hbs
+++ b/app/assets/javascripts/admin/templates/dashboard_next_general.hbs
@@ -56,36 +56,38 @@
 
   <div class="section-columns">
     <div class="section-column">
-      <div class="admin-report activity-metrics">
-        <div class="header">
-          <ul class="breadcrumb">
-            <li class="item report">
-              {{#link-to "adminReports" class="report-url"}}
-                {{i18n "admin.dashboard.activity_metrics"}}
-              {{/link-to}}
-            </li>
-          </ul>
-        </div>
-        <div class="report-body">
-          <div class="counters-list">
-            <div class="counters-header">
-              <div class="counters-cell"></div>
-              <div class="counters-cell">{{i18n 'admin.dashboard.reports.today'}}</div>
-              <div class="counters-cell">{{i18n 'admin.dashboard.reports.yesterday'}}</div>
-              <div class="counters-cell">{{i18n 'admin.dashboard.reports.last_7_days'}}</div>
-              <div class="counters-cell">{{i18n 'admin.dashboard.reports.last_30_days'}}</div>
+      {{#if activityMetrics.length}}
+        <div class="admin-report activity-metrics">
+          <div class="header">
+            <ul class="breadcrumb">
+              <li class="item report">
+                {{#link-to "adminReports" class="report-url"}}
+                  {{i18n "admin.dashboard.activity_metrics"}}
+                {{/link-to}}
+              </li>
+            </ul>
+          </div>
+          <div class="report-body">
+            <div class="counters-list">
+              <div class="counters-header">
+                <div class="counters-cell"></div>
+                <div class="counters-cell">{{i18n 'admin.dashboard.reports.today'}}</div>
+                <div class="counters-cell">{{i18n 'admin.dashboard.reports.yesterday'}}</div>
+                <div class="counters-cell">{{i18n 'admin.dashboard.reports.last_7_days'}}</div>
+                <div class="counters-cell">{{i18n 'admin.dashboard.reports.last_30_days'}}</div>
+              </div>
+
+              {{#each activityMetrics as |metric|}}
+                {{admin-report
+                  showHeader=false
+                  filters=activityMetricsFilters
+                  forcedModes="counters"
+                  dataSourceName=metric}}
+              {{/each}}
             </div>
-
-            {{#each activityMetrics as |metric|}}
-              {{admin-report
-                showHeader=false
-                filters=activityMetricsFilters
-                forcedModes="counters"
-                dataSourceName=metric}}
-            {{/each}}
           </div>
         </div>
-      </div>
+      {{/if}}
 
       <div class="user-metrics">
         {{#conditional-loading-section isLoading=isLoading}}
diff --git a/app/models/report.rb b/app/models/report.rb
index bf7da8e..d552a60 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -246,6 +246,8 @@ class Report
   def self.report_signups(report)
     report.group_filtering = true
 
+    report.icon = 'user-plus'
+
     if report.group_id
       basic_report_about report, User.real, :count_by_signup_date, report.start_date, report.end_date, report.group_id
       add_counts report, User.real, 'users.created_at'
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 423b032..4a2e0e0 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -3993,6 +3993,7 @@ en:
           tags: "Tags"
           search: "Search"
           groups: "Groups"
+          dashboard: "Dashboard"
         secret_list:
           invalid_input: "Input fields cannot be empty or contain vertical bar character."
 
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 74b319d..d0fc02e 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1903,6 +1903,8 @@ en:
 
     short_title: "The short title will be used on the user's home screen, launcher, or other places where space may be limited. A maximum of 12 characters is recommended."
 
+    dashboard_general_tab_activity_metrics: "Choose reports to be displayed as activity metrics on the general tab."
+
     errors:
       invalid_email: "Invalid email address."
       invalid_username: "There's no user with that username."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 7be81be..ebfd493 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -1898,3 +1898,19 @@ tags:
   force_lowercase_tags:
     default: true
     client: true
+
+dashboard:
+  dashboard_general_tab_activity_metrics:
+    client: true
+    type: list
+    list_type: compact
+    default: "page_view_total_reqs|visits|time_to_first_response|likes|flags|user_to_user_private_messages_with_replies"
+    allow_any: false
+    choices:
+      - page_view_total_reqs
+      - visits
+      - time_to_first_response
+      - likes
+      - flags
+      - user_to_user_private_messages_with_replies
+      - signups
diff --git a/test/javascripts/acceptance/dashboard-next-test.js.es6 b/test/javascripts/acceptance/dashboard-next-test.js.es6
index 0f55095..6ceb52b 100644
--- a/test/javascripts/acceptance/dashboard-next-test.js.es6
+++ b/test/javascripts/acceptance/dashboard-next-test.js.es6
@@ -1,7 +1,10 @@
 import { acceptance } from "helpers/qunit-helpers";
 
 acceptance("Dashboard Next", {
-  loggedIn: true
+  loggedIn: true,
+  settings: {
+    dashboard_general_tab_activity_metrics: "page_view_total_reqs"
+  }
 });
 
 QUnit.test("Dashboard", async assert => {
@@ -26,7 +29,6 @@ QUnit.test("tabs", async assert => {
 
 QUnit.test("general tab", async assert => {
   await visit("/admin");
-

[... diff too long, it was truncated ...]

GitHub
sha: 0402f0f3