From 50d11fd5823f068940afb2e3f7f4c60db74cb778 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 20 Jun 2018 23:15:11 +0200 Subject: [PATCH] FIX: improves durability display check --- .../admin/controllers/admin-dashboard-next.js.es6 | 6 +++++- .../javascripts/admin/templates/dashboard_next.hbs | 2 +- app/models/admin_dashboard_next_data.rb | 13 +++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin-dashboard-next.js.es6 b/app/assets/javascripts/admin/controllers/admin-dashboard-next.js.es6 index 4ba338f5ad3..e809df69513 100644 --- a/app/assets/javascripts/admin/controllers/admin-dashboard-next.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-dashboard-next.js.es6 @@ -15,8 +15,12 @@ export default Ember.Controller.extend({ exceptionController: Ember.inject.controller("exception"), showVersionChecks: setting("version_checks"), diskSpace: Ember.computed.alias("model.attributes.disk_space"), + lastBackupTakenAt: Ember.computed.alias( + "model.attributes.last_backup_taken_at" + ), logSearchQueriesEnabled: setting("log_search_queries"), availablePeriods: ["yearly", "quarterly", "monthly", "weekly"], + shouldDisplayDurability: Ember.computed.and("lastBackupTakenAt", "diskSpace"), @computed("problems.length") foundProblems(problemsLength) { @@ -137,7 +141,7 @@ export default Ember.Controller.extend({ return moment(updatedAt).format("LLL"); }, - @computed("model.attributes.last_backup_taken_at") + @computed("lastBackupTakenAt") backupTimestamp(lastBackupTakenAt) { return moment(lastBackupTakenAt).format("LLL"); }, diff --git a/app/assets/javascripts/admin/templates/dashboard_next.hbs b/app/assets/javascripts/admin/templates/dashboard_next.hbs index 20b781c2e7c..e6db196eb96 100644 --- a/app/assets/javascripts/admin/templates/dashboard_next.hbs +++ b/app/assets/javascripts/admin/templates/dashboard_next.hbs @@ -90,7 +90,7 @@ {{#conditional-loading-section isLoading=isLoading title=(i18n "admin.dashboard.backups")}}
- {{#if diskSpace}} + {{#if shouldDisplayDurability}}
{{#if currentUser.admin}}
diff --git a/app/models/admin_dashboard_next_data.rb b/app/models/admin_dashboard_next_data.rb index 335087925f8..210fff51cd1 100644 --- a/app/models/admin_dashboard_next_data.rb +++ b/app/models/admin_dashboard_next_data.rb @@ -23,11 +23,20 @@ class AdminDashboardNextData end def as_json(_options = nil) - @json ||= { + @json ||= get_json + end + + def get_json + json = { reports: AdminDashboardNextData.reports(REPORTS), - last_backup_taken_at: last_backup_taken_at, updated_at: Time.zone.now.as_json } + + if SiteSetting.enable_backups + json[:last_backup_taken_at] = last_backup_taken_at + end + + json end def last_backup_taken_at