diff --git a/app/assets/javascripts/admin/components/admin-report.js.es6 b/app/assets/javascripts/admin/components/admin-report.js.es6
index a29b627f41a..56f2457ed77 100644
--- a/app/assets/javascripts/admin/components/admin-report.js.es6
+++ b/app/assets/javascripts/admin/components/admin-report.js.es6
@@ -111,7 +111,12 @@ export default Ember.Component.extend({
unregisterHoverTooltip($(".info[data-tooltip]"));
},
- showError: Ember.computed.or("showTimeoutError", "showExceptionError"),
+ showError: Ember.computed.or(
+ "showTimeoutError",
+ "showExceptionError",
+ "showNotFoundError"
+ ),
+ showNotFoundError: Ember.computed.equal("model.error", "not_found"),
showTimeoutError: Ember.computed.equal("model.error", "timeout"),
showExceptionError: Ember.computed.equal("model.error", "exception"),
@@ -274,7 +279,7 @@ export default Ember.Component.extend({
if (!this.get("startDate") || !this.get("endDate")) {
report = sort(filteredReports)[0];
} else {
- let reportKey = this.get("reportKey");
+ const reportKey = this.get("reportKey");
report = sort(
filteredReports.filter(r => r.report_key.includes(reportKey))
@@ -283,6 +288,10 @@ export default Ember.Component.extend({
if (!report) return;
}
+ if (report.error === "not_found") {
+ this.set("showFilteringUI", false);
+ }
+
this._renderReport(
report,
this.get("forcedModes"),
diff --git a/app/assets/javascripts/admin/templates/components/admin-report.hbs b/app/assets/javascripts/admin/templates/components/admin-report.hbs
index 653feeadcc6..80f21c4a232 100644
--- a/app/assets/javascripts/admin/templates/components/admin-report.hbs
+++ b/app/assets/javascripts/admin/templates/components/admin-report.hbs
@@ -10,9 +10,13 @@
{{i18n "admin.dashboard.all_reports"}}
{{/link-to}}
-
|
+
+ {{#unless showNotFoundError}}
+ |
+ {{/unless}}
{{/if}}
+ {{#unless showNotFoundError}}
{{model.title}}
@@ -24,6 +28,7 @@
{{/if}}
+ {{/unless}}
{{/if}}
@@ -94,6 +99,13 @@
{{i18n "admin.dashboard.exception_error"}}
{{/if}}
+
+ {{#if showNotFoundError}}
+
+ {{d-icon "exclamation-triangle"}}
+ {{i18n "admin.dashboard.not_found_error"}}
+
+ {{/if}}
{{/unless}}
diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb
index 818d8dc3c74..2702ac388df 100644
--- a/app/controllers/admin/reports_controller.rb
+++ b/app/controllers/admin/reports_controller.rb
@@ -39,7 +39,12 @@ class Admin::ReportsController < Admin::AdminController
Report.cache(report, 35.minutes)
end
- reports << report if report
+ if report.blank?
+ report = Report._get(report_type, args)
+ report.error = :not_found
+ end
+
+ reports << report
end
end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 5a07acf4974..1c557df1956 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -2840,6 +2840,7 @@ en:
timeout_error: Sorry, query is taking too long, please pick a shorter interval
exception_error: Sorry, an error occurred while executing the query
too_many_requests: You’ve performed this action too many times. Please wait before trying again.
+ not_found_error: Sorry, this report doesn’t exist
reports:
trend_title: "%{percent} change. Currently %{current}, was %{prev} in previous period."
diff --git a/spec/requests/admin/reports_controller_spec.rb b/spec/requests/admin/reports_controller_spec.rb
index 793af3d217c..6110184781b 100644
--- a/spec/requests/admin/reports_controller_spec.rb
+++ b/spec/requests/admin/reports_controller_spec.rb
@@ -31,17 +31,18 @@ describe Admin::ReportsController do
context "invalid params" do
context "inexisting report" do
- it "returns only existing reports" do
+ it "returns not found reports" do
get "/admin/reports/bulk.json", params: {
reports: {
topics: { limit: 10 },
- xxx: { limit: 10 }
+ not_found: { limit: 10 }
}
}
expect(response.status).to eq(200)
- expect(JSON.parse(response.body)["reports"].count).to eq(1)
+ expect(JSON.parse(response.body)["reports"].count).to eq(2)
expect(JSON.parse(response.body)["reports"][0]["type"]).to eq("topics")
+ expect(JSON.parse(response.body)["reports"][1]["type"]).to eq("not_found")
end
end
end
diff --git a/test/javascripts/components/admin-report-test.js.es6 b/test/javascripts/components/admin-report-test.js.es6
index 0c3ef3890e9..e713ff693db 100644
--- a/test/javascripts/components/admin-report-test.js.es6
+++ b/test/javascripts/components/admin-report-test.js.es6
@@ -152,3 +152,14 @@ componentTest("rate limited", {
);
}
});
+
+componentTest("not found", {
+ template: "{{admin-report dataSourceName='not_found'}}",
+
+ test(assert) {
+ assert.ok(
+ exists(".alert-error.not-found"),
+ "it displays a not found error"
+ );
+ }
+});
diff --git a/test/javascripts/fixtures/reports_bulk.js.es6 b/test/javascripts/fixtures/reports_bulk.js.es6
index 5e303d6fc0e..2e581278e0f 100644
--- a/test/javascripts/fixtures/reports_bulk.js.es6
+++ b/test/javascripts/fixtures/reports_bulk.js.es6
@@ -86,6 +86,11 @@ signups_fixture.type = "signups_timeout";
signups_fixture.error = "timeout";
const signups_timeout = signups_fixture;
+signups_fixture = JSON.parse(JSON.stringify(signups));
+signups_fixture.type = "not_found";
+signups_fixture.error = "not_found";
+const signups_not_found = signups_fixture;
+
const startDate = moment()
.locale("en")
.utc()
@@ -177,6 +182,12 @@ const page_view_total_reqs = {
export default {
"/admin/reports/bulk": {
- reports: [signups, signups_exception, signups_timeout, page_view_total_reqs]
+ reports: [
+ signups,
+ signups_not_found,
+ signups_exception,
+ signups_timeout,
+ page_view_total_reqs
+ ]
}
};