FEATURE: displays a notice if report has no data (#6178)

This commit is contained in:
Joffrey JAFFEUX 2018-07-25 14:28:41 -04:00 committed by GitHub
parent 6ee1ea96ef
commit ad95c24307
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 2 deletions

View File

@ -111,6 +111,8 @@ export default Ember.Component.extend({
showTimeoutError: Ember.computed.alias("model.timeout"),
hasData: Ember.computed.notEmpty("model.data"),
@computed("dataSourceName", "model.type")
dasherizedDataSourceName(dataSourceName, type) {
return (dataSourceName || type || "undefined").replace(/_/g, "-");

View File

@ -67,8 +67,14 @@
<div class="report-body">
{{#unless showTimeoutError}}
{{#if currentMode}}
{{component modeComponent model=model options=options}}
{{#if hasData}}
{{#if currentMode}}
{{component modeComponent model=model options=options}}
{{/if}}
{{else}}
<div class="alert alert-info no-data-alert">
{{i18n 'admin.dashboard.reports.no_data'}}
</div>
{{/if}}
{{/unless}}

View File

@ -1,4 +1,13 @@
.admin-report {
.no-data-alert {
width: 100%;
align-self: flex-start;
}
.conditional-loading-section {
width: 100%;
}
.report-header {
display: flex;
justify-content: space-between;

View File

@ -2811,6 +2811,7 @@ en:
disabled: "This report is disabled"
totals_for_sample: "Totals for sample"
total: "All time total"
no_data: "No data to display."
trending_search:
more: '<a href="/admin/logs/search_logs">Search logs</a>'
disabled: 'Trending search report is disabled. Enable <a href="/admin/site_settings/category/all_results?filter=log%20search%20queries">log search queries</a> to collect data.'

View File

@ -115,3 +115,11 @@ componentTest("timeout", {
assert.ok(exists(".alert-error"), "it displays a timeout error");
}
});
componentTest("no data", {
template: "{{admin-report dataSourceName='posts'}}",
test(assert) {
assert.ok(exists(".no-data-alert"), "it displays a no data alert");
}
});